From c0c5237849fb7a647de82c590c34d71239f948a4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 26 Feb 2026 10:45:56 -0800 Subject: feat(lab_6): complete Unity tests including squareNumber --- lab_6/unity/test/tests/Testfoo.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lab_6/unity') diff --git a/lab_6/unity/test/tests/Testfoo.c b/lab_6/unity/test/tests/Testfoo.c index eac2bee..433dc4e 100644 --- a/lab_6/unity/test/tests/Testfoo.c +++ b/lab_6/unity/test/tests/Testfoo.c @@ -28,6 +28,8 @@ void testTEST_ASSERT_FALSE (void) void testTEST_ASSERT_EQUAL_INT8 (void) { TEST_ASSERT_EQUAL_INT8( 1, 1); + TEST_ASSERT_EQUAL_INT8(-5, -5); + TEST_ASSERT_EQUAL_INT8(0x7f, 127); //TEST_ASSERT_EQUAL_INT8(-1, 1); //failing } @@ -36,6 +38,8 @@ void testTEST_ASSERT_EQUAL_INT8 (void) void testTEST_ASSERT_EQUAL_UINT8 (void) { TEST_ASSERT_EQUAL_UINT8(1, 1); + TEST_ASSERT_EQUAL_UINT8(255, 255); + TEST_ASSERT_EQUAL_UINT8(0xa5, 165); //TEST_ASSERT_EQUAL_UINT8(1, -1); //failing } @@ -44,6 +48,8 @@ void testTEST_ASSERT_EQUAL_UINT8 (void) void testTEST_ASSERT_EQUAL_HEX8 (void) { TEST_ASSERT_EQUAL_HEX8( 0xff, 0xff ); + TEST_ASSERT_EQUAL_HEX8( 0x00, 0x00 ); + TEST_ASSERT_EQUAL_HEX8( 0x7f, 0x7f ); //TEST_ASSERT_EQUAL_HEX8( 0x00, 0xff ); //failing } @@ -80,5 +86,15 @@ void testTEST_ASSERT_BIT_HIGH (void) // unsigned integer. void testsquareNumber (void) { - + uint16_t input; + uint16_t expected; + uint16_t actual; + + for (input = 0; input <= 255; input++) + { + expected = input * input; + actual = squareNumber((uint8_t) input); + + TEST_ASSERT_EQUAL_UINT16(expected, actual); + } } -- cgit v1.2.3