Merge branch 'jk/messages-with-excess-lf-fix'
[git/gitster.git] / reftable / test_framework.h
blob687390f9c239a397652a9a4c9a0bbb7a3510d232
1 /*
2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
7 */
9 #ifndef TEST_FRAMEWORK_H
10 #define TEST_FRAMEWORK_H
12 #include "system.h"
13 #include "reftable-error.h"
15 #define EXPECT_ERR(c) \
16 do { \
17 if (c != 0) { \
18 fflush(stderr); \
19 fflush(stdout); \
20 fprintf(stderr, "%s: %d: error == %d (%s), want 0\n", \
21 __FILE__, __LINE__, c, reftable_error_str(c)); \
22 abort(); \
23 } \
24 } while (0)
26 #define EXPECT_STREQ(a, b) \
27 do { \
28 if (strcmp(a, b)) { \
29 fflush(stderr); \
30 fflush(stdout); \
31 fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \
32 __LINE__, #a, a, #b, b); \
33 abort(); \
34 } \
35 } while (0)
37 #define EXPECT(c) \
38 do { \
39 if (!(c)) { \
40 fflush(stderr); \
41 fflush(stdout); \
42 fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \
43 __LINE__, #c); \
44 abort(); \
45 } \
46 } while (0)
48 #define RUN_TEST(f) \
49 fprintf(stderr, "running %s\n", #f); \
50 fflush(stderr); \
51 f();
53 void set_test_hash(uint8_t *p, int i);
55 /* Like strbuf_add, but suitable for passing to reftable_new_writer
57 ssize_t strbuf_add_void(void *b, const void *data, size_t sz);
59 int noop_flush(void *);
61 #endif