Skip to content

Commit c48ab1f

Browse files
update test cases and add new test cases
1 parent 3598e3f commit c48ab1f

File tree

2 files changed

+225
-18
lines changed

2 files changed

+225
-18
lines changed

code/tests/cases/test_soap.c

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,93 @@ FOSSIL_TEST_CASE(c_test_soap_count_offensive) {
6464
}
6565

6666
FOSSIL_TEST_CASE(c_test_soap_is_rotbrain) {
67-
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("meme_speak1"));
68-
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("meme_speak2"));
69-
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("normal_word"));
67+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("lol"));
68+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("brb"));
69+
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("hello"));
7070
}
7171

7272
FOSSIL_TEST_CASE(c_test_soap_count_rotbrain) {
73-
char input[] = "This is a test with meme_speak1 and meme_speak2";
73+
char input[] = "This is a test with lol and brb";
7474
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
7575
}
7676

77-
FOSSIL_TEST_CASE(c_test_soap_correct_grammar) {
78-
char input[] = "this is a sentence with extra spaces.";
79-
char expected[] = "This is a sentence with extra spaces.";
77+
FOSSIL_TEST_CASE(c_test_soap_sanitize_multiple_offensive) {
78+
char input[] = "curse1 curse2 racist_phrase1 racist_phrase2";
79+
char expected[] = "*** *** *** ***";
8080

81-
fossil_soap_correct_grammar(input);
81+
fossil_soap_sanitize(input);
82+
83+
ASSUME_ITS_EQUAL_CSTR(expected, input);
84+
}
85+
86+
FOSSIL_TEST_CASE(c_test_soap_sanitize_no_offensive) {
87+
char input[] = "This is a clean sentence.";
88+
char expected[] = "This is a clean sentence.";
89+
90+
fossil_soap_sanitize(input);
91+
92+
ASSUME_ITS_EQUAL_CSTR(expected, input);
93+
}
94+
95+
FOSSIL_TEST_CASE(c_test_soap_is_offensive_case_insensitive) {
96+
ASSUME_ITS_TRUE(fossil_soap_is_offensive("CuRsE1"));
97+
ASSUME_ITS_TRUE(fossil_soap_is_offensive("RaCiSt_PhrAsE2"));
98+
ASSUME_ITS_FALSE(fossil_soap_is_offensive("Non_Offensive_Word"));
99+
}
100+
101+
FOSSIL_TEST_CASE(c_test_soap_count_offensive_mixed_case) {
102+
char input[] = "This is a test with CuRsE1 and RaCiSt_PhrAsE1";
103+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_offensive(input));
104+
}
105+
106+
FOSSIL_TEST_CASE(c_test_soap_is_rotbrain_case_insensitive) {
107+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("LoL"));
108+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("BrB"));
109+
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("Hello"));
110+
}
111+
112+
FOSSIL_TEST_CASE(c_test_soap_count_rotbrain_mixed_case) {
113+
char input[] = "This is a test with LoL and BrB";
114+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
115+
}
116+
117+
FOSSIL_TEST_CASE(c_test_soap_sanitize_synonyms) {
118+
char input[] = "This is a test with rizz and sus.";
119+
char expected[] = "This is a test with *** and ***.";
120+
121+
fossil_soap_sanitize(input);
82122

83123
ASSUME_ITS_EQUAL_CSTR(expected, input);
84124
}
85125

126+
FOSSIL_TEST_CASE(c_test_soap_sanitize_with_punctuation) {
127+
char input[] = "This is a test with curse1, and racist_phrase1!";
128+
char expected[] = "This is a test with ***, and ***!";
129+
130+
fossil_soap_sanitize(input);
131+
132+
ASSUME_ITS_EQUAL_CSTR(expected, input);
133+
}
134+
135+
FOSSIL_TEST_CASE(c_test_soap_count_offensive_with_punctuation) {
136+
char input[] = "This is a test with curse1, and racist_phrase1!";
137+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_offensive(input));
138+
}
139+
140+
FOSSIL_TEST_CASE(c_test_soap_sanitize_rotbrain_with_punctuation) {
141+
char input[] = "This is a test with lol, and brb!";
142+
char expected[] = "This is a test with ***, and ***!";
143+
144+
fossil_soap_sanitize(input);
145+
146+
ASSUME_ITS_EQUAL_CSTR(expected, input);
147+
}
148+
149+
FOSSIL_TEST_CASE(c_test_soap_count_rotbrain_with_punctuation) {
150+
char input[] = "This is a test with lol, and brb!";
151+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
152+
}
153+
86154
// * * * * * * * * * * * * * * * * * * * * * * * *
87155
// * Fossil Logic Test Pool
88156
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -93,7 +161,17 @@ FOSSIL_TEST_GROUP(c_soap_tests) {
93161
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_offensive);
94162
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_is_rotbrain);
95163
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_rotbrain);
96-
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_correct_grammar);
164+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_sanitize_multiple_offensive);
165+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_sanitize_no_offensive);
166+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_is_offensive_case_insensitive);
167+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_offensive_mixed_case);
168+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_is_rotbrain_case_insensitive);
169+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_rotbrain_mixed_case);
170+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_sanitize_synonyms);
171+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_sanitize_with_punctuation);
172+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_offensive_with_punctuation);
173+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_sanitize_rotbrain_with_punctuation);
174+
FOSSIL_TEST_ADD(c_soap_suite, c_test_soap_count_rotbrain_with_punctuation);
97175

