Skip to content

Commit 7b579cc

Browse files
committed
fixup! sys/net/unicoap: properly handle options with value zero
1 parent ba6784c commit 7b579cc

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tests/unittests/tests-unicoap/tests-unicoap-options.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,24 +383,25 @@ static void test_remove_multiple(void)
383383
_TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
384384
}
385385

386-
static void test_shortest_uint_in_option_value(void)
386+
static void test_option_value_uses_shortest_possible_representation(void)
387387
{
388388
static const uint8_t options_blob[] = { 0x00 };
389389
const unicoap_option_number_t OPTION_NUMBER = 0; // RESERVED
390+
const uint32_t OPTION_VALUE = 0;
390391
UNICOAP_OPTIONS_ALLOC_STATIC(options, 10);
391-
TEST_ASSERT_EQUAL_INT(0, unicoap_options_add_uint(&options, OPTION_NUMBER, 0));
392+
TEST_ASSERT_EQUAL_INT(0, unicoap_options_add_uint(&options, OPTION_NUMBER, OPTION_VALUE));
392393
TEST_ASSERT_EQUAL_INT(sizeof(options_blob), unicoap_options_size(&options));
393394
_TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
394395

395396
uint8_t uint8_val = 42;
396397
TEST_ASSERT_EQUAL_INT(0, unicoap_options_get_uint8(&options, OPTION_NUMBER, &uint8_val));
397-
TEST_ASSERT_EQUAL_INT(0, uint8_val);
398+
TEST_ASSERT_EQUAL_INT(OPTION_VALUE, uint8_val);
398399
uint16_t uint16_val = 42;
399400
TEST_ASSERT_EQUAL_INT(0, unicoap_options_get_uint16(&options, OPTION_NUMBER, &uint16_val));
400-
TEST_ASSERT_EQUAL_INT(0, uint16_val);
401+
TEST_ASSERT_EQUAL_INT(OPTION_VALUE, uint16_val);
401402
uint32_t uint32_val = 42;
402403
TEST_ASSERT_EQUAL_INT(0, unicoap_options_get_uint32(&options, OPTION_NUMBER, &uint32_val));
403-
TEST_ASSERT_EQUAL_INT(0, uint32_val);
404+
TEST_ASSERT_EQUAL_INT(OPTION_VALUE, uint32_val);
404405
}
405406

406407
Test* tests_unicoap_options(void)
@@ -413,7 +414,7 @@ Test* tests_unicoap_options(void)
413414
new_TestFixture(test_remove_leading),
414415
new_TestFixture(test_remove_trailing),
415416
new_TestFixture(test_remove_multiple),
416-
new_TestFixture(test_shortest_uint_in_option_value),
417+
new_TestFixture(test_option_value_uses_shortest_possible_representation),
417418
};
418419

419420
EMB_UNIT_TESTCALLER(test_unicoap, NULL, NULL, fixtures);

0 commit comments

Comments
 (0)