-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestGram.c
More file actions
43 lines (39 loc) · 878 Bytes
/
testGram.c
File metadata and controls
43 lines (39 loc) · 878 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
38
39
40
41
42
43
#include <stdio.h>
#include <string.h>
#include "wordCounter.h"
int main() {
Gram *table[HASH_SIZE];
initHashTable(table);
Gram *entry0 = table[0];
if (entry0 == NULL) {
printf("OK\n");
} else {
printf("not ok\n");
}
if (lookupWord(table, "ala") == NULL) {
printf("OK\n");
} else {
printf("not ok\n");
}
addWord(table, "A");
addWord(table, "A");
addWord(table, "AA");
Gram *grama = lookupWord(table, "A");
Gram *gramaa = lookupWord(table, "AA");
if ((grama != NULL) &&
(strcmp(grama->word, "A") == 0) &&
(grama->count == 2)) {
printf("OK\n");
} else {
printf("not ok\n");
}
if ((gramaa != NULL) &&
(strcmp(gramaa->word, "AA") == 0) &&
(gramaa->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
Gram *gramMax = findMax(table)[0];
printf("%s\n", gramMax->word);
}