Update tests for new check library & osx
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
START_TEST (test_uc_hex_encode_1)
|
||||
{
|
||||
uint8_t binary[] = {0xff};
|
||||
char hex[3] = "";
|
||||
|
||||
@@ -11,9 +12,11 @@ START_TEST (test_uc_hex_encode_1)
|
||||
|
||||
fail_if(strcmp(hex,"FF") != 0);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_2)
|
||||
{
|
||||
uint8_t binary[] = {127, 128, 129};
|
||||
char hex[sizeof binary * 2 + 1] = "";
|
||||
|
||||
@@ -21,9 +24,11 @@ START_TEST (test_uc_hex_encode_2)
|
||||
|
||||
fail_if(strcmp(hex,"7F8081") != 0, "was %s", hex);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_3)
|
||||
{
|
||||
uint8_t binary[] = {0, 1, 9, 11};
|
||||
char hex[sizeof binary * 2 + 1] = "";
|
||||
|
||||
@@ -31,9 +36,11 @@ START_TEST (test_uc_hex_encode_3)
|
||||
|
||||
fail_if(strcmp(hex,"0001090B") != 0, "was %s", hex);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_zero_len)
|
||||
{
|
||||
uint8_t binary[1] = {0xff};
|
||||
char hex[3] = "aa";
|
||||
|
||||
@@ -42,9 +49,11 @@ START_TEST (test_uc_hex_encode_zero_len)
|
||||
fail_if(hex[0] != 0);
|
||||
fail_if(hex[1] != 'a');
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_1)
|
||||
{
|
||||
char hex[] = "1F";
|
||||
uint8_t binary[2] = {0x11,0x22};
|
||||
uint8_t *res;
|
||||
@@ -55,9 +64,11 @@ START_TEST (test_uc_hex_decode_1)
|
||||
fail_if(binary[1] != 0x22);
|
||||
fail_if(res != binary + 1, "binary %p, res %p", &binary[0], res);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_2)
|
||||
{
|
||||
char hex[] = "00FF80";
|
||||
uint8_t binary[4] = {0x11, 0x11, 0x11};
|
||||
uint8_t *res;
|
||||
@@ -69,9 +80,11 @@ START_TEST (test_uc_hex_decode_2)
|
||||
fail_if(binary[2] != 0x80);
|
||||
fail_if(res != binary + 3, "binary %p, res %p", &binary[0], res);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_zero_length)
|
||||
{
|
||||
char hex[] = "00FF80";
|
||||
uint8_t binary[4] = {0x11, 0x11, 0x11};
|
||||
uint8_t *res;
|
||||
@@ -83,9 +96,11 @@ START_TEST (test_uc_hex_decode_zero_length)
|
||||
fail_if(binary[2] != 0x11);
|
||||
fail_if(res != binary);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_empty_string)
|
||||
{
|
||||
char hex[] = "";
|
||||
uint8_t binary[] = {0x11, 0x11, 0x11};
|
||||
uint8_t *res;
|
||||
@@ -97,8 +112,10 @@ START_TEST (test_uc_hex_decode_empty_string)
|
||||
fail_if(binary[2] != 0x11);
|
||||
fail_if(res != binary, "length %zu\n", res - binary);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
START_TEST (test_uc_hex_decode_spaces)
|
||||
{
|
||||
char hex[] = " 11 1213";
|
||||
uint8_t binary[3];
|
||||
uint8_t *res;
|
||||
@@ -110,9 +127,11 @@ START_TEST (test_uc_hex_decode_spaces)
|
||||
fail_if(binary[2] != 0x13);
|
||||
fail_if(res != binary+3, "length %zu\n", res - binary);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_spaces2)
|
||||
{
|
||||
char hex[] = "1112 13\r\n";
|
||||
uint8_t binary[3];
|
||||
uint8_t *res;
|
||||
@@ -124,9 +143,11 @@ START_TEST (test_uc_hex_decode_spaces2)
|
||||
fail_if(binary[2] != 0x13);
|
||||
fail_if(res != binary+3, "length %zu\n", res - binary);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_spaces_empty)
|
||||
{
|
||||
char hex[] = " \r\n ";
|
||||
uint8_t binary[] = {0x11,0x12};
|
||||
uint8_t *res;
|
||||
@@ -137,9 +158,11 @@ START_TEST (test_uc_hex_decode_spaces_empty)
|
||||
fail_if(binary[1] != 0x12);
|
||||
fail_if(res != binary, "length %zu\n", res - binary);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_odd_length)
|
||||
{
|
||||
char hex[] = "33FF80";
|
||||
uint8_t binary[4] = {0x11, 0x11, 0x11};
|
||||
uint8_t *res;
|
||||
@@ -151,9 +174,11 @@ START_TEST (test_uc_hex_decode_odd_length)
|
||||
fail_if(binary[2] != 0x11);
|
||||
fail_if(res != &binary[1]);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_decode_invalid)
|
||||
{
|
||||
char hex[] = "TEST ";
|
||||
uint8_t binary[4] = {0x11, 0x11, 0x11};
|
||||
uint8_t *res;
|
||||
@@ -165,9 +190,11 @@ START_TEST (test_uc_hex_decode_invalid)
|
||||
fail_if(binary[2] != 0x11);
|
||||
fail_if(res != NULL);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_delim_1)
|
||||
{
|
||||
uint8_t binary[4] = {0xFF, 0x00, 0x7F, 0x0A};
|
||||
char hex[17] = "";
|
||||
char *res;
|
||||
@@ -178,9 +205,11 @@ START_TEST (test_uc_hex_encode_delim_1)
|
||||
*res = 0;
|
||||
fail_if(res != hex + 12);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_delim_2)
|
||||
{
|
||||
uint8_t binary[] = {0xFF, 0x00};
|
||||
char hex[8] = "";
|
||||
char *res;
|
||||
@@ -190,9 +219,11 @@ START_TEST (test_uc_hex_encode_delim_2)
|
||||
fail_if(strcmp(hex, "FF \n00 ") != 0, "hex was '%s'", hex);
|
||||
fail_if(res != hex + 7, "sz was %zu", res - hex);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_uc_hex_encode_delim_zero_len)
|
||||
{
|
||||
uint8_t binary[] = {0xFF, 0x00};
|
||||
char hex[8] = "......";
|
||||
char *res;
|
||||
@@ -202,10 +233,12 @@ START_TEST (test_uc_hex_encode_delim_zero_len)
|
||||
fail_if(strcmp(hex, "") != 0, "hex was '%s'", hex);
|
||||
fail_if(res != hex);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (test_uc_hex_decode_lowercase)
|
||||
{
|
||||
char hex[] = "1f";
|
||||
uint8_t binary[2] = {0x11,0x22};
|
||||
uint8_t *res;
|
||||
@@ -216,6 +249,7 @@ START_TEST (test_uc_hex_decode_lowercase)
|
||||
fail_if(binary[1] != 0x22);
|
||||
fail_if(res != binary + 1, "binary %p, res %p", &binary[0], res);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
Suite *hex_suite(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user