forked from PAWPAW-Mirror/lib_xua
Add test that specifies a bit out-of-range when modifying a report item
This commit is contained in:
@@ -5,15 +5,37 @@
|
|||||||
#include "xua_unit_tests.h"
|
#include "xua_unit_tests.h"
|
||||||
#include "xua_hid_report_descriptor.h"
|
#include "xua_hid_report_descriptor.h"
|
||||||
|
|
||||||
void test_uninitialised_hidGetReportDescriptor()
|
static unsigned construct_usage_header( unsigned size )
|
||||||
|
{
|
||||||
|
unsigned header = 0x00;
|
||||||
|
|
||||||
|
header |= ( HID_REPORT_ITEM_USAGE_TAG << HID_REPORT_ITEM_HDR_TAG_SHIFT ) & HID_REPORT_ITEM_HDR_TAG_MASK;
|
||||||
|
header |= ( HID_REPORT_ITEM_USAGE_TYPE << HID_REPORT_ITEM_HDR_TYPE_SHIFT ) & HID_REPORT_ITEM_HDR_TYPE_MASK;
|
||||||
|
|
||||||
|
header |= ( size << HID_REPORT_ITEM_HDR_SIZE_SHIFT ) & HID_REPORT_ITEM_HDR_SIZE_MASK;
|
||||||
|
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_uninitialised_hidGetReportDescriptor( void )
|
||||||
{
|
{
|
||||||
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
||||||
TEST_ASSERT_NULL( reportDescPtr );
|
TEST_ASSERT_NULL( reportDescPtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_initialised_hidGetReportDescriptor()
|
void test_initialised_hidGetReportDescriptor( void )
|
||||||
{
|
{
|
||||||
hidInitReportDescriptor();
|
hidInitReportDescriptor();
|
||||||
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
||||||
TEST_ASSERT_NOT_NULL( reportDescPtr );
|
TEST_ASSERT_NOT_NULL( reportDescPtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_bad_bit_hidSetReportItem( void )
|
||||||
|
{
|
||||||
|
const unsigned bit = 8;
|
||||||
|
const unsigned byte = 0;
|
||||||
|
const unsigned char header = construct_usage_header( 0 );
|
||||||
|
|
||||||
|
unsigned retVal = hidSetReportItem( byte, bit, header, NULL );
|
||||||
|
TEST_ASSERT_EQUAL_UINT( HID_STATUS_BAD_LOCATION, retVal );
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user