-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_http_blank_line_parse.c
More file actions
37 lines (30 loc) · 1021 Bytes
/
test_http_blank_line_parse.c
File metadata and controls
37 lines (30 loc) · 1021 Bytes
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
#include "http_blank_line_parse.h"
#include "debug.h"
#include <stdio.h>
void assert(int check, char * description) {
printf("[%s] - %s\n", check ? "T" : "F", description);
}
void test_basic() {
printf("Testing Basic\n");
enum BLANK_LINE_STATE state = init_blank_line_state();
assert(state == BLANK_STATE_START, "Start");
state = update_blank_line_state(state, '\r');
assert(state == BLANK_STATE_R_1, "\\r");
state = update_blank_line_state(state, '\n');
assert(state == BLANK_STATE_N_2, "\\n");
}
void test_failure() {
printf("Testing Failure\n");
enum BLANK_LINE_STATE state = init_blank_line_state();
state = update_blank_line_state(state, '\r');
state = update_blank_line_state(state, 'F');
assert(state == BLANK_STATE_START, "Break at \\n");
state = init_blank_line_state();
state = update_blank_line_state(state, 'F');
assert(state == BLANK_STATE_START, "Break at \\n");
}
int main() {
printf("Starting HTTP Blank Line Parse Tests\n");
test_basic();
test_failure();
}