Skip to content

Commit

Permalink
Replace usage of UnityBegin/UnityEnd with UNITY_BEGIN/UNITY_END
Browse files Browse the repository at this point in the history
See discussion [here](exercism#943 (review))

Done via:
```
for f in $(find . -name "test_*.c"); do
    sed -i '' 's/UnityBegin\(.*\);/UNITY_BEGIN();/' $f
    sed -i '' 's/UnityEnd/UNITY_END/' $f
done
```
  • Loading branch information
ahans committed Jan 28, 2024
1 parent 385e057 commit 92b8f62
Show file tree
Hide file tree
Showing 76 changed files with 152 additions and 152 deletions.
4 changes: 2 additions & 2 deletions bin/check-unitybegin
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ check_exercises () {
for f in "${1}"/*/test_*; do
if [ -f "${f}" ]
then
if ! grep -q UnityBegin\(\""$(basename "$f")"\"\) "$f"; then
echo "$f needs correct UnityBegin line"
if ! grep -q UNITY_BEGIN\(\) "$f"; then
echo "$f needs correct UNITY_BEGIN line"
(( ERROR_COUNT++ ))
fi
else
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/acronym/test_acronym.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void test_underscore_emphasis(void)

int main(void)
{
UnityBegin("test_acronym.c");
UNITY_BEGIN();

RUN_TEST(test_null_string);
RUN_TEST(test_empty_string);
Expand All @@ -126,5 +126,5 @@ int main(void)
RUN_TEST(test_apostrophes);
RUN_TEST(test_underscore_emphasis);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/all-your-base/test_all_your_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void test_both_bases_are_negative(void)

int main(void)
{
UnityBegin("test_all_your_base.c");
UNITY_BEGIN();

RUN_TEST(test_single_bit_to_decimal);
RUN_TEST(test_binary_to_single_decimal);
Expand All @@ -231,5 +231,5 @@ int main(void)
RUN_TEST(test_output_base_is_negative);
RUN_TEST(test_both_bases_are_negative);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/allergies/test_allergies.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static void test_no_allergen_score_parts_without_highest_valid_score(void)

int main(void)
{
UnityBegin("test_allergies.c");
UNITY_BEGIN();

RUN_TEST(test_not_allergic_to_anything_for_eggs);
RUN_TEST(test_allergic_only_to_eggs);
Expand Down Expand Up @@ -459,5 +459,5 @@ int main(void)
RUN_TEST(test_no_allergen_score_parts);
RUN_TEST(test_no_allergen_score_parts_without_highest_valid_score);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/anagram/test_anagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static void test_words_other_than_themselves_can_be_anagrams(void)

int main(void)
{
UnityBegin("test_anagram.c");
UNITY_BEGIN();

RUN_TEST(test_no_matches);
RUN_TEST(test_detect_two_anagrams);
Expand All @@ -294,5 +294,5 @@ int main(void)
test_words_are_not_anagrams_of_themselves_even_if_letter_case_is_completely_different);
RUN_TEST(test_words_other_than_themselves_can_be_anagrams);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/armstrong-numbers/test_armstrong_numbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void test_seven_digit_number_that_is_not_an_armstrong_number(void)

int main(void)
{
UnityBegin("test_armstrong_numbers.c");
UNITY_BEGIN();

RUN_TEST(test_zero_is_an_armstrong_number);
RUN_TEST(test_single_digit_numbers_are_armstrong_numbers);
Expand All @@ -76,5 +76,5 @@ int main(void)
RUN_TEST(test_seven_digit_number_that_is_an_armstrong_number);
RUN_TEST(test_seven_digit_number_that_is_not_an_armstrong_number);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/atbash-cipher/test_atbash_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void test_decode_with_no_spaces(void)

int main(void)
{
UnityBegin("test_atbash_cipher.c");
UNITY_BEGIN();

RUN_TEST(test_encode_yes);
RUN_TEST(test_encode_no);
Expand All @@ -136,5 +136,5 @@ int main(void)
RUN_TEST(test_decode_with_too_many_spaces);
RUN_TEST(test_decode_with_no_spaces);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/beer-song/test_beer_song.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ static void test_all_verses(void)

int main(void)
{
UnityBegin("test_beer_song.c");
UNITY_BEGIN();

RUN_TEST(test_first_generic_verse);
RUN_TEST(test_last_generic_verse);
Expand All @@ -475,5 +475,5 @@ int main(void)
RUN_TEST(test_last_three_verses);
RUN_TEST(test_all_verses);

return UnityEnd();
return UNITY_END();
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void test_sorted_data_can_sort_complex_tree(void)

int main(void)
{
UnityBegin("test_binary_search_tree.c");
UNITY_BEGIN();

RUN_TEST(test_data_data_is_retained);
RUN_TEST(test_data_smaller_number_at_left_node);
Expand All @@ -205,5 +205,5 @@ int main(void)
RUN_TEST(test_sorted_data_can_sort_if_second_number_is_greater_than_first);
RUN_TEST(test_sorted_data_can_sort_complex_tree);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/binary-search/test_binary_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void test_nothing_is_found_when_the_left_and_right_bounds_cross(void)

int main(void)
{
UnityBegin("test_binary_search.c");
UNITY_BEGIN();

RUN_TEST(test_finds_a_value_in_an_array_with_one_element);
RUN_TEST(test_a_value_in_the_middle_of_an_array);
Expand All @@ -113,5 +113,5 @@ int main(void)
RUN_TEST(test_nothing_is_found_in_an_empty_array);
RUN_TEST(test_nothing_is_found_when_the_left_and_right_bounds_cross);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/binary/test_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void test_a_number_and_a_word_whitespace_separated_is_invalid(void)

int main(void)
{
UnityBegin("test_binary.c");
UNITY_BEGIN();

RUN_TEST(test_binary_0_is_decimal_0);
RUN_TEST(test_binary_1_is_decimal_1);
Expand All @@ -118,5 +118,5 @@ int main(void)
RUN_TEST(test_a_number_with_internal_non_binary_characters_is_invalid);
RUN_TEST(test_a_number_and_a_word_whitespace_separated_is_invalid);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/bob/test_bob.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static void test_non_question_ending_with_whitespace(void)

int main(void)
{
UnityBegin("test_bob.c");
UNITY_BEGIN();

RUN_TEST(test_stating_something);
RUN_TEST(test_shouting);
Expand Down Expand Up @@ -201,5 +201,5 @@ int main(void)
RUN_TEST(test_other_whitespace);
RUN_TEST(test_non_question_ending_with_whitespace);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/circular-buffer/test_circular_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static void test_initial_clear_does_not_affect_wrapping(void)

int main(void)
{
UnityBegin("test_circular_buffer.c");
UNITY_BEGIN();

RUN_TEST(test_reading_empty_buffer_fails);
RUN_TEST(test_can_read_item_just_written);
Expand All @@ -278,5 +278,5 @@ int main(void)
RUN_TEST(test_overwrite_replaces_oldest_item_remaining_following_read);
RUN_TEST(test_initial_clear_does_not_affect_wrapping);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/clock/test_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static void test_compare_full_clock_and_zeroed_clock(void)

int main(void)
{
UnityBegin("test_clock.c");
UNITY_BEGIN();

RUN_TEST(test_on_the_hour);
RUN_TEST(test_past_the_hour);
Expand Down Expand Up @@ -592,5 +592,5 @@ int main(void)
RUN_TEST(test_compare_clocks_with_negative_hours_and_minute_that_wrap);
RUN_TEST(test_compare_full_clock_and_zeroed_clock);

return UnityEnd();
return UNITY_END();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void test_negative_value_is_an_error(void)

int main(void)
{
UnityBegin("test_collatz_conjecture.c");
UNITY_BEGIN();

RUN_TEST(test_zero_steps_for_one);
RUN_TEST(test_divide_if_even);
Expand All @@ -50,5 +50,5 @@ int main(void)
RUN_TEST(test_zero_is_an_error);
RUN_TEST(test_negative_value_is_an_error);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/complex-numbers/test_complex_numbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void test_divide_real_number_by_complex_number(void)

int main(void)
{
UnityBegin("test_complex_numbers.c");
UNITY_BEGIN();

RUN_TEST(test_real_part_of_a_purely_real_number);
RUN_TEST(test_real_part_of_a_purely_imaginary_number);
Expand Down Expand Up @@ -544,5 +544,5 @@ int main(void)
RUN_TEST(test_divide_complex_number_by_real_number);
RUN_TEST(test_divide_real_number_by_complex_number);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/crypto-square/test_crypto_square.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test_54_char_plaintext_gives_7_chunks_last_two_with_trailing_spaces(void)

int main(void)
{
UnityBegin("test_crypto_square.c");
UNITY_BEGIN();

RUN_TEST(test_empty_text_res_in_an_empty_ciphertext);
RUN_TEST(test_lowercase);
Expand All @@ -96,5 +96,5 @@ int main(void)
RUN_TEST(
test_54_char_plaintext_gives_7_chunks_last_two_with_trailing_spaces);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/darts/test_darts.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static void test_asymmetric_position_between_the_inner_and_middle_circles(void)

int main(void)
{
UnityBegin("test_darts.c");
UNITY_BEGIN();

RUN_TEST(test_missed_target);
RUN_TEST(test_on_the_outer_circle);
Expand All @@ -143,5 +143,5 @@ int main(void)
RUN_TEST(test_just_outside_the_outer_circle);
RUN_TEST(test_asymmetric_position_between_the_inner_and_middle_circles);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/diamond/test_diamond.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void test_rows_largest_possible_diamond(void)

int main(void)
{
UnityBegin("test_diamond.c");
UNITY_BEGIN();

RUN_TEST(test_rows_degenerate_case_with_a_single_a_row);
RUN_TEST(
Expand All @@ -155,5 +155,5 @@ int main(void)
test_rows_smallest_non_degenerate_case_with_even_diamond_side_length);
RUN_TEST(test_rows_largest_possible_diamond);

return UnityEnd();
return UNITY_END();
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void test_difference_of_squares_100(void)

int main(void)
{
UnityBegin("test_difference_of_squares.c");
UNITY_BEGIN();

RUN_TEST(test_square_of_sum_1);
RUN_TEST(test_square_of_sum_5);
Expand All @@ -76,5 +76,5 @@ int main(void)
RUN_TEST(test_difference_of_squares_5);
RUN_TEST(test_difference_of_squares_100);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/etl/test_etl.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ static void test_multiple_scores_with_differing_numbers_of_letters(void)

int main(void)
{
UnityBegin("test_etl.c");
UNITY_BEGIN();

RUN_TEST(test_a_single_letter);
RUN_TEST(test_single_score_with_multiple_letters);
RUN_TEST(test_multiple_scores_with_multiple_letters);
RUN_TEST(test_multiple_scores_with_differing_numbers_of_letters);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/gigasecond/test_gigasecond.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static void test_your_birthday(void)

int main(void)
{
UnityBegin("test_gigasecond.c");
UNITY_BEGIN();

RUN_TEST(test_date);
RUN_TEST(test_another_date);
Expand All @@ -114,5 +114,5 @@ int main(void)
RUN_TEST(test_date_and_time_with_day_rollover);
// RUN_TEST(test_your_birthday);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/grade-school/test_grade_school.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static void test_students_are_sorted_by_name_in_grade(void)

int main(void)
{
UnityBegin("test_grade_school.c");
UNITY_BEGIN();

RUN_TEST(test_roster_is_empty_when_no_student_added);
RUN_TEST(test_add_student);
Expand All @@ -362,5 +362,5 @@ int main(void)
RUN_TEST(test_student_not_added_to_other_grade_for_multiple_grades);
RUN_TEST(test_students_are_sorted_by_name_in_grade);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/grains/test_grains.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void test_total(void)

int main(void)
{
UnityBegin("test_grains.c");
UNITY_BEGIN();

RUN_TEST(test_square_1);
RUN_TEST(test_square_2);
Expand All @@ -83,5 +83,5 @@ int main(void)
RUN_TEST(test_square_greater_than_64_does_not_exist);
RUN_TEST(test_total);

return UnityEnd();
return UNITY_END();
}
4 changes: 2 additions & 2 deletions exercises/practice/hamming/test_hamming.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void test_disallow_empty_second_strand(void)

int main(void)
{
UnityBegin("test_hamming.c");
UNITY_BEGIN();

RUN_TEST(test_empty_strands);
RUN_TEST(test_single_identical_strands);
Expand All @@ -76,5 +76,5 @@ int main(void)
RUN_TEST(test_disallow_empty_first_strand);
RUN_TEST(test_disallow_empty_second_strand);

return UnityEnd();
return UNITY_END();
}
Loading

0 comments on commit 92b8f62

Please sign in to comment.