summaryrefslogtreecommitdiff
path: root/src/common/test.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-04-07 13:25:44 +0000
committerNick Mathewson <nickm@torproject.org>2003-04-07 13:25:44 +0000
commit79b77b421d6e6b82de46cca841d30808bba89322 (patch)
treed22ce3205261f8073839aed81fed9876e1b751da /src/common/test.h
parent18bbac44ca22c2546f66097ca3458f086608c022 (diff)
downloadtor-79b77b421d6e6b82de46cca841d30808bba89322.tar.gz
tor-79b77b421d6e6b82de46cca841d30808bba89322.zip
First test added
svn:r226
Diffstat (limited to 'src/common/test.h')
-rw-r--r--src/common/test.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/common/test.h b/src/common/test.h
new file mode 100644
index 0000000000..187828e921
--- /dev/null
+++ b/src/common/test.h
@@ -0,0 +1,75 @@
+/* Copyright 2001,2002 Roger Dingledine, Matej Pfajfar. */
+/* See LICENSE for licensing information */
+/* $Id$ */
+
+#ifndef __TEST_H
+#define __TEST_H
+
+#define test_fail() \
+ if (1) { \
+ printf("\nFile %s: line %d (%s): assertion failed.", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__); \
+ return; \
+ }
+
+#define test_assert(expr) \
+ if(expr) { printf("."); } else { \
+ printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #expr); \
+ return; \
+ }
+
+#define test_eq(expr1, expr2) \
+ if(expr1==expr2) { printf("."); } else { \
+ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
+ " (%ld != %ld)\n", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #expr1, #expr2, \
+ (long)expr1, (long)expr2); \
+ return; \
+ }
+
+#define test_neq(expr1, expr2) \
+ if(expr1!=expr2) { printf("."); } else { \
+ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
+ " (%ld == %ld)\n", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #expr1, #expr2, \
+ (long)expr1, (long)expr2); \
+ return; \
+ }
+
+#define test_streq(expr1, expr2) \
+ if(!strcmp(expr1,expr2)) { printf("."); } else { \
+ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
+ " (%s != %s)\n", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #expr1, #expr2, \
+ (long)expr1, (long)expr2); \
+ return; \
+ }
+
+#define test_strneq(expr1, expr2) \
+ if(strcmp(expr1,expr2)) { printf("."); } else { \
+ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
+ " (%s == %s)\n", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #expr1, #expr2, \
+ expr1, expr2); \
+ return; \
+ }
+
+#endif