From cb86080b39af49ecff9a60ed47e8ae72993c34cd Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: ćšć, 26 11æ 2015 03:26:06 +0800 Subject: [PATCH] Fix unit test --- libscpi/test/test_parser.c | 63 +++++++++++++++++++++++++------ 1 files changed, 51 insertions(+), 12 deletions(-) diff --git a/libscpi/test/test_parser.c b/libscpi/test/test_parser.c index 3351173..5f37cba 100644 --- a/libscpi/test/test_parser.c +++ b/libscpi/test/test_parser.c @@ -76,6 +76,9 @@ { .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 }; @@ -281,6 +284,15 @@ 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(); @@ -306,6 +318,7 @@ 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"); @@ -320,6 +333,26 @@ 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) \ @@ -901,16 +934,18 @@ 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"); @@ -924,8 +959,9 @@ 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"); @@ -938,8 +974,9 @@ 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"); @@ -957,8 +994,9 @@ 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"); @@ -974,7 +1012,8 @@ 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"); -- Gitblit v1.9.1