@@ -31,9 +31,11 @@ void test_dstring2()
31
31
Bytes str ;
32
32
bytes_malloc (& str );
33
33
char fake [2 ];
34
+ char c ;
35
+ int i ;
34
36
fake [1 ] = '\0' ;
35
- for (char c = 'a' ; c <= 'z' ; c += 1 ) {
36
- for (int i = 0 ; i < 1024 ; i ++ ) {
37
+ for (c = 'a' ; c <= 'z' ; c += 1 ) {
38
+ for (i = 0 ; i < 1024 ; i ++ ) {
37
39
fake [0 ] = c ;
38
40
bytes_append (& str , fake );
39
41
}
@@ -42,8 +44,8 @@ void test_dstring2()
42
44
CHECK_EQUAL (bytes_size (str ), 32 * 1024 );
43
45
CHECK_EQUAL (bytes_ref (str , bytes_length (str )),
44
46
'\0' );
45
- for (char c = 'a' ; c <= 'z' ; c += 1 ) {
46
- for (int i = 0 ; i < 1024 ; i ++ ) {
47
+ for (c = 'a' ; c <= 'z' ; c += 1 ) {
48
+ for (i = 0 ; i < 1024 ; i ++ ) {
47
49
int idx = (c - 'a' );
48
50
idx *= 1024 ;
49
51
idx += i ;
@@ -74,7 +76,8 @@ void test_parse_uri()
74
76
75
77
void print_cache (lru_cache_t * pcache )
76
78
{
77
- for (lru_cache_node_t * p = pcache -> sentinel -> next ;
79
+ lru_cache_node_t * p ;
80
+ for (p = pcache -> sentinel -> next ;
78
81
p != pcache -> sentinel ; p = p -> next ) {
79
82
printf ("%c " , p -> value [0 ]);
80
83
}
@@ -88,19 +91,25 @@ void test_cache()
88
91
lru_cache_init (& cache , 16 );
89
92
90
93
char str [2 ];
91
- for (char c = 'a' ; c < 'a' + 16 ; c += 1 ) {
94
+ char c ;
95
+ for (c = 'a' ; c < 'a' + 16 ; c += 1 ) {
92
96
str [0 ] = c ;
93
97
str [1 ] = '\0' ;
94
98
lru_cache_insert (& cache , str , str , 1 );
99
+ CHECK_EQUAL (cache .cache_size , c - 'a' + 1 );
100
+ CHECK_EQUAL (cache .sentinel -> next -> value [0 ],
101
+ str [0 ]);
95
102
}
96
103
print_cache (& cache );
97
104
// printf("%zu\n", cache.cache_size);
98
105
CHECK_EQUAL (cache .cache_size , 16 );
99
- str [0 ] = 'a' + 16 ;
100
- lru_cache_insert (& cache , str , str , 1 );
101
- CHECK_EQUAL (cache .cache_size , 16 );
102
- CHECK_EQUAL (cache .sentinel -> next -> value [0 ],
103
- 'a' + 16 );
106
+ for (c = 'a' + 16 ; c < 'a' + 26 ; c += 1 ) {
107
+ str [0 ] = c ;
108
+ lru_cache_insert (& cache , str , str , 1 );
109
+ CHECK_EQUAL (cache .cache_size , 16 );
110
+ CHECK_EQUAL (cache .sentinel -> next -> value [0 ],
111
+ str [0 ]);
112
+ }
104
113
print_cache (& cache );
105
114
lru_cache_free (& cache );
106
115
}
0 commit comments