IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 10, 2007, 11:09:31 AM (19 years ago)
Author:
gusciora
Message:

This is a fairly large checkin. Most of the files were modified so they have
the same basic structure and format for testing: reporting errors, checking
memory leaks etc. Several bug fixes are included as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sys/tap_psStringSubstitute.c

    r10446 r12781  
    1111int main (void)
    1212{
     13    psLogSetFormat("HLNM");
     14    psLogSetLevel(PS_LOG_INFO);
    1315    plan_tests(16);
    1416
    15     diag("psStringSubstitute() tests");
    1617
    1718    // Return input for NULL key
    1819    {
     20        psMemId id = psMemGetId();
    1921        psString input = psStringCopy(ORIGINAL);
    2022        psStringSubstitute(&input, ",", NULL);
    2123        ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input);
    2224        psFree(input);
    23         //        ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks");
    24         mem();
     25        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    2526    }
     27
    2628
    2729    // Return input for empty key
    2830    {
     31        psMemId id = psMemGetId();
    2932        psString input = psStringCopy(ORIGINAL);
    3033        psStringSubstitute(&input, "XXX", "");
    3134        ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input);
    3235        psFree(input);
    33         //        ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks");
    34         mem();
     36        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    3537    }
     38
    3639
    3740    // Return corrected version for NULL replace
    3841    {
     42        psMemId id = psMemGetId();
    3943        psString input = psStringCopy(ORIGINAL);
    4044        psStringSubstitute(&input, NULL, ",");
    4145        ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input);
    4246        psFree(input);
    43         mem();
     47        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    4448    }
     49
    4550
    4651    // Return corrected version for empty replace
    4752    {
     53        psMemId id = psMemGetId();
    4854        psString input = psStringCopy(ORIGINAL);
    4955        psStringSubstitute(&input, "", ",");
    5056        ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input);
    5157        psFree(input);
    52         mem();
     58        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    5359    }
     60
    5461
    5562    // Return NULL for NULL input
    5663    {
     64        psMemId id = psMemGetId();
    5765        int status = psStringSubstitute(NULL, "XXX", ",");
    5866        ok(status == 0, "status = %d", status);
    59         mem();
     67        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    6068    }
     69
    6170
    6271    // Return emptry string for empty input
    6372    {
     73        psMemId id = psMemGetId();
    6474        psString input = psStringCopy("");
    6575        psStringSubstitute(&input, "XXX", ",");
    6676        ok(input && strcmp(input, "") == 0, "output = %s", input);
    6777        psFree(input);
    68         mem();
     78        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    6979    }
     80
    7081
    7182    // Change commas to bangs
    7283    {
     84        psMemId id = psMemGetId();
    7385        psString input = psStringCopy(ORIGINAL);
    7486        psStringSubstitute(&input, "!", ",");
    7587        ok(input && strcmp(input, "This is! a! test case! to check.") == 0, "output = %s", input);
    7688        psFree(input);
    77         mem();
     89        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    7890    }
     91
    7992
    8093    // Long replacement text --- should allocate new space
    8194    {
     95        psMemId id = psMemGetId();
    8296        psString input = psStringCopy(ORIGINAL);
    8397        psStringSubstitute(&input, "; This string is too long to fit in input(35 chars)", ".");
     
    86100           "output = %s", input);
    87101        psFree(input);
    88         mem();
     102        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    89103    }
    90 
    91 
    92     return exit_status();
    93104}
Note: See TracChangeset for help on using the changeset viewer.