From 0c7f101ad0e43c33e8dd1b53f6f6746652236b63 Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 摹曛, 27 8月 2015 23:41:03 +0800
Subject: [PATCH] Update travis script and add build icon to README

---
 libscpi/test/test_parser.c |   51 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/libscpi/test/test_parser.c b/libscpi/test/test_parser.c
index 76a4053..5365f84 100644
--- a/libscpi/test/test_parser.c
+++ b/libscpi/test/test_parser.c
@@ -102,6 +102,7 @@
     err_buffer[0] = 0;
     err_buffer_pos = 0;
 
+    SCPI_RegClearBits(&scpi_context, SCPI_REG_STB, STB_QMA);
     SCPI_EventClear(&scpi_context);
     SCPI_ErrorClear(&scpi_context);
 }
@@ -280,15 +281,17 @@
     
     srq_val = 0;
     TEST_IEEE4882("ABCD\r\n", ""); /* "Undefined header" cause command error */
-    CU_ASSERT_EQUAL(srq_val, 96); /* value of STB as service request */
-    TEST_IEEE4882("*STB?\r\n", "96\r\n"); /* Event status register + Service request */
+    CU_ASSERT_EQUAL(srq_val, (STB_ESR | STB_SRQ | STB_QMA)); /* value of STB as service request */
+    TEST_IEEE4882("*STB?\r\n", "100\r\n"); /* Event status register + Service request */
     TEST_IEEE4882("*ESR?\r\n", "32\r\n"); /* Command error */
 
-    TEST_IEEE4882("*STB?\r\n", "0\r\n");
+    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:NEXT?\r\n", "-113,\"Undefined header\"\r\n");
     TEST_IEEE4882("SYST:ERR:NEXT?\r\n", "0,\"No error\"\r\n");
+
+    TEST_IEEE4882("*STB?\r\n", "0\r\n"); /* Error queue is now empty */
     
     RST_executed = FALSE;
     TEST_IEEE4882("*RST\r\n", "");
@@ -364,6 +367,7 @@
     TEST_ParamDouble("#B101010", TRUE, 42, TRUE, 0);
     TEST_ParamDouble("#H101010", TRUE, 1052688, TRUE, 0);
     TEST_ParamDouble("#Q10", TRUE, 8, TRUE, 0);
+    TEST_ParamDouble("#HFFFFFFFF", TRUE, 0xFFFFFFFFu, TRUE, 0);
 
     TEST_ParamDouble("", TRUE, 0, FALSE, -109); // missing parameter
     TEST_ParamDouble("abcd", TRUE, 0, FALSE, -104); // Data type error
@@ -403,6 +407,40 @@
 }
 
 
+#define TEST_ParamCopyText(data, mandatory, expected_value, expected_len, expected_result, expected_error_code) \
+{                                                                                       \
+    char value[100];                                                                    \
+    size_t value_len;                                                                   \
+    scpi_bool_t result;                                                                 \
+    int16_t errCode;                                                                    \
+                                                                                        \
+    SCPI_CoreCls(&scpi_context);                                                        \
+    scpi_context.input_count = 0;                                                       \
+    scpi_context.param_list.lex_state.buffer = data;                                    \
+    scpi_context.param_list.lex_state.len = strlen(scpi_context.param_list.lex_state.buffer);\
+    scpi_context.param_list.lex_state.pos = scpi_context.param_list.lex_state.buffer;   \
+    result = SCPI_ParamCopyText(&scpi_context, value, sizeof(value), &value_len, mandatory);\
+    /*printf("%.*s\r\n",  (int)value_len, value);*/                                     \
+    errCode = SCPI_ErrorPop(&scpi_context);                                             \
+    CU_ASSERT_EQUAL(result, expected_result);                                           \
+    if (expected_result) {                                                              \
+        CU_ASSERT_STRING_EQUAL(value, expected_value);                                  \
+        CU_ASSERT_EQUAL(value_len, expected_len);                                       \
+    }                                                                                   \
+    CU_ASSERT_EQUAL(errCode, expected_error_code);                                      \
+}
+
+static void testSCPI_ParamCopyText(void) {
+    TEST_ParamCopyText("\'abc\'", TRUE, "abc", 3, TRUE, 0);
+    TEST_ParamCopyText("\"abc\"", TRUE, "abc", 3, TRUE, 0);
+    TEST_ParamCopyText("\'a\'", TRUE, "a", 1, TRUE, 0);
+    TEST_ParamCopyText("\'a\'\'c\'", TRUE, "a\'c", 3, TRUE, 0);
+    TEST_ParamCopyText("\'a\"c\'", TRUE, "a\"c", 3, TRUE, 0);
+    TEST_ParamCopyText("\"a\"\"c\"", TRUE, "a\"c", 3, TRUE, 0);
+    TEST_ParamCopyText("\"a\'c\"", TRUE, "a\'c", 3, TRUE, 0);
+}
+
+
 int main() {
     CU_pSuite pSuite = NULL;
 
@@ -421,9 +459,10 @@
     if ((NULL == CU_add_test(pSuite, "SCPI_ParamInt", testSCPI_ParamInt))
             || (NULL == CU_add_test(pSuite, "SCPI_ParamDouble", testSCPI_ParamDouble))
             || (NULL == CU_add_test(pSuite, "SCPI_ParamCharacters", testSCPI_ParamCharacters))
-	    || (NULL == CU_add_test(pSuite, "Commands handling", testCommandsHandling))
-	    || (NULL == CU_add_test(pSuite, "Error handling", testErrorHandling))
-	    || (NULL == CU_add_test(pSuite, "IEEE 488.2 Mandatory commands", testIEEE4882))
+            || (NULL == CU_add_test(pSuite, "SCPI_ParamCopyText", testSCPI_ParamCopyText))
+            || (NULL == CU_add_test(pSuite, "Commands handling", testCommandsHandling))
+            || (NULL == CU_add_test(pSuite, "Error handling", testErrorHandling))
+            || (NULL == CU_add_test(pSuite, "IEEE 488.2 Mandatory commands", testIEEE4882))
             ) {
         CU_cleanup_registry();
         return CU_get_error();

--
Gitblit v1.9.1