Skip to content

Commit 9a2ed79

Browse files
Update test_soap.c
1 parent 4e6580e commit 9a2ed79

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

code/tests/cases/test_soap.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,64 @@ FOSSIL_TEST(c_test_io_soap_suggest_with_tabs) {
215215
free(result);
216216
}
217217

218+
FOSSIL_TEST(c_test_io_soap_detect_bias_political) {
219+
const char *input = "All liberals are wrong.";
220+
const char *expected = "political-bias";
221+
const char *result = fossil_io_soap_detect_bias(input);
222+
ASSUME_ITS_EQUAL_CSTR(expected, result);
223+
}
224+
225+
FOSSIL_TEST(c_test_io_soap_detect_bias_noneutral) {
226+
const char *input = "Dogs are better than cats.";
227+
const char *expected = "subjective-bias";
228+
const char *result = fossil_io_soap_detect_bias(input);
229+
ASSUME_ITS_EQUAL_CSTR(expected, result);
230+
}
231+
232+
FOSSIL_TEST(c_test_io_soap_detect_fake_news_true_case) {
233+
const char *input = "NASA confirms moon is made of cheese.";
234+
const char *expected = "fake";
235+
const char *result = fossil_io_soap_detect_fake_news(input);
236+
ASSUME_ITS_EQUAL_CSTR(expected, result);
237+
}
238+
239+
FOSSIL_TEST(c_test_io_soap_detect_fake_news_valid_fact) {
240+
const char *input = "The Earth revolves around the Sun.";
241+
const char *expected = "valid";
242+
const char *result = fossil_io_soap_detect_fake_news(input);
243+
ASSUME_ITS_EQUAL_CSTR(expected, result);
244+
}
245+
246+
FOSSIL_TEST(c_test_io_soap_correct_grammar_typo) {
247+
const char *input = "He go to school every day.";
248+
const char *expected = "He goes to school every day.";
249+
char *result = fossil_io_soap_correct_grammar(input);
250+
ASSUME_ITS_EQUAL_CSTR(expected, result);
251+
free(result);
252+
}
253+
254+
FOSSIL_TEST(c_test_io_soap_correct_grammar_punctuation) {
255+
const char *input = "hello how are you";
256+
const char *expected = "Hello, how are you?";
257+
char *result = fossil_io_soap_correct_grammar(input);
258+
ASSUME_ITS_EQUAL_CSTR(expected, result);
259+
free(result);
260+
}
261+
262+
FOSSIL_TEST(c_test_io_soap_fuzzy_match_simple) {
263+
const char *a = "rotbrain";
264+
const char *b = "rot-brain";
265+
bool result = fossil_io_soap_fuzzy_match(a, b);
266+
ASSUME_ITS_TRUE(result);
267+
}
268+
269+
FOSSIL_TEST(c_test_io_soap_fuzzy_match_fail) {
270+
const char *a = "hello";
271+
const char *b = "goodbye";
272+
bool result = fossil_io_soap_fuzzy_match(a, b);
273+
ASSUME_ITS_TRUE(!result);
274+
}
275+
218276
// * * * * * * * * * * * * * * * * * * * * * * * *
219277
// * Fossil Logic Test Pool
220278
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -242,6 +300,14 @@ FOSSIL_TEST_GROUP(c_soap_tests) {
242300
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_special_chars);
243301
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_newlines);
244302
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_tabs);
303+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_bias_political);
304+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_bias_noneutral);
305+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_fake_news_true_case);
306+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_fake_news_valid_fact);
307+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_correct_grammar_typo);
308+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_correct_grammar_punctuation);
309+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_fuzzy_match_simple);
310+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_fuzzy_match_fail);
245311

246312
FOSSIL_TEST_REGISTER(c_soap_suite);
247313
}

0 commit comments

Comments
 (0)