README.md
1### Tests have been generated with the following code
2
3```c
4
5void dump_report_map(const uint8_t *data, size_t len){
6 esp_hid_report_map_t * report_map = esp_hid_parse_report_map(data, len);
7 printf(" TEST_ASSERT_NOT_NULL(report_map);\n");
8 printf(" TEST_ASSERT(report_map->usage == ESP_HID_USAGE_%s);\n", esp_hid_usage_str(report_map->usage));
9 printf(" TEST_ASSERT(report_map->appearance == 0x%04X);\n", report_map->appearance);
10 printf(" TEST_ASSERT(report_map->reports_len == %u);\n", report_map->reports_len);
11 for(uint8_t i=0; i<report_map->reports_len; i++){
12 printf(" TEST_ASSERT(report_map->reports[%u].report_id == %u);\n", i, report_map->reports[i].report_id);
13 printf(" TEST_ASSERT(report_map->reports[%u].report_type == ESP_HID_REPORT_TYPE_%s);\n", i, esp_hid_report_type_str(report_map->reports[i].report_type));
14 printf(" TEST_ASSERT(report_map->reports[%u].protocol_mode == ESP_HID_PROTOCOL_MODE_%s);\n", i, esp_hid_protocol_mode_str(report_map->reports[i].protocol_mode));
15 printf(" TEST_ASSERT(report_map->reports[%u].usage == ESP_HID_USAGE_%s);\n", i, esp_hid_usage_str(report_map->reports[i].usage));
16 printf(" TEST_ASSERT(report_map->reports[%u].value_len == %u);\n", i, report_map->reports[i].value_len);
17 }
18 printf(" esp_hid_free_report_map(report_map);\n");
19}
20
21#define _str(a) #a
22#define xstr(a) _str(a)
23#define TEST_DUMP(map) \
24 printf("TEST_CASE(\"can parse " xstr(map) "\", \"[esp_hid]\")\n{\n"); \
25 printf(" esp_hid_report_map_t * report_map = esp_hid_parse_report_map(" xstr(map) ", sizeof(" xstr(map) "));\n"); \
26 dump_report_map(map, sizeof(map)); \
27 printf("}\n\n");
28
29void generate_tests(){
30 TEST_DUMP(hidReportMap);
31 TEST_DUMP(relMouseReportMap);
32 TEST_DUMP(absMouseReportMap);
33 TEST_DUMP(keyboardReportMap);
34 TEST_DUMP(joystickReportMap);
35 TEST_DUMP(mediaReportMap);
36 TEST_DUMP(mediaReportMap2);
37 TEST_DUMP(hidapiReportMap);
38}
39
40```
41