Changeset 12781 for trunk/psLib/test/sys/tap_psStringSubstitute.c
- Timestamp:
- Apr 10, 2007, 11:09:31 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sys/tap_psStringSubstitute.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tap_psStringSubstitute.c
r10446 r12781 11 11 int main (void) 12 12 { 13 psLogSetFormat("HLNM"); 14 psLogSetLevel(PS_LOG_INFO); 13 15 plan_tests(16); 14 16 15 diag("psStringSubstitute() tests");16 17 17 18 // Return input for NULL key 18 19 { 20 psMemId id = psMemGetId(); 19 21 psString input = psStringCopy(ORIGINAL); 20 22 psStringSubstitute(&input, ",", NULL); 21 23 ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input); 22 24 psFree(input); 23 // ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks"); 24 mem(); 25 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 25 26 } 27 26 28 27 29 // Return input for empty key 28 30 { 31 psMemId id = psMemGetId(); 29 32 psString input = psStringCopy(ORIGINAL); 30 33 psStringSubstitute(&input, "XXX", ""); 31 34 ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input); 32 35 psFree(input); 33 // ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks"); 34 mem(); 36 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 35 37 } 38 36 39 37 40 // Return corrected version for NULL replace 38 41 { 42 psMemId id = psMemGetId(); 39 43 psString input = psStringCopy(ORIGINAL); 40 44 psStringSubstitute(&input, NULL, ","); 41 45 ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input); 42 46 psFree(input); 43 mem();47 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 44 48 } 49 45 50 46 51 // Return corrected version for empty replace 47 52 { 53 psMemId id = psMemGetId(); 48 54 psString input = psStringCopy(ORIGINAL); 49 55 psStringSubstitute(&input, "", ","); 50 56 ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input); 51 57 psFree(input); 52 mem();58 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 53 59 } 60 54 61 55 62 // Return NULL for NULL input 56 63 { 64 psMemId id = psMemGetId(); 57 65 int status = psStringSubstitute(NULL, "XXX", ","); 58 66 ok(status == 0, "status = %d", status); 59 mem();67 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 60 68 } 69 61 70 62 71 // Return emptry string for empty input 63 72 { 73 psMemId id = psMemGetId(); 64 74 psString input = psStringCopy(""); 65 75 psStringSubstitute(&input, "XXX", ","); 66 76 ok(input && strcmp(input, "") == 0, "output = %s", input); 67 77 psFree(input); 68 mem();78 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 69 79 } 80 70 81 71 82 // Change commas to bangs 72 83 { 84 psMemId id = psMemGetId(); 73 85 psString input = psStringCopy(ORIGINAL); 74 86 psStringSubstitute(&input, "!", ","); 75 87 ok(input && strcmp(input, "This is! a! test case! to check.") == 0, "output = %s", input); 76 88 psFree(input); 77 mem();89 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 78 90 } 91 79 92 80 93 // Long replacement text --- should allocate new space 81 94 { 95 psMemId id = psMemGetId(); 82 96 psString input = psStringCopy(ORIGINAL); 83 97 psStringSubstitute(&input, "; This string is too long to fit in input(35 chars)", "."); … … 86 100 "output = %s", input); 87 101 psFree(input); 88 mem();102 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 89 103 } 90 91 92 return exit_status();93 104 }
Note:
See TracChangeset
for help on using the changeset viewer.
