-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (29 loc) · 897 Bytes
/
main.cpp
File metadata and controls
36 lines (29 loc) · 897 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
#include "GibberishDetector.h"
#include <assert.h>
struct TestCase {
const char *str;
bool expected_result;
};
TestCase testCases[] = {
{ "Hello World", false },
{ "Test", false },
{ "Hello", false },
{ "yes", false },
{ "FunctionName", false },
{ "aSasdffffwHGsd", true },
{ "hgfRTFs", true },
{ "bcv3Hgf", true },
};
#define NUM_CASES (sizeof(testCases) / sizeof(testCases[0]))
const char accepted_chars[] = "abcdefghijklmnopqrstuvwxyz ";
int main(int argc, char *argv[])
{
GibberishDetector detector;
detector.init(accepted_chars);
for (int i = 0; i < NUM_CASES; ++i) {
bool is_gib = detector.is_gibberish(testCases[i].str);
printf("Testing [%s]: %s\n", testCases[i].str, is_gib ? "GIBBERISH" : "English");
assert(is_gib == testCases[i].expected_result);
}
return 0;
}