-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
153 lines (133 loc) · 4.3 KB
/
test.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Note... this isn't a very exhaustive test suite... however, I only needed to fix these edge cases, and the system
* appeared to operate normally. Feel free to leave a git issue, or submit a PR highlighting a case that fails...
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include "avr-scheduler.h"
int main(int argc, char *argv[]) {
schedule_t *s = new_schedule();
// Put stuff in a schedule, and set the ID's to be the order that you expect. The first one will be 1, second 2, etc...
schedule_insert(s, 10, 100, 1);
schedule_insert(s, 20, 110, 2);
schedule_insert(s, 30, 120, 3);
schedule_insert(s, 40, 130, 4);
schedule_test_backwards(s); // This will check the order
schedule_test_forwards(s);
schedule_clear(s); //Clear the schedule after every test
schedule_insert(s, 100, 50, 1);
schedule_insert(s, 100, 150, 2);
schedule_insert(s, 100, 59850, 3);
schedule_insert(s, 100, 59950, 4);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 100, 59850, 1);
schedule_insert(s, 100, 59950, 2);
schedule_insert(s, 100, 50, 3);
schedule_insert(s, 100, 150, 4);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 100, 59850, 1);
schedule_insert(s, 100, 50, 2);
schedule_insert(s, 100, 150, 3);
schedule_insert(s, 100, 150, 4);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 100, 59850, 3);
schedule_insert(s, 50, 59850, 2);
schedule_insert(s, 20, 59850, 1);
schedule_insert(s, 100, 50, 4);
schedule_insert(s, 100, 150, 5);
schedule_insert(s, 100, 150, 6);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 100, 59950, 3);
schedule_insert(s, 50, 59950, 2);
schedule_insert(s, 20, 59950, 1);
schedule_insert(s, 100, 50, 4);
schedule_insert(s, 100, 150, 5);
schedule_insert(s, 100, 150, 6);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 20, 59850, 1);
schedule_insert(s, 50, 59850, 2);
schedule_insert(s, 100, 59850, 3);
schedule_insert(s, 100, 50, 4);
schedule_insert(s, 100, 150, 5);
schedule_insert(s, 100, 150, 6);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 20, 59950, 1);
schedule_insert(s, 50, 59950, 2);
schedule_insert(s, 100, 59950, 3);
schedule_insert(s, 100, 50, 4);
schedule_insert(s, 100, 150, 5);
schedule_insert(s, 100, 150, 6);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 150, 59950, 3); //100
schedule_insert(s, 50, 59960, 1); //10
schedule_insert(s, 100, 59970, 2); //70
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 150, 59950, 5); //100
schedule_insert(s, 50, 59960, 1); //10
schedule_insert(s, 100, 59970, 3); //70
schedule_insert(s, 60, 30, 4); //90
schedule_insert(s, 10, 50, 2); //60
schedule_insert(s, 100, 150, 6); //250
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 20, 59850, 0);
schedule_insert(s, 50, 59850, 0);
schedule_insert(s, 100, 59850, 1);
schedule_insert(s, 100, 50, 2);
schedule_insert(s, 100, 150, 3);
schedule_insert(s, 100, 150, 4);
schedule_pop(s);
schedule_pop(s);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 20, 59950, 0);
schedule_insert(s, 50, 59950, 0);
schedule_insert(s, 100, 59950, 1);
schedule_insert(s, 100, 50, 2);
schedule_insert(s, 100, 150, 3);
schedule_insert(s, 100, 150, 4);
schedule_pop(s);
schedule_pop(s);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 150, 59950, 1); //100
schedule_insert(s, 50, 59960, 0); //10
schedule_insert(s, 100, 59970, 0); //70
schedule_pop(s);
schedule_pop(s);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
schedule_insert(s, 150, 59950, 3); //100
schedule_insert(s, 50, 59960, 0); //10
schedule_insert(s, 100, 59970, 1); //70
schedule_insert(s, 60, 30, 2); //90
schedule_insert(s, 10, 50, 0); //60
schedule_insert(s, 100, 150, 4); //250
schedule_pop(s);
schedule_pop(s);
schedule_test_backwards(s);
schedule_test_forwards(s);
schedule_clear(s);
}