Skip to content

Commit

Permalink
Include two more tests for bolding
Browse files Browse the repository at this point in the history
  • Loading branch information
btrkeks committed Sep 19, 2024
1 parent 6d8b194 commit fcefbc9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/utils_tests/enclose_word_in_string_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ AfterEach(enclose_word_in_string) {
}

Ensure(enclose_word_in_string, handles_all_null_input) {
_drop_(frees8) s8 bolded = enclose_word_in_s8_with(fromcstr_(0), fromcstr_(0), fromcstr_(0), fromcstr_(0));
_drop_(frees8) s8 bolded =
enclose_word_in_s8_with(fromcstr_(0), fromcstr_(0), fromcstr_(0), fromcstr_(0));

assert_that(bolded.s, is_equal_to_string(0));
}
Expand Down Expand Up @@ -41,11 +42,35 @@ Ensure(enclose_word_in_string, properly_encloses_string_with_four_occurences) {
"相手の<b>態度</b>で、こちらの<b>態度</b>を変える。"));
}

Ensure(enclose_word_in_string, properly_encloses_at_end) {
const s8 sentence = S("事前に昏倒させられたのではない。ただ、一つ解せないことがあって");
const s8 word = S("解せないことがあって");

_drop_(frees8) s8 bolded = enclose_word_in_s8_with(sentence, word, S("<b>"), S("</b>"));

assert_that(bolded.s,
is_equal_to_string(
"事前に昏倒させられたのではない。ただ、一つ<b>解せないことがあって</b>"));
}

Ensure(enclose_word_in_string, properly_encloses_at_start) {
const s8 sentence = S("事前に昏倒させられたのではない。ただ、一つ解せないことがあって");
const s8 word = S("事前");

_drop_(frees8) s8 bolded = enclose_word_in_s8_with(sentence, word, S("<b>"), S("</b>"));

assert_that(bolded.s,
is_equal_to_string(
"<b>事前</b>に昏倒させられたのではない。ただ、一つ解せないことがあって"));
}

TestSuite *s8_tests(void) {
TestSuite *suite = create_test_suite();
add_test_with_context(suite, enclose_word_in_string, properly_encloses_string_with_one_occurence);
add_test_with_context(suite, enclose_word_in_string, properly_encloses_string_with_four_occurences);
add_test_with_context(suite, enclose_word_in_string, handles_all_null_input);
add_test_with_context(suite, enclose_word_in_string, handles_null_sentence_rest_non_null);
add_test_with_context(suite, enclose_word_in_string, properly_encloses_at_end);
add_test_with_context(suite, enclose_word_in_string, properly_encloses_at_start);
return suite;
}

0 comments on commit fcefbc9

Please sign in to comment.