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 | 41 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 38 insertions(+), 3 deletions(-) diff --git a/libscpi/test/test_parser.c b/libscpi/test/test_parser.c index 4b3111d..5365f84 100644 --- a/libscpi/test/test_parser.c +++ b/libscpi/test/test_parser.c @@ -407,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; @@ -425,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