Skip to content

Commit

Permalink
Additional rectangles test (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode authored Nov 4, 2024
1 parent a5127f2 commit 02a30c3
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
30 changes: 30 additions & 0 deletions exercises/practice/rectangles/rectangles_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,35 @@ void test_rectangles_must_have_four_sides(void) {
TEST_ASSERT_EQUAL_INT(5, rectangles(strings));
}

void test_very_large_input(void) {
TEST_IGNORE();
const char *strings[] = {
" +-----+--------+ +-----+ ",
"++---++-----+--------+---++-----++",
"||+--++-----+-+-++ | || ||",
"||| || +-+-++-+ | || ||",
"||| || | | || | | || ||",
"||| +++-----+-+-++-+-+---++-+ ||",
"||| ||| | | || | |+--++-+-+ ||",
"||| +++---+-+-+-++-+-++--++-+ | ||",
"||| |||+--+-+-+-+| | |+--++---+ ||",
"||| |||| | | | || | |+-+|| ||",
"||+-++++--+-+++-++-+-++-+++---++||",
"|| |+++--+-+++-+--+-+| ||| ||||",
"+++-+++++---++--+-++-++-+++---+|||",
" |+-+++++---++--+ || || ||| ||||",
" | +++++---++--+-++-++-++++ ||||",
" | |||| |+----++-++-++++--+++|",
" | |+++---+| || || || || |",
"+++ |||+---++----+| || || || |",
"||| +++----++----++-++-++----++-+",
"+++---++----++-----+-++-++----++ ",
" +-+ ",
NULL
};
TEST_ASSERT_EQUAL_INT(2063, rectangles(strings));
}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_no_rows);
Expand All @@ -189,5 +218,6 @@ int main(void) {
RUN_TEST(test_corner_is_required_for_a_rectangle_to_be_complete);
RUN_TEST(test_large_input_with_many_rectangles);
RUN_TEST(test_rectangles_must_have_four_sides);
RUN_TEST(test_very_large_input);
return UNITY_END();
}
34 changes: 34 additions & 0 deletions generators/exercises/rectangles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@
extern int rectangles(const char **strings);
"""

def extra_cases():
return [
{
"description": "very large input",
"property": "rectangles",
"input": {
"strings": [
" +-----+--------+ +-----+ ",
"++---++-----+--------+---++-----++",
"||+--++-----+-+-++ | || ||",
"||| || +-+-++-+ | || ||",
"||| || | | || | | || ||",
"||| +++-----+-+-++-+-+---++-+ ||",
"||| ||| | | || | |+--++-+-+ ||",
"||| +++---+-+-+-++-+-++--++-+ | ||",
"||| |||+--+-+-+-+| | |+--++---+ ||",
"||| |||| | | | || | |+-+|| ||",
"||+-++++--+-+++-++-+-++-+++---++||",
"|| |+++--+-+++-+--+-+| ||| ||||",
"+++-+++++---++--+-++-++-+++---+|||",
" |+-+++++---++--+ || || ||| ||||",
" | +++++---++--+-++-++-++++ ||||",
" | |||| |+----++-++-++++--+++|",
" | |+++---+| || || || || |",
"+++ |||+---++----+| || || || |",
"||| +++----++----++-++-++----++-+",
"+++---++----++-----+-++-++----++ ",
" +-+ "
]
},
"expected": 2063
}
]

def gen_func_body(prop, inp, expected):
strings = inp["strings"]
str_list = []
Expand Down

0 comments on commit 02a30c3

Please sign in to comment.