Changeset 4559

Show
Ignore:
Timestamp:
02/09/07 20:31:49 (2 years ago)
Author:
morris
Message:

Add more test cases

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/test/tests/wi-string-tests.c

    r4556 r4559  
    3030 
    3131WI_TEST_EXPORT void                                     wi_test_string_case(void); 
    32 WI_TEST_EXPORT void                                     wi_test_string_conversions(void); 
     32WI_TEST_EXPORT void                                     wi_test_string_constant(void); 
     33WI_TEST_EXPORT void                                     wi_test_string_compare(void); 
     34WI_TEST_EXPORT void                                     wi_test_string_data_conversions(void); 
     35WI_TEST_EXPORT void                                     wi_test_string_length(void); 
     36WI_TEST_EXPORT void                                     wi_test_string_format(void); 
     37WI_TEST_EXPORT void                                     wi_test_string_numeric_conversions(void); 
    3338WI_TEST_EXPORT void                                     wi_test_string_paths(void); 
    3439 
     
    4651 
    4752 
    48 void wi_test_string_conversions(void) { 
     53void wi_test_string_constant(void) { 
     54        WI_TEST_ASSERT_EQUALS( 
     55                WI_STR("hello world"), 
     56                WI_STR("hello world"), 
     57                "WI_STR()"); 
     58 
     59        WI_TEST_ASSERT_TRUE( 
     60                WI_STR("hello world") != WI_STR("hello another world"), 
     61                "WI_STR()"); 
     62
     63 
     64 
     65 
     66void wi_test_string_compare(void) { 
     67        WI_TEST_ASSERT_TRUE( 
     68                wi_is_equal( 
     69                        wi_string_with_cstring("hello world"), 
     70                        wi_string_with_cstring("hello world")), 
     71                "wi_is_equal()"); 
     72 
     73        WI_TEST_ASSERT_FALSE( 
     74                wi_is_equal( 
     75                        wi_string_with_cstring("hello world"), 
     76                        wi_string_with_cstring("hello another world")), 
     77                "wi_is_equal()"); 
     78 
     79        WI_TEST_ASSERT_TRUE( 
     80                wi_string_compare( 
     81                        wi_string_with_cstring("hello world"), 
     82                        wi_string_with_cstring("hello world")) 
     83                        == 0, 
     84                "wi_string_compare()"); 
     85 
     86        WI_TEST_ASSERT_FALSE( 
     87                wi_string_compare( 
     88                        wi_string_with_cstring("hello world"), 
     89                        wi_string_with_cstring("Hello world")) 
     90                        == 0, 
     91                "wi_string_compare()"); 
     92 
     93        WI_TEST_ASSERT_FALSE( 
     94                wi_string_compare( 
     95                        wi_string_with_cstring("hello world"), 
     96                        wi_string_with_cstring("hello another world")) 
     97                        == 0, 
     98                "wi_string_compare()"); 
     99 
     100        WI_TEST_ASSERT_TRUE( 
     101                wi_string_case_insensitive_compare( 
     102                        wi_string_with_cstring("hello world"), 
     103                        wi_string_with_cstring("Hello world")) 
     104                        == 0, 
     105                "wi_string_case_insensitive_compare()"); 
     106 
     107        WI_TEST_ASSERT_FALSE( 
     108                wi_string_case_insensitive_compare( 
     109                        wi_string_with_cstring("hello world"), 
     110                        wi_string_with_cstring("Hello another world")) 
     111                        == 0, 
     112                "wi_string_case_insensitive_compare()"); 
     113
     114 
     115 
     116 
     117void wi_test_string_data_conversions(void) { 
     118        WI_TEST_ASSERT_EQUAL_INSTANCES( 
     119                wi_string_md5(WI_STR("hello world")), 
     120                WI_STR("5eb63bbbe01eeed093cb22bb8f5acdc3"), 
     121                "wi_string_md5()"); 
     122 
     123        WI_TEST_ASSERT_EQUAL_INSTANCES( 
     124                wi_string_sha1(WI_STR("hello world")), 
     125                WI_STR("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"), 
     126                "wi_string_sha1()"); 
     127 
     128        WI_TEST_ASSERT_EQUAL_INSTANCES( 
     129                wi_string_base64(WI_STR("hello world")), 
     130                WI_STR("aGVsbG8gd29ybGQ="), 
     131                "wi_string_base64()"); 
     132 
     133        WI_TEST_ASSERT_EQUAL_INSTANCES( 
     134                wi_autorelease(wi_string_init_with_base64(wi_string_alloc(), WI_STR("aGVsbG8gd29ybGQ="))), 
     135                WI_STR("hello world"), 
     136                "wi_string_init_with_base64()"); 
     137
     138 
     139 
     140 
     141void wi_test_string_format(void) { 
     142        WI_TEST_ASSERT_EQUAL_INSTANCES( 
     143                wi_string_with_format(WI_STR("'%d' '%u' '%p' '%.5f' '%@' '%@' '%#@' '%s' '%s' '%#s'"), 
     144                        -5, 5, 0xAC1DFEED, 3.1415926, WI_STR("hello world"), NULL, NULL, "hello world", NULL, NULL), 
     145                WI_STR("'-5' '5' '0xac1dfeed' '3.14159' 'hello world' '(null)' '' 'hello world' '(null)' ''"), 
     146                "wi_string_with_format()"); 
     147
     148 
     149 
     150 
     151void wi_test_string_length(void) { 
     152        WI_TEST_ASSERT_EQUALS( 
     153                wi_string_length(WI_STR("")), 
     154                0U, 
     155                "wi_string_length()"); 
     156 
     157        WI_TEST_ASSERT_EQUALS( 
     158                wi_string_length(WI_STR("hello world")), 
     159                11U, 
     160                "wi_string_length()"); 
     161
     162 
     163 
     164 
     165void wi_test_string_numeric_conversions(void) { 
    49166        WI_TEST_ASSERT_EQUALS( 
    50167                wi_string_bool(WI_STR("yes")),