]> git.ozlabs.org Git - ccan/blobdiff - ccan/foreach/test/compile_ok-const.c
foreach: more const iteration fixes.
[ccan] / ccan / foreach / test / compile_ok-const.c
diff --git a/ccan/foreach/test/compile_ok-const.c b/ccan/foreach/test/compile_ok-const.c
new file mode 100644 (file)
index 0000000..d1c858a
--- /dev/null
@@ -0,0 +1,14 @@
+#include <ccan/foreach/foreach.h>
+#include <ccan/foreach/foreach.c>
+
+/* Iterating over const pointers should work fine. */
+int main(int argc, char *argv[])
+{
+       const char *s1 = "hello", *s2 = "world", *p;
+       unsigned int i = 0;
+
+       foreach_ptr(p, s1, s2)
+               i++;
+
+       return i == 2 ? 0 : 1;
+}