Test case for verify.h.
authorBruno Haible <bruno@clisp.org>
Fri, 23 Sep 2005 13:42:08 +0000 (13:42 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 23 Sep 2005 13:42:08 +0000 (13:42 +0000)
ChangeLog
tests/test-verify.c [new file with mode: 0644]

index c7971b1725b50353e8db1e217bd5b76fe3171083..148993ce18e44bcadc66cd37250220de1df3c62e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-09-23  Bruno Haible  <bruno@clisp.org>
+
+       * tests/test-verify.c: New file.
+
 2005-09-22  Paul Eggert  <eggert@cs.ucla.edu>
 
        Sync from coreutils.
diff --git a/tests/test-verify.c b/tests/test-verify.c
new file mode 100644 (file)
index 0000000..74bee4e
--- /dev/null
@@ -0,0 +1,22 @@
+#include "verify.h"
+
+int x;
+enum { a, b, c };
+
+verify (x >= 0);                  /* should give ERROR: non-constant expression */
+verify (c == 2);                  /* should be ok */
+verify (1 + 1 == 3);              /* should give ERROR */
+verify (1 == 1); verify (1 == 1); /* should be ok */
+
+int function (int n)
+{
+  verify (n >= 0);                  /* should give ERROR: non-constant expression */
+  verify (c == 2);                  /* should be ok */
+  verify (1 + 1 == 3);              /* should give ERROR */
+  verify (1 == 1); verify (1 == 1); /* should be ok */
+
+  if (n)
+    return (verify_expr (1 == 1), verify_expr (1 == 1), 7); /* should be ok */
+  else
+    return (verify_expr (1 == 2), 5); /* should give ERROR */
+}