-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestGramBT.c
95 lines (88 loc) · 2.16 KB
/
testGramBT.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "wordCounter.h"
int main() {
GramBT *gram=NULL;
if (lookupWordBT(gram, "ala") == NULL) {
printf("OK\n");
} else {
printf("not ok\n");
}
GramBT **gram_added = malloc(sizeof(GramBT*));
GramBT **gramm1_added = malloc(sizeof(GramBT*));
gram = addWordBT(gram, "B", gram_added);
if ((gram != NULL) &&
(strcmp(gram->word, "B") == 0) &&
(gram->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
(*gram_added)->next = addWordBT((*gram_added)->next, "BA", gramm1_added);
gram = addWordBT(gram, "BA", gram_added);
if ((gram != NULL) &&
(strcmp(gram->word, "B") == 0) &&
(gram->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
GramBT *grama = lookupWordBT(gram, "B");
if ((grama != NULL) &&
(strcmp(grama->word, "B") == 0) &&
(grama->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
if ((grama->r != NULL) &&
(strcmp(grama->r->word, "BA") == 0) &&
(grama->r->count == 1))
{
printf("OK\n");
} else {
printf("not ok\n");
}
if ((grama->next != NULL) &&
(strcmp(grama->next->word, "BA") == 0) &&
(grama->next->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
if ((grama != NULL) &&
(strcmp(grama->word, "B") == 0) &&
(grama->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
gram = addWordBT(gram, "AB", gram_added);
gram = addWordBT(gram, "AB", gram_added);
if ((gram != NULL) &&
(strcmp(gram->word, "B") == 0) &&
(gram->count == 1)) {
printf("OK\n");
} else {
printf("not ok\n");
}
if ((gram->l != NULL) &&
(strcmp(gram->l->word, "AB") == 0) &&
(gram->l->count == 2))
{
printf("OK\n");
} else {
printf("not ok\n");
}
/* Gram *gramaa = lookupWord(table, "AA"); */
/* 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); */
}