Browse code

janssonrpcc: end of line normalization to linux line ending format

Henning Westerholt authored on 09/09/2019 19:28:22
Showing 3 changed files
... ...
@@ -1,11 +1,11 @@
1
-CC = gcc
2
-FILES = *.c ../netstring.c ../jsonrpc_global.c seatest/seatest.c
3
-OUT_EXE = test
4
-
5
-build: $(FILES)
6
-	$(CC) -std=gnu99 -pedantic -D TEST -o $(OUT_EXE) $(FILES) -lm -levent
7
-
8
-clean:
9
-	rm -f *.o core
10
-
11
-rebuild: clean build
1
+CC = gcc
2
+FILES = *.c ../netstring.c ../jsonrpc_global.c seatest/seatest.c
3
+OUT_EXE = test
4
+
5
+build: $(FILES)
6
+	$(CC) -std=gnu99 -pedantic -D TEST -o $(OUT_EXE) $(FILES) -lm -levent
7
+
8
+clean:
9
+	rm -f *.o core
10
+
11
+rebuild: clean build
... ...
@@ -1,248 +1,248 @@
1
-#include "seatest.h"
2
-#include <string.h>
3
-#ifdef WIN32
4
-#include <conio.h>
5
-#include "windows.h"
6
-#else
7
-unsigned int GetTickCount() { return 0;}
8
-void _getch( void ) { }
9
-#endif
10
-
11
-static int sea_tests_run = 0;
12
-static int sea_tests_passed = 0;
13
-static int sea_tests_failed = 0;
14
-static char* seatest_current_fixture;
15
-
16
-static void (*seatest_suite_setup_func)( void ) = 0;
17
-static void (*seatest_suite_teardown_func)( void ) = 0;
18
-static void (*seatest_fixture_setup)( void ) = 0;
19
-static void (*seatest_fixture_teardown)( void ) = 0;
20
-
21
-
22
-
23
-void suite_setup(void (*setup)( void ))
24
-{
25
-	seatest_suite_setup_func = setup;
26
-}
27
-void suite_teardown(void (*teardown)( void ))
28
-{
29
-	seatest_suite_teardown_func = teardown;
30
-}
31
-
32
-void seatest_suite_setup( void )
33
-{
34
-	if(seatest_suite_setup_func != 0) seatest_suite_setup_func();
35
-}
36
-
37
-void seatest_suite_teardown( void )
38
-{
39
-	if(seatest_suite_teardown_func != 0) seatest_suite_teardown_func();
40
-}
41
-
42
-void fixture_setup(void (*setup)( void ))
43
-{
44
-	seatest_fixture_setup = setup;
45
-}
46
-void fixture_teardown(void (*teardown)( void ))
47
-{
48
-	seatest_fixture_teardown = teardown;
49
-}
50
-
51
-void seatest_setup( void )
52
-{
53
-	if(seatest_fixture_setup != 0) seatest_fixture_setup();
54
-}
55
-
56
-void seatest_teardown( void )
57
-{
58
-	if(seatest_fixture_teardown != 0) seatest_fixture_teardown();
59
-}
60
-
61
-char* test_file_name(char* path)
62
-{
63
-	char* file = path + strlen(path);
64
-	while(file != path && *file!= '\\' ) file--;
65
-	if(*file == '\\') file++;
66
-	return file;
67
-}
68
-
69
-static int seatest_fixture_tests_run;
70
-static int seatest_fixture_tests_failed;
71
-
72
-void seatest_simple_test_result(int passed, char* reason, const char* function, unsigned int line)
73
-{
74
-	if (!passed)
75
-	{
76
-		printf("%-20s Line %-5d %s\r\n", function, line, reason );
77
-		sea_tests_failed++; 
78
-	}
79
-	else
80
-	{
81
-		sea_tests_passed++; 
82
-	}	
83
-}
84
-
85
-void seatest_assert_true(int test, const char* function, unsigned int line)
86
-{
87
-	seatest_simple_test_result(test, "Should of been true", function, line);
88
-
89
-}
90
-
91
-void seatest_assert_false(int test, const char* function, unsigned int line)
92
-{
93
-	seatest_simple_test_result(!test, "Should of been false", function, line);	
94
-}
95
-
96
-
97
-void seatest_assert_int_equal(int expected, int actual, const char* function, unsigned int line)
98
-{
99
-	char s[SEATEST_PRINT_BUFFER_SIZE];
100
-	sprintf(s, "Expected %d but was %d", expected, actual);
101
-	seatest_simple_test_result(expected==actual, s, function, line);	
102
-}
103
-
104
-void seatest_assert_ulong_equal(unsigned long expected, unsigned long actual, const char* function, unsigned int line)
105
-{
106
-	char s[SEATEST_PRINT_BUFFER_SIZE];
107
-	sprintf(s, "Expected %lu but was %lu", expected, actual);
108
-	seatest_simple_test_result(expected==actual, s, function, line);	
109
-}
110
-
111
-void seatest_assert_float_equal( float expected, float actual, float delta, const char* function, unsigned int line )
112
-{
113
-	char s[SEATEST_PRINT_BUFFER_SIZE];
114
-	float result = expected-actual;
115
-	sprintf(s, "Expected %f but was %f", expected, actual);
116
-	if(result < 0.0) result = 0.0f - result;
117
-	seatest_simple_test_result( result <= delta, s, function, line);	
118
-}
119
-
120
-void seatest_assert_double_equal( double expected, double actual, double delta, const char* function, unsigned int line )
121
-{
122
-	char s[SEATEST_PRINT_BUFFER_SIZE];
123
-	double result = expected-actual;
124
-	sprintf(s, "Expected %f but was %f", expected, actual);
125
-	if(result < 0.0) result = 0.0 - result;
126
-	seatest_simple_test_result( result <= delta, s, function, line);	
127
-}
128
-
129
-void seatest_assert_string_equal(char* expected, char* actual, const char* function, unsigned int line)
130
-{
131
-	char s[SEATEST_PRINT_BUFFER_SIZE];
132
-	sprintf(s, "Expected %s but was %s", expected, actual);
133
-	seatest_simple_test_result(strcmp(expected, actual)==0, s, function, line);	
134
-}
135
-
136
-void seatest_assert_string_ends_with(char* expected, char* actual, const char* function, unsigned int line)
137
-{
138
-	char s[SEATEST_PRINT_BUFFER_SIZE];
139
-	sprintf(s, "Expected %s to end with %s", actual, expected);
140
-	seatest_simple_test_result(strcmp(expected, actual+(strlen(actual)-strlen(expected)))==0, s, function, line);	
141
-}
142
-
143
-void seatest_assert_string_starts_with(char* expected, char* actual, const char* function, unsigned int line)
144
-{
145
-	char s[SEATEST_PRINT_BUFFER_SIZE];
146
-	sprintf(s, "Expected %s to start with %s", actual, expected);
147
-	seatest_simple_test_result(strncmp(expected, actual, strlen(expected))==0, s, function, line);	
148
-}
149
-
150
-void seatest_assert_string_contains(char* expected, char* actual, const char* function, unsigned int line)
151
-{
152
-	char s[SEATEST_PRINT_BUFFER_SIZE];
153
-	sprintf(s, "Expected %s to be in %s", expected, actual);
154
-	seatest_simple_test_result(strstr(actual, expected)!=0, s, function, line);	
155
-}
156
-
157
-void seatest_assert_string_doesnt_contain(char* expected, char* actual, const char* function, unsigned int line)
158
-{
159
-	char s[SEATEST_PRINT_BUFFER_SIZE];
160
-	sprintf(s, "Expected %s not to have %s in it", actual, expected);
161
-	seatest_simple_test_result(strstr(actual, expected)==0, s, function, line);	
162
-}
163
-
164
-void seatest_run_test(void)
165
-{
166
-	sea_tests_run++; 
167
-}
168
-
169
-void seatest_header_printer(char* s, int length, char f)
170
-{
171
-	int l = strlen(s);
172
-	int d = (length- (l + 2)) / 2;
173
-	int i;
174
-	for(i = 0; i<d; i++) printf("%c",f);
175
-	printf(" %s ", s);
176
-	for(i = (d+l+2); i<length; i++) printf("%c",f);
177
-	printf("\r\n");
178
-}
179
-
180
-
181
-void seatest_test_fixture_start(char* filepath)
182
-{
183
-	seatest_current_fixture = test_file_name(filepath);
184
-	seatest_header_printer(seatest_current_fixture, 50, '-');
185
-	seatest_fixture_tests_failed = sea_tests_failed;
186
-	seatest_fixture_tests_run = sea_tests_run;
187
-	seatest_fixture_teardown = 0;
188
-	seatest_fixture_setup = 0;
189
-}
190
-
191
-void seatest_test_fixture_end()
192
-{
193
-	char s[SEATEST_PRINT_BUFFER_SIZE];
194
-	sprintf(s, "%d run  %d failed", sea_tests_run-seatest_fixture_tests_run, sea_tests_failed-seatest_fixture_tests_failed);
195
-	seatest_header_printer(s, 50, ' ');
196
-	printf("\r\n");
197
-}
198
-
199
-static char* seatest_fixture_filter = 0;
200
-static char* seatest_test_filter = 0;
201
-
202
-void fixture_filter(char* filter)
203
-{
204
-	seatest_fixture_filter = filter;
205
-}
206
-
207
-
208
-void test_filter(char* filter)
209
-{
210
-	seatest_test_filter = filter;
211
-}
212
-
213
-
214
-int seatest_should_run( char* fixture, char* test)
215
-{
216
-	int run = 1;
217
-	if(seatest_fixture_filter) 
218
-	{
219
-		if(strncmp(seatest_fixture_filter, fixture, strlen(seatest_fixture_filter)) != 0) run = 0;
220
-	}
221
-	if(seatest_test_filter) 
222
-	{
223
-		if(strncmp(seatest_test_filter, test, strlen(seatest_test_filter)) != 0) run = 0;
224
-	}
225
-	return run;
226
-}
227
-
228
-int run_tests(void (*tests)(void))
229
-{
230
-	unsigned long end;
231
-	unsigned long start = GetTickCount();
232
-	tests();	 
233
-	end = GetTickCount();
234
-	printf("\r\n\r\n==================SEATEST v%s====================\r\n\r\n", SEATEST_VERSION);	 
235
-	if (sea_tests_failed > 0) {
236
-		printf("                      Failed\r\n");			
237
-	}
238
-	else {
239
-		printf("               ALL TESTS PASSED\r\n");
240
-	}
241
-	printf("                 %d tests run\r\n", sea_tests_run);
242
-	printf("                    in %lu ms\r\n",end - start);
243
-	printf("==================================================\r\n");
244
-
245
-	_getch();
246
-	return sea_tests_failed == 0;
247
-}
248
-
1
+#include "seatest.h"
2
+#include <string.h>
3
+#ifdef WIN32
4
+#include <conio.h>
5
+#include "windows.h"
6
+#else
7
+unsigned int GetTickCount() { return 0;}
8
+void _getch( void ) { }
9
+#endif
10
+
11
+static int sea_tests_run = 0;
12
+static int sea_tests_passed = 0;
13
+static int sea_tests_failed = 0;
14
+static char* seatest_current_fixture;
15
+
16
+static void (*seatest_suite_setup_func)( void ) = 0;
17
+static void (*seatest_suite_teardown_func)( void ) = 0;
18
+static void (*seatest_fixture_setup)( void ) = 0;
19
+static void (*seatest_fixture_teardown)( void ) = 0;
20
+
21
+
22
+
23
+void suite_setup(void (*setup)( void ))
24
+{
25
+	seatest_suite_setup_func = setup;
26
+}
27
+void suite_teardown(void (*teardown)( void ))
28
+{
29
+	seatest_suite_teardown_func = teardown;
30
+}
31
+
32
+void seatest_suite_setup( void )
33
+{
34
+	if(seatest_suite_setup_func != 0) seatest_suite_setup_func();
35
+}
36
+
37
+void seatest_suite_teardown( void )
38
+{
39
+	if(seatest_suite_teardown_func != 0) seatest_suite_teardown_func();
40
+}
41
+
42
+void fixture_setup(void (*setup)( void ))
43
+{
44
+	seatest_fixture_setup = setup;
45
+}
46
+void fixture_teardown(void (*teardown)( void ))
47
+{
48
+	seatest_fixture_teardown = teardown;
49
+}
50
+
51
+void seatest_setup( void )
52
+{
53
+	if(seatest_fixture_setup != 0) seatest_fixture_setup();
54
+}
55
+
56
+void seatest_teardown( void )
57
+{
58
+	if(seatest_fixture_teardown != 0) seatest_fixture_teardown();
59
+}
60
+
61
+char* test_file_name(char* path)
62
+{
63
+	char* file = path + strlen(path);
64
+	while(file != path && *file!= '\\' ) file--;
65
+	if(*file == '\\') file++;
66
+	return file;
67
+}
68
+
69
+static int seatest_fixture_tests_run;
70
+static int seatest_fixture_tests_failed;
71
+
72
+void seatest_simple_test_result(int passed, char* reason, const char* function, unsigned int line)
73
+{
74
+	if (!passed)
75
+	{
76
+		printf("%-20s Line %-5d %s\r\n", function, line, reason );
77
+		sea_tests_failed++; 
78
+	}
79
+	else
80
+	{
81
+		sea_tests_passed++; 
82
+	}	
83
+}
84
+
85
+void seatest_assert_true(int test, const char* function, unsigned int line)
86
+{
87
+	seatest_simple_test_result(test, "Should of been true", function, line);
88
+
89
+}
90
+
91
+void seatest_assert_false(int test, const char* function, unsigned int line)
92
+{
93
+	seatest_simple_test_result(!test, "Should of been false", function, line);	
94
+}
95
+
96
+
97
+void seatest_assert_int_equal(int expected, int actual, const char* function, unsigned int line)
98
+{
99
+	char s[SEATEST_PRINT_BUFFER_SIZE];
100
+	sprintf(s, "Expected %d but was %d", expected, actual);
101
+	seatest_simple_test_result(expected==actual, s, function, line);	
102
+}
103
+
104
+void seatest_assert_ulong_equal(unsigned long expected, unsigned long actual, const char* function, unsigned int line)
105
+{
106
+	char s[SEATEST_PRINT_BUFFER_SIZE];
107
+	sprintf(s, "Expected %lu but was %lu", expected, actual);
108
+	seatest_simple_test_result(expected==actual, s, function, line);	
109
+}
110
+
111
+void seatest_assert_float_equal( float expected, float actual, float delta, const char* function, unsigned int line )
112
+{
113
+	char s[SEATEST_PRINT_BUFFER_SIZE];
114
+	float result = expected-actual;
115
+	sprintf(s, "Expected %f but was %f", expected, actual);
116
+	if(result < 0.0) result = 0.0f - result;
117
+	seatest_simple_test_result( result <= delta, s, function, line);	
118
+}
119
+
120
+void seatest_assert_double_equal( double expected, double actual, double delta, const char* function, unsigned int line )
121
+{
122
+	char s[SEATEST_PRINT_BUFFER_SIZE];
123
+	double result = expected-actual;
124
+	sprintf(s, "Expected %f but was %f", expected, actual);
125
+	if(result < 0.0) result = 0.0 - result;
126
+	seatest_simple_test_result( result <= delta, s, function, line);	
127
+}
128
+
129
+void seatest_assert_string_equal(char* expected, char* actual, const char* function, unsigned int line)
130
+{
131
+	char s[SEATEST_PRINT_BUFFER_SIZE];
132
+	sprintf(s, "Expected %s but was %s", expected, actual);
133
+	seatest_simple_test_result(strcmp(expected, actual)==0, s, function, line);	
134
+}
135
+
136
+void seatest_assert_string_ends_with(char* expected, char* actual, const char* function, unsigned int line)
137
+{
138
+	char s[SEATEST_PRINT_BUFFER_SIZE];
139
+	sprintf(s, "Expected %s to end with %s", actual, expected);
140
+	seatest_simple_test_result(strcmp(expected, actual+(strlen(actual)-strlen(expected)))==0, s, function, line);	
141
+}
142
+
143
+void seatest_assert_string_starts_with(char* expected, char* actual, const char* function, unsigned int line)
144
+{
145
+	char s[SEATEST_PRINT_BUFFER_SIZE];
146
+	sprintf(s, "Expected %s to start with %s", actual, expected);
147
+	seatest_simple_test_result(strncmp(expected, actual, strlen(expected))==0, s, function, line);	
148
+}
149
+
150
+void seatest_assert_string_contains(char* expected, char* actual, const char* function, unsigned int line)
151
+{
152
+	char s[SEATEST_PRINT_BUFFER_SIZE];
153
+	sprintf(s, "Expected %s to be in %s", expected, actual);
154
+	seatest_simple_test_result(strstr(actual, expected)!=0, s, function, line);	
155
+}
156
+
157
+void seatest_assert_string_doesnt_contain(char* expected, char* actual, const char* function, unsigned int line)
158
+{
159
+	char s[SEATEST_PRINT_BUFFER_SIZE];
160
+	sprintf(s, "Expected %s not to have %s in it", actual, expected);
161
+	seatest_simple_test_result(strstr(actual, expected)==0, s, function, line);	
162
+}
163
+
164
+void seatest_run_test(void)
165
+{
166
+	sea_tests_run++; 
167
+}
168
+
169
+void seatest_header_printer(char* s, int length, char f)
170
+{
171
+	int l = strlen(s);
172
+	int d = (length- (l + 2)) / 2;
173
+	int i;
174
+	for(i = 0; i<d; i++) printf("%c",f);
175
+	printf(" %s ", s);
176
+	for(i = (d+l+2); i<length; i++) printf("%c",f);
177
+	printf("\r\n");
178
+}
179
+
180
+
181
+void seatest_test_fixture_start(char* filepath)
182
+{
183
+	seatest_current_fixture = test_file_name(filepath);
184
+	seatest_header_printer(seatest_current_fixture, 50, '-');
185
+	seatest_fixture_tests_failed = sea_tests_failed;
186
+	seatest_fixture_tests_run = sea_tests_run;
187
+	seatest_fixture_teardown = 0;
188
+	seatest_fixture_setup = 0;
189
+}
190
+
191
+void seatest_test_fixture_end()
192
+{
193
+	char s[SEATEST_PRINT_BUFFER_SIZE];
194
+	sprintf(s, "%d run  %d failed", sea_tests_run-seatest_fixture_tests_run, sea_tests_failed-seatest_fixture_tests_failed);
195
+	seatest_header_printer(s, 50, ' ');
196
+	printf("\r\n");
197
+}
198
+
199
+static char* seatest_fixture_filter = 0;
200
+static char* seatest_test_filter = 0;
201
+
202
+void fixture_filter(char* filter)
203
+{
204
+	seatest_fixture_filter = filter;
205
+}
206
+
207
+
208
+void test_filter(char* filter)
209
+{
210
+	seatest_test_filter = filter;
211
+}
212
+
213
+
214
+int seatest_should_run( char* fixture, char* test)
215
+{
216
+	int run = 1;
217
+	if(seatest_fixture_filter) 
218
+	{
219
+		if(strncmp(seatest_fixture_filter, fixture, strlen(seatest_fixture_filter)) != 0) run = 0;
220
+	}
221
+	if(seatest_test_filter) 
222
+	{
223
+		if(strncmp(seatest_test_filter, test, strlen(seatest_test_filter)) != 0) run = 0;
224
+	}
225
+	return run;
226
+}
227
+
228
+int run_tests(void (*tests)(void))
229
+{
230
+	unsigned long end;
231
+	unsigned long start = GetTickCount();
232
+	tests();	 
233
+	end = GetTickCount();
234
+	printf("\r\n\r\n==================SEATEST v%s====================\r\n\r\n", SEATEST_VERSION);	 
235
+	if (sea_tests_failed > 0) {
236
+		printf("                      Failed\r\n");			
237
+	}
238
+	else {
239
+		printf("               ALL TESTS PASSED\r\n");
240
+	}
241
+	printf("                 %d tests run\r\n", sea_tests_run);
242
+	printf("                    in %lu ms\r\n",end - start);
243
+	printf("==================================================\r\n");
244
+
245
+	_getch();
246
+	return sea_tests_failed == 0;
247
+}
248
+
... ...
@@ -1,74 +1,74 @@
1
-#ifndef SEATEST_H
2
-#define SEATEST_H
3
-#include <stdio.h>
4
-
5
-/*
6
-Defines
7
-*/
8
-
9
-#define SEATEST_VERSION "0.5"
10
-#define SEATEST_PROJECT_HOME "http://code.google.com/p/seatest/"
11
-#define SEATEST_PRINT_BUFFER_SIZE 100000
12
-
13
-/*
14
-Declarations
15
-*/
16
-
17
-void seatest_test_fixture_start(char* filepath);
18
-void seatest_test_fixture_end( void );
19
-void seatest_simple_test_result(int passed, char* reason, const char* function, unsigned int line);
20
-void seatest_assert_true(int test, const char* function, unsigned int line);
21
-void seatest_assert_false(int test, const char* function, unsigned int line);
22
-void seatest_assert_int_equal(int expected, int actual, const char* function, unsigned int line);
23
-void seatest_assert_ulong_equal(unsigned long expected, unsigned long actual, const char* function, unsigned int line);
24
-void seatest_assert_float_equal(float expected, float actual, float delta, const char* function, unsigned int line);
25
-void seatest_assert_double_equal(double expected, double actual, double delta, const char* function, unsigned int line);
26
-void seatest_assert_string_equal(char* expected, char* actual, const char* function, unsigned int line);
27
-void seatest_assert_string_ends_with(char* expected, char* actual, const char* function, unsigned int line);
28
-void seatest_assert_string_starts_with(char* expected, char* actual, const char* function, unsigned int line);
29
-void seatest_assert_string_contains(char* expected, char* actual, const char* function, unsigned int line);
30
-void seatest_assert_string_doesnt_contain(char* expected, char* actual, const char* function, unsigned int line);
31
-int seatest_should_run( char* fixture, char* test);
32
-void seatest_run_test(void);
33
-void seatest_setup( void );
34
-void seatest_teardown( void );
35
-void seatest_suite_teardown( void );
36
-void seatest_suite_setup( void );
37
-
38
-/*
39
-Assert Macros
40
-*/
41
-
42
-#define assert_true(test) do { seatest_assert_true(test, __FUNCTION__, __LINE__); } while (0)
43
-#define assert_false(test) do {  seatest_assert_false(test, __FUNCTION__, __LINE__); } while (0)
44
-#define assert_int_equal(expected, actual) do {  seatest_assert_int_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
45
-#define assert_ulong_equal(expected, actual) do {  seatest_assert_ulong_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
46
-#define assert_string_equal(expected, actual) do {  seatest_assert_string_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
47
-#define assert_n_array_equal(expected, actual, n) do { int seatest_count; for(seatest_count=0; seatest_count<n; seatest_count++) { char s_seatest[SEATEST_PRINT_BUFFER_SIZE]; sprintf(s_seatest,"Expected %d to be %d at position %d", actual[seatest_count], expected[seatest_count], seatest_count); seatest_simple_test_result((expected[seatest_count] == actual[seatest_count]), s_seatest, __FUNCTION__, __LINE__);} } while (0)
48
-#define assert_bit_set(bit_number, value) { seatest_simple_test_result(((1 << bit_number) & value), " Expected bit to be set" ,  __FUNCTION__, __LINE__); } while (0)
49
-#define assert_bit_not_set(bit_number, value) { seatest_simple_test_result(!((1 << bit_number) & value), " Expected bit not to to be set" ,  __FUNCTION__, __LINE__); } while (0)
50
-#define assert_bit_mask_matches(value, mask) { seatest_simple_test_result(((value & mask) == mask), " Expected all bits of mask to be set" ,  __FUNCTION__, __LINE__); } while (0)
51
-#define assert_fail(message) { seatest_simple_test_result(0, message,  __FUNCTION__, __LINE__); } while (0)
52
-#define assert_float_equal(expected, actual, delta) do {  seatest_assert_float_equal(expected, actual, delta, __FUNCTION__, __LINE__); } while (0)
53
-#define assert_double_equal(expected, actual, delta) do {  seatest_assert_double_equal(expected, actual, delta, __FUNCTION__, __LINE__); } while (0)
54
-#define assert_string_contains(expected, actual) do {  seatest_assert_string_contains(expected, actual, __FUNCTION__, __LINE__); } while (0)
55
-#define assert_string_doesnt_contain(expected, actual) do {  seatest_assert_string_doesnt_contain(expected, actual, __FUNCTION__, __LINE__); } while (0)
56
-#define assert_string_starts_with(expected, actual) do {  seatest_assert_string_starts_with(expected, actual, __FUNCTION__, __LINE__); } while (0)
57
-#define assert_string_ends_with(expected, actual) do {  seatest_assert_string_ends_with(expected, actual, __FUNCTION__, __LINE__); } while (0)
58
-
59
-/*
60
-Fixture / Test Management
61
-*/
62
-
63
-void fixture_setup(void (*setup)( void ));
64
-void fixture_teardown(void (*teardown)( void ));
65
-#define run_test(test) do { if(seatest_should_run(__FILE__, #test)) {seatest_suite_setup(); seatest_setup(); test(); seatest_teardown(); seatest_suite_teardown(); seatest_run_test();  }} while (0)
66
-#define test_fixture_start() do { seatest_test_fixture_start(__FILE__); } while (0)
67
-#define test_fixture_end() do { seatest_test_fixture_end();} while (0)
68
-void fixture_filter(char* filter);
69
-void test_filter(char* filter);
70
-
71
-int run_tests(void (*tests)(void));
72
-void suite_teardown(void (*teardown)( void ));
73
-void suite_setup(void (*setup)( void ));
74
-#endif 
1
+#ifndef SEATEST_H
2
+#define SEATEST_H
3
+#include <stdio.h>
4
+
5
+/*
6
+Defines
7
+*/
8
+
9
+#define SEATEST_VERSION "0.5"
10
+#define SEATEST_PROJECT_HOME "http://code.google.com/p/seatest/"
11
+#define SEATEST_PRINT_BUFFER_SIZE 100000
12
+
13
+/*
14
+Declarations
15
+*/
16
+
17
+void seatest_test_fixture_start(char* filepath);
18
+void seatest_test_fixture_end( void );
19
+void seatest_simple_test_result(int passed, char* reason, const char* function, unsigned int line);
20
+void seatest_assert_true(int test, const char* function, unsigned int line);
21
+void seatest_assert_false(int test, const char* function, unsigned int line);
22
+void seatest_assert_int_equal(int expected, int actual, const char* function, unsigned int line);
23
+void seatest_assert_ulong_equal(unsigned long expected, unsigned long actual, const char* function, unsigned int line);
24
+void seatest_assert_float_equal(float expected, float actual, float delta, const char* function, unsigned int line);
25
+void seatest_assert_double_equal(double expected, double actual, double delta, const char* function, unsigned int line);
26
+void seatest_assert_string_equal(char* expected, char* actual, const char* function, unsigned int line);
27
+void seatest_assert_string_ends_with(char* expected, char* actual, const char* function, unsigned int line);
28
+void seatest_assert_string_starts_with(char* expected, char* actual, const char* function, unsigned int line);
29
+void seatest_assert_string_contains(char* expected, char* actual, const char* function, unsigned int line);
30
+void seatest_assert_string_doesnt_contain(char* expected, char* actual, const char* function, unsigned int line);
31
+int seatest_should_run( char* fixture, char* test);
32
+void seatest_run_test(void);
33
+void seatest_setup( void );
34
+void seatest_teardown( void );
35
+void seatest_suite_teardown( void );
36
+void seatest_suite_setup( void );
37
+
38
+/*
39
+Assert Macros
40
+*/
41
+
42
+#define assert_true(test) do { seatest_assert_true(test, __FUNCTION__, __LINE__); } while (0)
43
+#define assert_false(test) do {  seatest_assert_false(test, __FUNCTION__, __LINE__); } while (0)
44
+#define assert_int_equal(expected, actual) do {  seatest_assert_int_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
45
+#define assert_ulong_equal(expected, actual) do {  seatest_assert_ulong_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
46
+#define assert_string_equal(expected, actual) do {  seatest_assert_string_equal(expected, actual, __FUNCTION__, __LINE__); } while (0)
47
+#define assert_n_array_equal(expected, actual, n) do { int seatest_count; for(seatest_count=0; seatest_count<n; seatest_count++) { char s_seatest[SEATEST_PRINT_BUFFER_SIZE]; sprintf(s_seatest,"Expected %d to be %d at position %d", actual[seatest_count], expected[seatest_count], seatest_count); seatest_simple_test_result((expected[seatest_count] == actual[seatest_count]), s_seatest, __FUNCTION__, __LINE__);} } while (0)
48
+#define assert_bit_set(bit_number, value) { seatest_simple_test_result(((1 << bit_number) & value), " Expected bit to be set" ,  __FUNCTION__, __LINE__); } while (0)
49
+#define assert_bit_not_set(bit_number, value) { seatest_simple_test_result(!((1 << bit_number) & value), " Expected bit not to to be set" ,  __FUNCTION__, __LINE__); } while (0)
50
+#define assert_bit_mask_matches(value, mask) { seatest_simple_test_result(((value & mask) == mask), " Expected all bits of mask to be set" ,  __FUNCTION__, __LINE__); } while (0)
51
+#define assert_fail(message) { seatest_simple_test_result(0, message,  __FUNCTION__, __LINE__); } while (0)
52
+#define assert_float_equal(expected, actual, delta) do {  seatest_assert_float_equal(expected, actual, delta, __FUNCTION__, __LINE__); } while (0)
53
+#define assert_double_equal(expected, actual, delta) do {  seatest_assert_double_equal(expected, actual, delta, __FUNCTION__, __LINE__); } while (0)
54
+#define assert_string_contains(expected, actual) do {  seatest_assert_string_contains(expected, actual, __FUNCTION__, __LINE__); } while (0)
55
+#define assert_string_doesnt_contain(expected, actual) do {  seatest_assert_string_doesnt_contain(expected, actual, __FUNCTION__, __LINE__); } while (0)
56
+#define assert_string_starts_with(expected, actual) do {  seatest_assert_string_starts_with(expected, actual, __FUNCTION__, __LINE__); } while (0)
57
+#define assert_string_ends_with(expected, actual) do {  seatest_assert_string_ends_with(expected, actual, __FUNCTION__, __LINE__); } while (0)
58
+
59
+/*
60
+Fixture / Test Management
61
+*/
62
+
63
+void fixture_setup(void (*setup)( void ));
64
+void fixture_teardown(void (*teardown)( void ));
65
+#define run_test(test) do { if(seatest_should_run(__FILE__, #test)) {seatest_suite_setup(); seatest_setup(); test(); seatest_teardown(); seatest_suite_teardown(); seatest_run_test();  }} while (0)
66
+#define test_fixture_start() do { seatest_test_fixture_start(__FILE__); } while (0)
67
+#define test_fixture_end() do { seatest_test_fixture_end();} while (0)
68
+void fixture_filter(char* filter);
69
+void test_filter(char* filter);
70
+
71
+int run_tests(void (*tests)(void));
72
+void suite_teardown(void (*teardown)( void ));
73
+void suite_setup(void (*setup)( void ));
74
+#endif