Browse Source

add tests for range copying

Julius Pfrommer 7 years ago
parent
commit
fd304f00d9

+ 1 - 1
src/server/ua_services_attribute.c

@@ -37,7 +37,7 @@ readDimension(UA_Byte *buf, size_t buflen, UA_NumericRangeDimension *dim) {
         return 0;
 
     /* invalid range */
-    if(dim->min >= dim->max)
+    if(dim->min > dim->max)
         return 0;
     
     return progress + progress2;

+ 10 - 6
tests/CMakeLists.txt

@@ -28,13 +28,17 @@ endif()
 # the unit test are built directly on the open62541 object files. so they can
 # access symbols that are hidden/not exported to the shared library
 
-add_executable(check_builtin check_builtin.c $<TARGET_OBJECTS:open62541-object>)
-target_link_libraries(check_builtin ${LIBS})
-add_test(builtin ${CMAKE_CURRENT_BINARY_DIR}/check_builtin)
+add_executable(check_types_builtin check_types_builtin.c $<TARGET_OBJECTS:open62541-object>)
+target_link_libraries(check_types_builtin ${LIBS})
+add_test(types_builtin ${CMAKE_CURRENT_BINARY_DIR}/check_types_builtin)
 
-add_executable(check_memory check_memory.c $<TARGET_OBJECTS:open62541-object>)
-target_link_libraries(check_memory ${LIBS})
-add_test(memory ${CMAKE_CURRENT_BINARY_DIR}/check_memory)
+add_executable(check_types_memory check_types_memory.c $<TARGET_OBJECTS:open62541-object>)
+target_link_libraries(check_types_memory ${LIBS})
+add_test(types_memory ${CMAKE_CURRENT_BINARY_DIR}/check_types_memory)
+
+add_executable(check_types_range check_types_range.c $<TARGET_OBJECTS:open62541-object>)
+target_link_libraries(check_types_range ${LIBS})
+add_test(types_range ${CMAKE_CURRENT_BINARY_DIR}/check_types_range)
 
 add_executable(check_chunking check_chunking.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_chunking ${LIBS})

+ 2 - 24
tests/check_services_attributes.c

@@ -16,9 +16,6 @@
 #include <urcu.h>
 #endif
 
-/* copied definition */
-UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range);
-
 static UA_StatusCode
 readCPUTemperature_broken(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp,
                           const UA_NumericRange *range, UA_DataValue *dataValue) {
@@ -1021,21 +1018,6 @@ START_TEST(WriteSingleDataSourceAttributeValue) {
     UA_Server_delete(server);
 } END_TEST
 
-START_TEST(numericRange) {
-    UA_NumericRange range;
-    const UA_String str = (UA_String){9, (UA_Byte*)"1:2,0:3,5"};
-    UA_StatusCode retval = parse_numericrange(&str, &range);
-    ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
-    ck_assert_int_eq(range.dimensionsSize,3);
-    ck_assert_int_eq(range.dimensions[0].min,1);
-    ck_assert_int_eq(range.dimensions[0].max,2);
-    ck_assert_int_eq(range.dimensions[1].min,0);
-    ck_assert_int_eq(range.dimensions[1].max,3);
-    ck_assert_int_eq(range.dimensions[2].min,5);
-    ck_assert_int_eq(range.dimensions[2].max,5);
-    UA_free(range.dimensions);
-} END_TEST
-
 static Suite * testSuite_services_attributes(void) {
     Suite *s = suite_create("services_attributes_read");
 
@@ -1063,8 +1045,8 @@ static Suite * testSuite_services_attributes(void) {
     tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeHistorizingWithoutTimestamp);
     tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeExecutableWithoutTimestamp);
     tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserExecutableWithoutTimestamp);
-        tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestampFromBrokenSource);
-        tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeValueWithoutTimestamp);
+    tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestampFromBrokenSource);
+    tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeValueWithoutTimestamp);
     tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestamp);
     tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp);
 
@@ -1097,10 +1079,6 @@ static Suite * testSuite_services_attributes(void) {
 
     suite_add_tcase(s, tc_writeSingleAttributes);
 
-    TCase *tc_parseNumericRange = tcase_create("parseNumericRange");
-    tcase_add_test(tc_parseNumericRange, numericRange);
-    suite_add_tcase(s, tc_parseNumericRange);
-
     return s;
 }
 

tests/check_builtin.c → tests/check_types_builtin.c


tests/check_memory.c → tests/check_types_memory.c