@@ -383,6 +383,26 @@ 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 )
387+ {
388+ static const uint8_t options_blob [] = { 0x00 };
389+ const unicoap_option_number_t OPTION_NUMBER = 0 ; // RESERVED
390+ 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 (sizeof (options_blob ), unicoap_options_size (& options ));
393+ _TEST_ASSERT_EQUAL_BYTES (options_blob , unicoap_options_data (& options ), sizeof (options_blob ));
394+
395+ uint8_t uint8_val = 42 ;
396+ TEST_ASSERT_EQUAL_INT (0 , unicoap_options_get_uint8 (& options , OPTION_NUMBER , & uint8_val ));
397+ TEST_ASSERT_EQUAL_INT (0 , uint8_val );
398+ uint16_t uint16_val = 42 ;
399+ TEST_ASSERT_EQUAL_INT (0 , unicoap_options_get_uint16 (& options , OPTION_NUMBER , & uint16_val ));
400+ TEST_ASSERT_EQUAL_INT (0 , uint16_val );
401+ uint32_t uint32_val = 42 ;
402+ TEST_ASSERT_EQUAL_INT (0 , unicoap_options_get_uint32 (& options , OPTION_NUMBER , & uint32_val ));
403+ TEST_ASSERT_EQUAL_INT (0 , uint32_val );
404+ }
405+
386406Test * tests_unicoap_options (void )
387407{
388408 EMB_UNIT_TESTFIXTURES (fixtures ){
@@ -393,6 +413,7 @@ Test* tests_unicoap_options(void)
393413 new_TestFixture (test_remove_leading ),
394414 new_TestFixture (test_remove_trailing ),
395415 new_TestFixture (test_remove_multiple ),
416+ new_TestFixture (test_shortest_uint_in_option_value ),
396417 };
397418
398419 EMB_UNIT_TESTCALLER (test_unicoap , NULL , NULL , fixtures );
0 commit comments