Changeset 815 for trunk/superstring/source/test.c
- Timestamp:
- 03/28/08 22:32:22 (4 years ago)
- File:
-
- 1 edited
-
trunk/superstring/source/test.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/superstring/source/test.c
r812 r815 29 29 void test_anonymous(void); 30 30 void test_compare(void); 31 void test_setchar(void); 32 void test_append(void); 31 33 32 34 #define TEST_INIT_VALUE "Hello, world!" … … 156 158 } 157 159 160 void test_setchar(void) { 161 superstring str = ss_create(TEST_INIT_VALUE); 162 163 tassert(ss_char(str, 0) == TEST_INIT_VALUE[0]); 164 tassert(ss_setchar(str, 0, 'y') == SS_ERROR_SUCCESS); 165 tassert(ss_char(str, 0) == 'y'); 166 tassert(ss_char(str, 0) != TEST_INIT_VALUE[0]); 167 168 tassert(ss_setchar(str, 1024, '!') == SS_ERROR_INVALID_PARAMETER); 169 } 170 171 void test_append(void) { 172 superstring str = ss_create("abc"); 173 superstring str2 = ss_create("123"); 174 175 tassert(ss_append(&str, NULL) == SS_ERROR_INVALID_PARAMETER); 176 tassert(ss_append(&str, str2) == SS_ERROR_SUCCESS); 177 tassert(ss_compare_cs(str, "abc123") == 0); 178 ss_destroy(&str); 179 ss_destroy(&str2); 180 181 /* test an allocation which forces growth */ 182 size_t len; 183 str = ss_create("abc"); 184 len = ss_length(str); 185 for (int i = 0;i < 100;i++) { 186 tassert(ss_append_cs(&str, "123") == SS_ERROR_SUCCESS); 187 len += 3; /* length should grow by 3 .. */ 188 } 189 tassert(ss_length(str) == len); 190 191 ss_destroy(&str); 192 } 193 158 194 int main(void) { 159 195 … … 162 198 runtest(anonymous); 163 199 runtest(compare); 200 runtest(setchar); 201 runtest(append); 164 202 165 203 /* If we made it here we are at the end! Let them know we succeeded. */
Note: See TracChangeset
for help on using the changeset viewer.
