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

Additional rectangles test #106

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
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
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