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
6668FOSSIL_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
7274FOSSIL_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