@@ -34,11 +34,36 @@ void test_calculate_checksum_with_max_values(void) {
3434 TEST_ASSERT_EQUAL_UINT8 (expected_checksum , actual_checksum );
3535}
3636
37+ void test_calculate_checksum_with_null_buffer (void ) {
38+ uint8_t * data = NULL ;
39+ uint8_t expected_checksum = 0 ; // Null buffer should return 0
40+ uint8_t actual_checksum = calculate_checksum (data , 10 ); // Length is arbitrary since buffer is NULL
41+ TEST_ASSERT_EQUAL_UINT8 (expected_checksum , actual_checksum );
42+ }
43+
44+ void test_calculate_checksum_with_zero_length (void ) {
45+ uint8_t data [] = {0x01 , 0x02 , 0x03 };
46+ uint8_t expected_checksum = 0 ; // Zero length should return 0
47+ uint8_t actual_checksum = calculate_checksum (data , 0 );
48+ TEST_ASSERT_EQUAL_UINT8 (expected_checksum , actual_checksum );
49+ }
50+
51+ void test_calculate_zero_checksum (void ) {
52+ uint8_t data [] = {0x00 , 0x00 , 0x00 , 0x00 };
53+ uint8_t expected_checksum = 0 ; // All zeros should yield a checksum of 0
54+ uint8_t actual_checksum = calculate_checksum (data , sizeof (data ));
55+ TEST_ASSERT_EQUAL_UINT8 (expected_checksum , actual_checksum );
56+ }
57+
3758int main (void ) {
3859 UNITY_BEGIN ();
3960 RUN_TEST (test_calculate_checksum_with_valid_data );
4061 RUN_TEST (test_calculate_checksum_with_empty_data );
4162 RUN_TEST (test_calculate_checksum_with_max_values );
63+ RUN_TEST (test_calculate_checksum_with_null_buffer );
64+ RUN_TEST (test_calculate_checksum_with_zero_length );
65+ RUN_TEST (test_calculate_zero_checksum );
66+
4267 return UNITY_END ();
4368}
4469
0 commit comments