| | |
| | | { .pattern = "TEST:TREEA?", .callback = test_treeA,}, |
| | | { .pattern = "TEST:TREEB?", .callback = test_treeB,}, |
| | | |
| | | { .pattern = "STUB", .callback = SCPI_Stub,}, |
| | | { .pattern = "STUB?", .callback = SCPI_StubQ,}, |
| | | |
| | | SCPI_CMD_LIST_END |
| | | }; |
| | | |
| | |
| | | output_buffer_clear(); \ |
| | | } |
| | | |
| | | #define TEST_IEEE4882_REG(reg, expected) { \ |
| | | CU_ASSERT_EQUAL(SCPI_RegGet(&scpi_context, reg), expected); \ |
| | | } |
| | | |
| | | |
| | | #define TEST_IEEE4882_REG_SET(reg, val) { \ |
| | | SCPI_RegSet(&scpi_context, reg, val); \ |
| | | } |
| | | |
| | | output_buffer_clear(); |
| | | error_buffer_clear(); |
| | | |
| | |
| | | TEST_IEEE4882("*STB?\r\n", "68\r\n"); /* Error queue is still not empty */ |
| | | TEST_IEEE4882("*ESR?\r\n", "0\r\n"); |
| | | |
| | | TEST_IEEE4882("SYST:ERR:COUNT?\r\n", "1\r\n"); |
| | | TEST_IEEE4882("SYST:ERR:NEXT?\r\n", "-113,\"Undefined header\"\r\n"); |
| | | TEST_IEEE4882("SYST:ERR:NEXT?\r\n", "0,\"No error\"\r\n"); |
| | | |
| | |
| | | TEST_IEEE4882("*WAI\r\n", ""); |
| | | |
| | | TEST_IEEE4882("SYSTem:VERSion?\r\n", "1999.0\r\n"); |
| | | |
| | | TEST_IEEE4882_REG_SET(SCPI_REG_QUES, 1); |
| | | TEST_IEEE4882_REG(SCPI_REG_QUES, 1); |
| | | TEST_IEEE4882("STATus:PRESet\r\n", ""); |
| | | TEST_IEEE4882_REG(SCPI_REG_QUES, 0); |
| | | |
| | | TEST_IEEE4882_REG_SET(SCPI_REG_QUESE, 1); |
| | | TEST_IEEE4882("STATus:QUEStionable:ENABle?\r\n", "1\r\n"); |
| | | TEST_IEEE4882_REG(SCPI_REG_QUESE, 1); |
| | | TEST_IEEE4882("STATus:QUEStionable:ENABle 2\r\n", ""); |
| | | TEST_IEEE4882_REG(SCPI_REG_QUESE, 2); |
| | | |
| | | TEST_IEEE4882("STATus:QUEStionable:EVENt?\r\n", "0\r\n"); |
| | | TEST_IEEE4882_REG_SET(SCPI_REG_QUES, 1); |
| | | TEST_IEEE4882("STATus:QUEStionable:EVENt?\r\n", "1\r\n"); |
| | | TEST_IEEE4882_REG(SCPI_REG_QUES, 0); |
| | | TEST_IEEE4882("STATus:QUEStionable:EVENt?\r\n", "0\r\n"); |
| | | |
| | | TEST_IEEE4882("STUB\r\n", ""); |
| | | TEST_IEEE4882("STUB?\r\n", "0\r\n"); |
| | | } |
| | | |
| | | #define TEST_ParamInt32(data, mandatory, expected_value, expected_result, expected_error_code) \ |
| | |
| | | static void testResultInt32(void) { |
| | | TEST_Result(Int32, 10, "10"); |
| | | TEST_Result(Int32, -10, "-10"); |
| | | TEST_Result(Int32, 2147483647, "2147483647"); |
| | | TEST_Result(Int32, -2147483648, "-2147483648"); |
| | | TEST_Result(Int32, 2147483647L, "2147483647"); |
| | | //TEST_Result(Int32, -2147483648L, "-2147483648"); // bug in GCC |
| | | TEST_Result(Int32, -2147483647L, "-2147483647"); |
| | | } |
| | | |
| | | static void testResultUInt32(void) { |
| | | TEST_Result(UInt32, 10, "10"); |
| | | TEST_Result(UInt32, -10, "4294967286"); |
| | | TEST_Result(UInt32, 2147483647, "2147483647"); |
| | | TEST_Result(UInt32, -2147483648, "2147483648"); |
| | | TEST_Result(UInt32, 4294967295, "4294967295"); |
| | | TEST_Result(UInt32, 2147483647L, "2147483647"); |
| | | //TEST_Result(UInt32, -2147483648L, "2147483648"); // bug in GCC |
| | | TEST_Result(UInt32, -2147483647L, "2147483649"); |
| | | TEST_Result(UInt32, 4294967295UL, "4294967295"); |
| | | |
| | | TEST_ResultBase(UInt32, 0xffffffff, 16, "#HFFFFFFFF"); |
| | | TEST_ResultBase(UInt32, 0xffffffff, 8, "#Q37777777777"); |
| | |
| | | TEST_Result(Int64, -128, "-128"); |
| | | TEST_Result(Int64, 32767, "32767"); |
| | | TEST_Result(Int64, -32768, "-32768"); |
| | | TEST_Result(Int64, 2147483647, "2147483647"); |
| | | TEST_Result(Int64, -2147483648, "-2147483648"); |
| | | TEST_Result(Int64, 2147483647L, "2147483647"); |
| | | //TEST_Result(Int64, -2147483648, "-2147483648"); // bug in gcc |
| | | TEST_Result(Int64, -2147483647L, "-2147483647"); |
| | | TEST_Result(Int64, 9223372036854775807LL, "9223372036854775807"); |
| | | //TEST_Result(Int64, -9223372036854775808LL, "-9223372036854775808"); bug in GCC |
| | | TEST_Result(Int64, -9223372036854775807LL, "-9223372036854775807"); |
| | |
| | | TEST_Result(UInt64, -128, "18446744073709551488"); |
| | | TEST_Result(UInt64, 32767, "32767"); |
| | | TEST_Result(UInt64, -32768, "18446744073709518848"); |
| | | TEST_Result(UInt64, 2147483647, "2147483647"); |
| | | TEST_Result(UInt64, -2147483648, "18446744071562067968"); |
| | | TEST_Result(UInt64, 2147483647L, "2147483647"); |
| | | //TEST_Result(UInt64, -2147483648L, "18446744071562067968"); // bug in GCC |
| | | TEST_Result(UInt64, -2147483647L, "18446744071562067969"); |
| | | TEST_Result(UInt64, 9223372036854775807LL, "9223372036854775807"); |
| | | //TEST_Result(Int64, -9223372036854775808LL, "9223372036854775808"); bug in GCC |
| | | TEST_Result(UInt64, -9223372036854775807LL, "9223372036854775809"); |
| | |
| | | TEST_Result(Float, -128, "-128"); |
| | | TEST_Result(Float, 32767, "32767"); |
| | | TEST_Result(Float, -32768, "-32768"); |
| | | TEST_Result(Float, 2147483647, "2.14748e+09"); |
| | | TEST_Result(Float, -2147483648, "-2.14748e+09"); |
| | | TEST_Result(Float, 2147483647L, "2.14748e+09"); |
| | | //TEST_Result(Float, -2147483648, "-2.14748e+09"); // bug in GCC |
| | | TEST_Result(Float, -2147483647L, "-2.14748e+09"); |
| | | TEST_Result(Float, 9223372036854775807LL, "9.22337e+18"); |
| | | TEST_Result(Float, -9223372036854775807LL, "-9.22337e+18"); |
| | | |
| | |
| | | TEST_Result(Double, 32767, "32767"); |
| | | TEST_Result(Double, -32768, "-32768"); |
| | | TEST_Result(Double, 2147483647, "2147483647"); |
| | | TEST_Result(Double, -2147483648, "-2147483648"); |
| | | //TEST_Result(Double, -2147483648, "-2147483648"); // bug in GCC |
| | | TEST_Result(Double, -2147483647, "-2147483647"); |
| | | TEST_Result(Double, 9223372036854775807LL, "9.22337203685478e+18"); |
| | | TEST_Result(Double, -9223372036854775807LL, "-9.22337203685478e+18"); |
| | | |