Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_diamond.c #1017

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions exercises/practice/diamond/test_diamond.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

void setUp(void)
{
}

void tearDown(void)
{
}
void setUp(void) {}
void tearDown(void) {}

static void test_rows_degenerate_case_with_a_single_a_row(void)
{
Expand All @@ -21,57 +16,45 @@ static void test_rows_degenerate_case_with_a_single_a_row(void)
free_diamond(diamond);
}

static void
test_rows_degenerate_case_with_no_row_with_3_distinct_groups_of_spaces(void)
static void test_rows_degenerate_case_with_no_row_with_3_distinct_groups_of_spaces(void)
{
TEST_IGNORE(); // delete this line to run test
const char letter = 'B';
const char *expected[] = {
// clang-format off
" A ",
"B B",
" A "
//clang-format on
};
char **diamond = make_diamond(letter);
TEST_ASSERT_EQUAL_STRING_ARRAY(expected, diamond, ARRAY_SIZE(expected));
free_diamond(diamond);
}

static void
test_rows_smallest_non_degenerate_case_with_odd_diamond_side_length(void)
static void test_rows_smallest_non_degenerate_case_with_odd_diamond_side_length(void)
{
TEST_IGNORE();
const char letter = 'C';
const char *expected[] = {
// clang-format off
" A ",
" B B ",
"C C",
" B B ",
" A "
// clang-format on
};
char **diamond = make_diamond(letter);
TEST_ASSERT_EQUAL_STRING_ARRAY(expected, diamond, ARRAY_SIZE(expected));
free_diamond(diamond);
}

static void
test_rows_smallest_non_degenerate_case_with_even_diamond_side_length(void)
static void test_rows_smallest_non_degenerate_case_with_even_diamond_side_length(void)
{
TEST_IGNORE();
const char letter = 'D';
const char *expected[] = {
// clang-format off
" A ",
" B B ",
" C C ",
"D D",
" C C ",
" B B ",
" A "
// clang-format on
};
char **diamond = make_diamond(letter);
TEST_ASSERT_EQUAL_STRING_ARRAY(expected, diamond, ARRAY_SIZE(expected));
Expand All @@ -80,10 +63,8 @@ test_rows_smallest_non_degenerate_case_with_even_diamond_side_length(void)

static void test_rows_largest_possible_diamond(void)
{
TEST_IGNORE();
const char letter = 'Z';
const char *expected[] = {
// clang-format off
" A ",
" B B ",
" C C ",
Expand Down Expand Up @@ -135,7 +116,6 @@ static void test_rows_largest_possible_diamond(void)
" C C ",
" B B ",
" A "
// clang-format on
};
char **diamond = make_diamond(letter);
TEST_ASSERT_EQUAL_STRING_ARRAY(expected, diamond, ARRAY_SIZE(expected));
Expand All @@ -147,12 +127,9 @@ int main(void)
UNITY_BEGIN();

RUN_TEST(test_rows_degenerate_case_with_a_single_a_row);
RUN_TEST(
test_rows_degenerate_case_with_no_row_with_3_distinct_groups_of_spaces);
RUN_TEST(
test_rows_smallest_non_degenerate_case_with_odd_diamond_side_length);
RUN_TEST(
test_rows_smallest_non_degenerate_case_with_even_diamond_side_length);
RUN_TEST(test_rows_degenerate_case_with_no_row_with_3_distinct_groups_of_spaces);
RUN_TEST(test_rows_smallest_non_degenerate_case_with_odd_diamond_side_length);
RUN_TEST(test_rows_smallest_non_degenerate_case_with_even_diamond_side_length);
RUN_TEST(test_rows_largest_possible_diamond);

return UNITY_END();
Expand Down