-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.c
110 lines (93 loc) · 2.18 KB
/
basic.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <signal.h>
#ifndef _WIN32
#include <sanitizer/asan_interface.h>
#include <unistd.h>
#else
#include <Windows.h>
#include <stdbool.h>
#endif
// !!!! The only needed header here. !!!!
#include "../src/souffle.h"
SETUP(main_suite, TestCase1) {
int *data = malloc(sizeof(int));
assert(data);
*data = 5;
*ctx = data;
}
TEST(main_suite, TestCase1) {
ASSERT_TRUE(true);
int *data = (int *)*ctx;
ASSERT_NOT_NULL(data);
ASSERT_EQ(*data, 5);
}
TEARDOWN(main_suite, TestCase1) { free(*ctx); }
TEST(main_suite, test_number_eq) {
int a = 5;
int b = 1;
ASSERT_EQ(a, b);
}
TEST(main_suite, exception_test) {
// ASSERT_EQ(12, 1);
#ifndef _WIN32
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
LOG_MSG("ASAN is ON, skipping...\n");
SKIP_TEST();
#endif
raise(SIGSEGV);
#else
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
#endif
}
TEST(main_suite, pass) { ASSERT_EQ(1, 1); }
TEST(main_suite, pass_fail_pass) {
ASSERT_EQ(1, 1);
ASSERT_EQ(2, 1);
ASSERT_EQ(1, 1);
}
TEST(main_suite, float_check) { ASSERT_EQ(1.5, 2.5); }
TEST(main_suite, pass_fail) {
ASSERT_EQ(1, 1);
ASSERT_EQ(2, 1);
}
TEST(main_suite, skip_me) {
SKIP_TEST();
ASSERT_EQ(1, 1);
}
// Used to test print border expansion.
TEST(
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE,
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE) {
ASSERT_EQ(1, 1);
}
TEST(arr_suite, array_check) {
int a[3] = {1, 2, 3};
int b[3] = {1, 4, 3};
ASSERT_INT_ARR_EQ(a, b, 3);
}
TEST(main_suite, long_test) {
for (size_t i = 0; i < 3; i++) {
#ifndef _WIN32
sleep(1);
#else
Sleep(1000);
#endif
ASSERT_EQ(i, i);
}
}
TEST(main_suite, timeout_test) {
for (size_t i = 0; i < 10000000000; i++) {
#ifndef _WIN32
sleep(1);
#else
Sleep(1000);
#endif
ASSERT_EQ(i, i);
}
}
TEST(suite_2, is_true) { ASSERT_TRUE(true); }
TEST(main_suite, string_test) { ASSERT_STR_EQ("Hello, World", "Hello World!"); }
TEST(main_suite, log_on_pass) {
ASSERT_EQ(1, 1);
LOG_MSG("This is a log message\n");
LOG_MSG("This is a second log message\n");
}