98176
FOSSIL_TEST_REGISTER(c_soap_suite);
99177
}

code/tests/cases/test_soap.cpp

Lines changed: 138 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "fossil/io/framework.h"
1717

18+
using namespace fossil::io;
19+
1820
// * * * * * * * * * * * * * * * * * * * * * * * *
1921
// * Fossil Logic Test Utilites
2022
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -64,25 +66,135 @@ FOSSIL_TEST_CASE(cpp_test_soap_count_offensive) {
6466
}
6567

6668
FOSSIL_TEST_CASE(cpp_test_soap_is_rotbrain) {
67-
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("meme_speak1"));
68-
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("meme_speak2"));
69-
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("normal_word"));
69+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("lol"));
70+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("brb"));
71+
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("hello"));
7072
}
7173

7274
FOSSIL_TEST_CASE(cpp_test_soap_count_rotbrain) {
73-
char input[] = "This is a test with meme_speak1 and meme_speak2";
75+
char input[] = "This is a test with lol and brb";
7476
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
7577
}
7678

77-
FOSSIL_TEST_CASE(cpp_test_soap_correct_grammar) {
78-
char input[] = "this is a sentence with extra spaces.";
79-
char expected[] = "This is a sentence with extra spaces.";
79+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_multiple_offensive) {
80+
char input[] = "curse1 curse2 racist_phrase1 racist_phrase2";
81+
char expected[] = "*** *** *** ***";
82+
83+
fossil_soap_sanitize(input);
84+
85+
ASSUME_ITS_EQUAL_CSTR(expected, input);
86+
}
87+
88+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_no_offensive) {
89+
char input[] = "This is a clean sentence.";
90+
char expected[] = "This is a clean sentence.";
8091

81-
fossil_soap_correct_grammar(input);
92+
fossil_soap_sanitize(input);
8293

8394
ASSUME_ITS_EQUAL_CSTR(expected, input);
8495
}
8596

