added more test cases
This commit is contained in:
+29
-8
@@ -75,6 +75,7 @@ int reject_decode_service_request(
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// decode the whole APDU - mainly used for unit testing
|
||||||
int reject_decode_apdu(
|
int reject_decode_apdu(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
unsigned apdu_len,
|
unsigned apdu_len,
|
||||||
@@ -86,15 +87,18 @@ int reject_decode_apdu(
|
|||||||
if (!apdu)
|
if (!apdu)
|
||||||
return -1;
|
return -1;
|
||||||
// optional checking - most likely was already done prior to this call
|
// optional checking - most likely was already done prior to this call
|
||||||
if (apdu[0] != PDU_TYPE_REJECT)
|
if (apdu_len)
|
||||||
return -1;
|
|
||||||
if (apdu_len > 1)
|
|
||||||
{
|
{
|
||||||
len = reject_decode_service_request(
|
if (apdu[0] != PDU_TYPE_REJECT)
|
||||||
&apdu[1],
|
return -1;
|
||||||
apdu_len - 1,
|
if (apdu_len > 1)
|
||||||
invoke_id,
|
{
|
||||||
reject_reason);
|
len = reject_decode_service_request(
|
||||||
|
&apdu[1],
|
||||||
|
apdu_len - 1,
|
||||||
|
invoke_id,
|
||||||
|
reject_reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
@@ -140,6 +144,23 @@ void testReject(Test * pTest)
|
|||||||
&test_reject_reason);
|
&test_reject_reason);
|
||||||
ct_test(pTest, len == -1);
|
ct_test(pTest, len == -1);
|
||||||
|
|
||||||
|
// test NULL APDU
|
||||||
|
len = reject_decode_apdu(
|
||||||
|
NULL,
|
||||||
|
apdu_len,
|
||||||
|
&test_invoke_id,
|
||||||
|
&test_reject_reason);
|
||||||
|
ct_test(pTest, len == -1);
|
||||||
|
|
||||||
|
// force a zero length
|
||||||
|
len = reject_decode_apdu(
|
||||||
|
&apdu[0],
|
||||||
|
0,
|
||||||
|
&test_invoke_id,
|
||||||
|
&test_reject_reason);
|
||||||
|
ct_test(pTest, len == 0);
|
||||||
|
|
||||||
|
|
||||||
// check them all...
|
// check them all...
|
||||||
for (
|
for (
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user