| #include "../../unity/unity.h" |
| #include <stdio.h> |
| #include <stdlib.h> |
|
|
| void setUp(void) { |
| |
| } |
|
|
| void tearDown(void) { |
| |
| } |
|
|
| |
| void test_suffix_power_k_variants(void) { |
| TEST_ASSERT_EQUAL_INT(1, suffix_power('K')); |
| TEST_ASSERT_EQUAL_INT(1, suffix_power('k')); |
| } |
|
|
| |
| void test_suffix_power_all_uppercase(void) { |
| struct { |
| char suf; |
| int expected; |
| } cases[] = { |
| { 'M', 2 }, |
| { 'G', 3 }, |
| { 'T', 4 }, |
| { 'P', 5 }, |
| { 'E', 6 }, |
| { 'Z', 7 }, |
| { 'Y', 8 }, |
| { 'R', 9 }, |
| { 'Q', 10 }, |
| }; |
|
|
| for (size_t i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) { |
| TEST_ASSERT_EQUAL_INT(cases[i].expected, suffix_power(cases[i].suf)); |
| } |
| } |
|
|
| |
| void test_suffix_power_lowercase_unrecognized(void) { |
| char lows[] = { 'm', 'g', 't', 'p', 'e', 'z', 'y', 'r', 'q' }; |
| for (size_t i = 0; i < sizeof(lows)/sizeof(lows[0]); i++) { |
| TEST_ASSERT_EQUAL_INT(0, suffix_power(lows[i])); |
| } |
| } |
|
|
| |
| void test_suffix_power_invalid_chars(void) { |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('A')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('b')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('0')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power(' ')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('\0')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('\n')); |
| } |
|
|
| |
| void test_suffix_power_boundary_non_suffixes(void) { |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('@')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('[')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('`')); |
| TEST_ASSERT_EQUAL_INT(0, suffix_power('{')); |
| } |
|
|
| int main(void) { |
| UNITY_BEGIN(); |
|
|
| RUN_TEST(test_suffix_power_k_variants); |
| RUN_TEST(test_suffix_power_all_uppercase); |
| RUN_TEST(test_suffix_power_lowercase_unrecognized); |
| RUN_TEST(test_suffix_power_invalid_chars); |
| RUN_TEST(test_suffix_power_boundary_non_suffixes); |
|
|
| return UNITY_END(); |
| } |