Skip to content

Commit 147184d

Browse files
Update test_soap.c
1 parent 13d1cd1 commit 147184d

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

code/tests/cases/test_soap.c

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

218+
FOSSIL_TEST(c_test_io_soap_detect_sentiment_positive) {
219+
const char *input = "I love this product!";
220+
const char *expected = "positive";
221+
const char *result = fossil_io_soap_detect_sentiment(input);
222+
ASSUME_ITS_EQUAL_CSTR(expected, result);
223+
}
224+
225+
FOSSIL_TEST(c_test_io_soap_detect_sentiment_negative) {
226+
const char *input = "This is the worst idea ever.";
227+
const char *expected = "negative";
228+
const char *result = fossil_io_soap_detect_sentiment(input);
229+
ASSUME_ITS_EQUAL_CSTR(expected, result);
230+
}
231+
232+
FOSSIL_TEST(c_test_io_soap_detect_sentiment_neutral) {
233+
const char *input = "It is a pencil.";
234+
const char *expected = "neutral";
235+
const char *result = fossil_io_soap_detect_sentiment(input);
236+
ASSUME_ITS_EQUAL_CSTR(expected, result);
237+
}
238+
239+
FOSSIL_TEST(c_test_io_soap_detect_harmful_content) {
240+
const char *input = "You are worthless.";
241+
int result = fossil_io_soap_detect_harmful_content(input);
242+
ASSUME_ITS_EQUAL_I32(1, result);
243+
}
244+
245+
FOSSIL_TEST(c_test_io_soap_normalize_slang) {
246+
const char *input = "brb, ttyl!";
247+
const char *expected = "be right back, talk to you later!";
248+
char *result = fossil_io_soap_normalize_slang(input);
249+
ASSUME_ITS_EQUAL_CSTR(expected, result);
250+
free(result);
251+
}
252+
253+
FOSSIL_TEST(c_test_io_soap_correct_grammar) {
254+
const char *input = "should of gone there";
255+
const char *expected = "should have gone there";
256+
char *result = fossil_io_soap_correct_grammar(input);
257+
ASSUME_ITS_EQUAL_CSTR(expected, result);
258+
free(result);
259+
}
260+
261+
FOSSIL_TEST(c_test_io_soap_filter_offensive) {
262+
const char *input = "You are such an idiot.";
263+
const char *expected = "You are such an ***.";
264+
char *result = fossil_io_soap_filter_offensive(input);
265+
ASSUME_ITS_EQUAL_CSTR(expected, result);
266+
free(result);
267+
}
268+
269+
FOSSIL_TEST(c_test_io_soap_detect_clickbait) {
270+
const char *input = "You won't believe what happened next!";
271+
int result = fossil_io_soap_detect_clickbait(input);
272+
ASSUME_ITS_EQUAL_I32(1, result);
273+
}
274+
275+
FOSSIL_TEST(c_test_io_soap_detect_exaggeration) {
276+
const char *input = "This is the greatest thing in the entire universe!";
277+
int result = fossil_io_soap_detect_exaggeration(input);
278+
ASSUME_ITS_EQUAL_I32(1, result);
279+
}
280+
281+
FOSSIL_TEST(c_test_io_soap_detect_fallacy) {
282+
const char *input = "If we allow A, then B, C, and D will also happen!";
283+
const char *expected = "slippery slope"; // assuming this is detected
284+
const char *result = fossil_io_soap_detect_fallacy(input);
285+
ASSUME_ITS_EQUAL_CSTR(expected, result);
286+
}
287+
288+
FOSSIL_TEST(c_test_io_soap_summarize) {
289+
const char *input = "Although the product has some flaws, it is still worth buying because of its affordability.";
290+
const char *expected = "It's affordable despite some flaws."; // approximate
291+
char *result = fossil_io_soap_summarize(input);
292+
ASSUME(result != NULL); // Exact match may vary
293+
free(result);
294+
}
295+
296+
FOSSIL_TEST(c_test_io_soap_readability_score) {
297+
const char *input = "This sentence is simple.";
298+
float score = fossil_io_soap_evaluate_readability(input);
299+
ASSUME(score > 60.0); // basic readability check
300+
}
301+
302+
FOSSIL_TEST(c_test_io_soap_politeness_score_polite) {
303+
const char *input = "Could you please help me with this?";
304+
float score = fossil_io_soap_politeness_score(input);
305+
ASSUME(score > 0.8f);
306+
}
307+
308+
FOSSIL_TEST(c_test_io_soap_politeness_score_rude) {
309+
const char *input = "Do it now.";
310+
float score = fossil_io_soap_politeness_score(input);
311+
ASSUME(score < 0.3f);
312+
}
313+
218314
// * * * * * * * * * * * * * * * * * * * * * * * *
219315
// * Fossil Logic Test Pool
220316
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -242,6 +338,20 @@ FOSSIL_TEST_GROUP(c_soap_tests) {
242338
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_special_chars);
243339
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_newlines);
244340
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_suggest_with_tabs);
341+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_sentiment_positive);
342+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_sentiment_negative);
343+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_sentiment_neutral);
344+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_harmful_content);
345+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_normalize_slang);
346+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_correct_grammar);
347+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_filter_offensive);
348+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_clickbait);
349+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_exaggeration);
350+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_detect_fallacy);
351+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_summarize);
352+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_readability_score);
353+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_politeness_score_polite);
354+
FOSSIL_TEST_ADD(c_soap_suite, c_test_io_soap_politeness_score_rude);
245355

246356
FOSSIL_TEST_REGISTER(c_soap_suite);
247357
}

0 commit comments

Comments
 (0)