Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc / deps / grpc / third_party / upb / tests / upb_test.h
diff --git a/legacy-libs/grpc/deps/grpc/third_party/upb/tests/upb_test.h b/legacy-libs/grpc/deps/grpc/third_party/upb/tests/upb_test.h
new file mode 100644 (file)
index 0000000..d4b0688
--- /dev/null
@@ -0,0 +1,53 @@
+
+#ifndef UPB_TEST_H_
+#define UPB_TEST_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int num_assertions = 0;
+uint32_t testhash = 0;
+
+#define PRINT_FAILURE(expr) \
+  fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \
+  fprintf(stderr, "expr: %s\n", #expr); \
+  if (testhash) { \
+    fprintf(stderr, "assertion failed running test %x.  " \
+                    "Run with the arg %x to run only this test.\n", \
+                    testhash, testhash); \
+  }
+
+#define ASSERT(expr) do { \
+  ++num_assertions; \
+  if (!(expr)) { \
+    PRINT_FAILURE(expr) \
+    abort(); \
+  } \
+} while (0)
+
+#define ASSERT_NOCOUNT(expr) do { \
+  if (!(expr)) { \
+    PRINT_FAILURE(expr) \
+    abort(); \
+  } \
+} while (0)
+
+#define ASSERT_STATUS(expr, status) do { \
+  ++num_assertions; \
+  if (!(expr)) { \
+    PRINT_FAILURE(expr) \
+    fprintf(stderr, "failed status: %s\n", upb_status_errmsg(status)); \
+    abort(); \
+  } \
+} while (0)
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif  /* UPB_DECODER_H_ */