@@ -313,3 +313,43 @@ TEST_F(WpcCddApiTest, settingTooManyOptionalItemsShouldFail)
313
313
ASSERT_GT (detected_max_item_count, 0 );
314
314
}
315
315
316
+ TEST_F (WpcCddApiTest, gettingEndpointsListShouldFailIfBufferIsTooSmall)
317
+ {
318
+ const uint8_t TEST_PAYLOAD[] = { 0x10 };
319
+ ASSERT_EQ (APP_RES_OK, WPC_set_config_data_item (100 , TEST_PAYLOAD, sizeof (TEST_PAYLOAD)));
320
+ ASSERT_EQ (APP_RES_OK, WPC_set_config_data_item (200 , TEST_PAYLOAD, sizeof (TEST_PAYLOAD)));
321
+
322
+ uint16_t endpoints_list[1 ] = { 0 };
323
+ uint8_t endpoints_count = 0xFF ;
324
+ ASSERT_EQ (APP_RES_INTERNAL_ERROR,
325
+ WPC_get_config_data_item_list (endpoints_list, sizeof (endpoints_list), &endpoints_count));
326
+ }
327
+
328
+ TEST_F (WpcCddApiTest, shouldReturnEmptyListIfNoOptionalItemIsSet)
329
+ {
330
+ uint16_t endpoints_list[10 ] = { 0 };
331
+ uint8_t endpoints_count = 0xFF ;
332
+ ASSERT_EQ (APP_RES_OK,
333
+ WPC_get_config_data_item_list (endpoints_list, sizeof (endpoints_list), &endpoints_count));
334
+ ASSERT_EQ (0 , endpoints_count);
335
+ }
336
+
337
+ TEST_F (WpcCddApiTest, gettingListOfOptionalEndpointsShouldWork)
338
+ {
339
+ const std::set<uint16_t > endpoints = { 0xAABB , 0x1234 , 0xD0B0 };
340
+ for (const auto & endpoint : endpoints) {
341
+ const uint8_t TEST_PAYLOAD[] = { 0x10 };
342
+ ASSERT_EQ (APP_RES_OK, WPC_set_config_data_item (endpoint, TEST_PAYLOAD, sizeof (TEST_PAYLOAD)));
343
+ }
344
+
345
+ uint16_t endpoints_list[3 ] = { 0 };
346
+ uint8_t endpoints_count = 0xFF ;
347
+ ASSERT_EQ (APP_RES_OK,
348
+ WPC_get_config_data_item_list (endpoints_list, sizeof (endpoints_list), &endpoints_count));
349
+
350
+ ASSERT_EQ (endpoints.size (), endpoints_count);
351
+ for (uint8_t i = 0 ; i < endpoints_count; i++){
352
+ ASSERT_EQ (1 , endpoints.count (endpoints_list[i]));
353
+ }
354
+ }
355
+
0 commit comments