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

Cipher exercises test boundary characters #129

Merged
merged 1 commit into from
Dec 6, 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
9 changes: 9 additions & 0 deletions exercises/practice/affine-cipher/affine_cipher_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ void test_decode_with_a_not_coprime_to_m(void) {
TEST_ASSERT_EQUAL_STRING("", buffer);
}

void test_encode_boundary_characters(void) {
TEST_IGNORE();
char buffer[BUFFER_SIZE];

encode(buffer, "/09:@AMNZ[`amnz{", 25, 12);
TEST_ASSERT_EQUAL_STRING("09maz nmazn", buffer);
}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_encode_yes);
Expand All @@ -157,5 +165,6 @@ int main(void) {
RUN_TEST(test_decode_with_no_spaces_in_input);
RUN_TEST(test_decode_with_too_many_spaces);
RUN_TEST(test_decode_with_a_not_coprime_to_m);
RUN_TEST(test_encode_boundary_characters);
return UNITY_END();
}
9 changes: 9 additions & 0 deletions exercises/practice/atbash-cipher/atbash_cipher_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ void test_decode_with_no_spaces(void) {
TEST_ASSERT_EQUAL_STRING("anobstacleisoftenasteppingstone", buffer);
}

void test_encode_boundary_characters(void) {
TEST_IGNORE();
char buffer[BUFFER_SIZE];

encode(buffer, "/09:@AMNZ[`amnz{");
TEST_ASSERT_EQUAL_STRING("09znm aznma", buffer);
}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_encode_yes);
Expand All @@ -139,5 +147,6 @@ int main(void) {
RUN_TEST(test_decode_all_the_letters);
RUN_TEST(test_decode_with_too_many_spaces);
RUN_TEST(test_decode_with_no_spaces);
RUN_TEST(test_encode_boundary_characters);
return UNITY_END();
}
9 changes: 9 additions & 0 deletions exercises/practice/rotational-cipher/rotational_cipher_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ void test_rotate_all_letters(void) {
TEST_ASSERT_EQUAL_STRING("Gur dhvpx oebja sbk whzcf bire gur ynml qbt.", buffer);
}

void test_rotate_boundary_characters(void) {
TEST_IGNORE();
char buffer[BUFFER_SIZE];

rotate(buffer, "/09:@AMNZ[`amnz{", 13);
TEST_ASSERT_EQUAL_STRING("/09:@NZAM[`nzam{", buffer);
}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_rotate_a_by_0_same_output_as_input);
Expand All @@ -101,5 +109,6 @@ int main(void) {
RUN_TEST(test_rotate_numbers);
RUN_TEST(test_rotate_punctuation);
RUN_TEST(test_rotate_all_letters);
RUN_TEST(test_rotate_boundary_characters);
return UNITY_END();
}
16 changes: 16 additions & 0 deletions generators/exercises/affine_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
extern void decode(char *buffer, const char *phrase, unsigned a, unsigned b);
"""

def extra_cases():
return [
{
"description": "encode boundary characters",
"property": "encode",
"input": {
"phrase": "/09:@AMNZ[`amnz{",
"key": {
"a": 25,
"b": 12
}
},
"expected": "09maz nmazn"
}
]

def gen_func_body(prop, inp, expected):
phrase = inp["phrase"]
a = inp["key"]["a"]
Expand Down
12 changes: 12 additions & 0 deletions generators/exercises/atbash_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
extern void decode(char *buffer, const char *phrase);
"""

def extra_cases():
return [
{
"description": "encode boundary characters",
"property": "encode",
"input": {
"phrase": "/09:@AMNZ[`amnz{"
},
"expected": "09znm aznma"
}
]

def gen_func_body(prop, inp, expected):
phrase = inp["phrase"]
str_list = []
Expand Down
13 changes: 13 additions & 0 deletions generators/exercises/rotational_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
extern void rotate(char *buffer, const char *text, int shift_key);
"""

def extra_cases():
return [
{
"description": "rotate boundary characters",
"property": "rotate",
"input": {
"text": "/09:@AMNZ[`amnz{",
"shiftKey": 13
},
"expected": "/09:@NZAM[`nzam{"
}
]

def gen_func_body(prop, inp, expected):
text = inp["text"]
shift_key = inp["shiftKey"]
Expand Down