| | |
| | | |
| | | // test conversion to decimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int32ToStr(val[i], str, max, 10); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 10, TRUE); |
| | | snprintf(ref, max, "%"PRIi32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to hexadecimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int32ToStr(val[i], str, max, 16); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 16, TRUE); |
| | | snprintf(ref, max, "%"PRIX32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to octal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int32ToStr(val[i], str, max, 8); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 8, TRUE); |
| | | snprintf(ref, max, "%"PRIo32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | | } |
| | | |
| | | // test conversion to binary numbers |
| | | len = SCPI_Int32ToStr(0, str, max, 2); |
| | | len = SCPI_Int32ToStr(0, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 1); |
| | | CU_ASSERT_STRING_EQUAL(str, "0"); |
| | | |
| | | len = SCPI_Int32ToStr(1, str, max, 2); |
| | | len = SCPI_Int32ToStr(1, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 1); |
| | | CU_ASSERT_STRING_EQUAL(str, "1"); |
| | | |
| | | len = SCPI_Int32ToStr(-1, str, max, 2); |
| | | len = SCPI_Int32ToStr(-1, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 32); |
| | | CU_ASSERT_STRING_EQUAL(str, "11111111111111111111111111111111"); |
| | | |
| | | len = SCPI_Int32ToStr(0x01234567, str, max, 2); |
| | | len = SCPI_Int32ToStr(0x01234567, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 25); |
| | | CU_ASSERT_STRING_EQUAL(str, "1001000110100010101100111"); |
| | | |
| | | len = SCPI_Int32ToStr(0x89abcdef, str, max, 2); |
| | | len = SCPI_Int32ToStr(0x89abcdef, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 32); |
| | | CU_ASSERT_STRING_EQUAL(str, "10001001101010111100110111101111"); |
| | | } |
| | |
| | | |
| | | // test conversion to decimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt32ToStr(val[i], str, max, 10); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 10, FALSE); |
| | | snprintf(ref, max, "%"PRIu32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to hexadecimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt32ToStr(val[i], str, max, 16); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 16, FALSE); |
| | | snprintf(ref, max, "%"PRIX32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to octal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt32ToStr(val[i], str, max, 8); |
| | | len = SCPI_Int32ToStr(val[i], str, max, 8, FALSE); |
| | | snprintf(ref, max, "%"PRIo32, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to decimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int64ToStr(val[i], str, max, 10); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 10, TRUE); |
| | | snprintf(ref, max, "%"PRIi64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to hexadecimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int64ToStr(val[i], str, max, 16); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 16, TRUE); |
| | | snprintf(ref, max, "%"PRIX64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to octal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_Int64ToStr(val[i], str, max, 8); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 8, TRUE); |
| | | snprintf(ref, max, "%"PRIo64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | | } |
| | | |
| | | // test conversion to binary numbers |
| | | len = SCPI_Int64ToStr(0, str, max, 2); |
| | | len = SCPI_Int64ToStr(0, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 1); |
| | | CU_ASSERT_STRING_EQUAL(str, "0"); |
| | | |
| | | len = SCPI_Int64ToStr(1, str, max, 2); |
| | | len = SCPI_Int64ToStr(1, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 1); |
| | | CU_ASSERT_STRING_EQUAL(str, "1"); |
| | | |
| | | len = SCPI_Int64ToStr(-1, str, max, 2); |
| | | len = SCPI_Int64ToStr(-1, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 64); |
| | | CU_ASSERT_STRING_EQUAL(str, "1111111111111111111111111111111111111111111111111111111111111111"); |
| | | |
| | | len = SCPI_Int64ToStr(0x0123456789abcdef, str, max, 2); |
| | | len = SCPI_Int64ToStr(0x0123456789abcdef, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 57); |
| | | CU_ASSERT_STRING_EQUAL(str, "100100011010001010110011110001001101010111100110111101111"); |
| | | |
| | | len = SCPI_Int64ToStr(0xfedcba9876543210, str, max, 2); |
| | | len = SCPI_Int64ToStr(0xfedcba9876543210, str, max, 2, TRUE); |
| | | CU_ASSERT(len == 64); |
| | | CU_ASSERT_STRING_EQUAL(str, "1111111011011100101110101001100001110110010101000011001000010000"); |
| | | } |
| | |
| | | |
| | | // test conversion to decimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt64ToStr(val[i], str, max, 10); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 10, FALSE); |
| | | snprintf(ref, max, "%"PRIu64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to hexadecimal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt64ToStr(val[i], str, max, 16); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 16, FALSE); |
| | | snprintf(ref, max, "%"PRIX64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |
| | |
| | | |
| | | // test conversion to octal numbers |
| | | for (uintptr_t i=0; i<7; i++) { |
| | | len = SCPI_UInt64ToStr(val[i], str, max, 8); |
| | | len = SCPI_Int64ToStr(val[i], str, max, 8, FALSE); |
| | | snprintf(ref, max, "%"PRIo64, val[i]); |
| | | CU_ASSERT(len == strlen(ref)); |
| | | CU_ASSERT_STRING_EQUAL(str, ref); |