Convert varint test to use the new ASSERT_STRING_EQUAL macro
authorSandro Santilli <strk@keybit.net>
Wed, 10 Jun 2015 23:27:52 +0000 (23:27 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 10 Jun 2015 23:27:52 +0000 (23:27 +0000)
Also drops manual "strcmp" calls from it.

git-svn-id: http://svn.osgeo.org/postgis/trunk@13645 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_varint.c

index 049d4bb8f289e6b045798d02e2c0004c77757bcf..aaa5505299c0aab7af1b244a18c20d8bc267a08c 100644 (file)
@@ -44,10 +44,7 @@ static void do_test_u32_varint(uint32_t nr, int expected_size, char* expected_re
        CU_ASSERT_EQUAL(size, expected_size);
        
        hex = hexbytes_from_bytes(buf, size);
-       if ( strcmp(hex, expected_res) ) 
-               printf("Expected: %s\nObtained: %s\n", expected_res, hex);
-
-       CU_ASSERT_STRING_EQUAL(hex, expected_res);      
+       ASSERT_STRING_EQUAL(hex, expected_res); 
        lwfree(hex);
 }
 
@@ -65,11 +62,7 @@ static void do_test_s32_varint(int32_t nr,int expected_size, char* expected_res)
        CU_ASSERT_EQUAL(size,expected_size);
 
        hex = hexbytes_from_bytes(buf, size);
-       if ( strcmp(hex,expected_res) ) 
-       {
-               printf("Expected: %s\nObtained: %s\n", expected_res, hex);
-       }
-       CU_ASSERT_STRING_EQUAL(hex, expected_res);      
+       ASSERT_STRING_EQUAL(hex, expected_res); 
        lwfree(hex);
 }
 
@@ -87,11 +80,7 @@ static void do_test_u64_varint(uint64_t nr,int expected_size, char* expected_res
        CU_ASSERT_EQUAL(size,expected_size);
 
        hex = hexbytes_from_bytes(buf,size);
-       if ( strcmp(hex,expected_res) ) 
-       {
-               printf("Expected: %s\nObtained: %s\n", expected_res, hex);
-       }
-       CU_ASSERT_STRING_EQUAL(hex, expected_res);
+       ASSERT_STRING_EQUAL(hex, expected_res);
        lwfree(hex);
 }
 
@@ -109,11 +98,7 @@ static void do_test_s64_varint(int64_t nr,int expected_size, char* expected_res)
        CU_ASSERT_EQUAL(size,expected_size);
        
        hex = hexbytes_from_bytes(buf,size);
-       if ( strcmp(hex,expected_res) ) 
-       {
-               printf("Expected: %s\nObtained: %s\n", expected_res, hex);
-       }
-       CU_ASSERT_STRING_EQUAL(hex, expected_res);      
+       ASSERT_STRING_EQUAL(hex, expected_res); 
        lwfree(hex);
 }
 
@@ -123,7 +108,7 @@ static void test_varint(void)
        do_test_u64_varint(1, 1, "01");
        do_test_u64_varint(300, 2, "AC02");
        do_test_u64_varint(150, 2, "9601");
-       do_test_u64_varint(240, 2, "F001"); 
+       do_test_u64_varint(240, 2, "F001");
        do_test_u64_varint(0x4000, 3, "808001");
   /*
                 0100:0000 0000:0000 - input (0x4000)