97+
FOSSIL_TEST_CASE(cpp_test_soap_is_offensive_case_insensitive) {
98+
ASSUME_ITS_TRUE(fossil_soap_is_offensive("CuRsE1"));
99+
ASSUME_ITS_TRUE(fossil_soap_is_offensive("RaCiSt_PhrAsE2"));
100+
ASSUME_ITS_FALSE(fossil_soap_is_offensive("Non_Offensive_Word"));
101+
}
102+
103+
FOSSIL_TEST_CASE(cpp_test_soap_count_offensive_mixed_case) {
104+
char input[] = "This is a test with CuRsE1 and RaCiSt_PhrAsE1";
105+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_offensive(input));
106+
}
107+
108+
FOSSIL_TEST_CASE(cpp_test_soap_is_rotbrain_case_insensitive) {
109+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("LoL"));
110+
ASSUME_ITS_TRUE(fossil_soap_is_rotbrain("BrB"));
111+
ASSUME_ITS_FALSE(fossil_soap_is_rotbrain("Hello"));
112+
}
113+
114+
FOSSIL_TEST_CASE(cpp_test_soap_count_rotbrain_mixed_case) {
115+
char input[] = "This is a test with LoL and BrB";
116+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
117+
}
118+
119+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_synonyms) {
120+
char input[] = "This is a test with rizz and sus.";
121+
char expected[] = "This is a test with *** and ***.";
122+
123+
fossil_soap_sanitize(input);
124+
125+
ASSUME_ITS_EQUAL_CSTR(expected, input);
126+
}
127+
128+
FOSSIL_TEST_CASE(cpp_test_soap_count_rotbrain_with_punctuation) {
129+
char input[] = "This is a test with lol, and brb!";
130+
ASSUME_ITS_EQUAL_I32(2, fossil_soap_count_rotbrain(input));
131+
}
132+
133+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_empty_string) {
134+
char input[] = "";
135+
char expected[] = "";
136+
137+
fossil::io::Soap::sanitize(input);
138+
139+
ASSUME_ITS_EQUAL_CSTR(expected, input);
140+
}
141+
142+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_only_offensive) {
143+
char input[] = "curse1";
144+
char expected[] = "***";
145+
146+
fossil::io::Soap::sanitize(input);
147+
148+
ASSUME_ITS_EQUAL_CSTR(expected, input);
149+
}
150+
151+
FOSSIL_TEST_CASE(cpp_test_soap_is_offensive_empty_string) {
152+
ASSUME_ITS_FALSE(fossil::io::Soap::is_offensive(""));
153+
}
154+
155+
FOSSIL_TEST_CASE(cpp_test_soap_is_rotbrain_empty_string) {
156+
ASSUME_ITS_FALSE(fossil::io::Soap::is_rotbrain(""));
157+
}
158+
159+
FOSSIL_TEST_CASE(cpp_test_soap_count_offensive_empty_string) {
160+
char input[] = "";
161+
ASSUME_ITS_EQUAL_I32(0, fossil::io::Soap::count_offensive(input));
162+
}
163+
164+
FOSSIL_TEST_CASE(cpp_test_soap_count_rotbrain_empty_string) {
165+
char input[] = "";
166+
ASSUME_ITS_EQUAL_I32(0, fossil::io::Soap::count_rotbrain(input));
167+
}
168+
169+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_mixed_content) {
170+
char input[] = "This is a test with curse1, lol, and non_offensive_word.";
171+
char expected[] = "This is a test with ***, ***, and non_offensive_word.";
172+
173+
fossil::io::Soap::sanitize(input);
174+
175+
ASSUME_ITS_EQUAL_CSTR(expected, input);
176+
}
177+
178+
FOSSIL_TEST_CASE(cpp_test_soap_count_offensive_mixed_content) {
179+
char input[] = "This is a test with curse1, curse2, and non_offensive_word.";
180+
ASSUME_ITS_EQUAL_I32(2, fossil::io::Soap::count_offensive(input));
181+
}
182+
183+
FOSSIL_TEST_CASE(cpp_test_soap_count_rotbrain_mixed_content) {
184+
char input[] = "This is a test with lol, brb, and non_offensive_word.";
185+
ASSUME_ITS_EQUAL_I32(2, fossil::io::Soap::count_rotbrain(input));
186+
}
187+
188+
FOSSIL_TEST_CASE(cpp_test_soap_sanitize_with_punctuation) {
189+
char input[] = "curse1! curse2? racist_phrase1.";
190+
char expected[] = "***! ***? ***.";
191+
192+
fossil::io::Soap::sanitize(input);
193+
194+
ASSUME_ITS_EQUAL_CSTR(expected, input);
195+
}
196+
197+
86198
// * * * * * * * * * * * * * * * * * * * * * * * *
87199
// * Fossil Logic Test Pool
88200
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -93,7 +205,24 @@ FOSSIL_TEST_GROUP(cpp_soap_tests) {
93205
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_offensive);
94206
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_is_rotbrain);
95207
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_rotbrain);
96-
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_correct_grammar);
208+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_multiple_offensive);
209+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_no_offensive);
210+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_is_offensive_case_insensitive);
211+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_offensive_mixed_case);
212+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_is_rotbrain_case_insensitive);
213+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_rotbrain_mixed_case);
214+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_synonyms);
215+
216+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_empty_string);
217+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_only_offensive);
218+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_is_offensive_empty_string);
219+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_is_rotbrain_empty_string);
220+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_offensive_empty_string);
221+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_rotbrain_empty_string);
222+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_mixed_content);
223+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_offensive_mixed_content);
224+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_count_rotbrain_mixed_content);
225+
FOSSIL_TEST_ADD(cpp_soap_suite, cpp_test_soap_sanitize_with_punctuation);
97226

98227
FOSSIL_TEST_REGISTER(cpp_soap_suite);
99228
}

0 commit comments

Comments
 (0)