[BACK]Return to regress.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/regress.c, Revision 1.2

1.2     ! espie       1: /* $OpenBSD: regress.c,v 1.1 2000/07/17 23:01:20 espie Exp $ */
1.1       espie       2:
                      3: /*
                      4:  * Copyright (c) 1999 Marc Espie.
                      5:  *
                      6:  * Code written for the OpenBSD project.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  *
                     17:  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
                     18:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
                     19:  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
                     20:  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
                     21:  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     22:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
                     23:  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     24:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     25:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     26:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
                     27:  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     28:  */
                     29:
                     30: /* regression tests */
                     31: #include "make.h"
                     32: #include <stdio.h>
                     33:
                     34: int main __P((void));
                     35: #define CHECK(s)               \
                     36: do {                           \
                     37:     printf("%-65s", #s);       \
                     38:     if (s)                     \
                     39:        printf("ok\n");         \
                     40:     else {                     \
                     41:        printf("failed\n");     \
                     42:        errors++;               \
                     43:     }                          \
                     44: } while (0);
                     45:
1.2     ! espie      46: int
        !            47: main()
1.1       espie      48: {
1.2     ! espie      49:     unsigned int errors = 0;
1.1       espie      50:
1.2     ! espie      51:     CHECK(Str_Match("string", "string") == TRUE);
        !            52:     CHECK(Str_Match("string", "string2") == FALSE);
        !            53:     CHECK(Str_Match("string", "string*") == TRUE);
        !            54:     CHECK(Str_Match("Long string", "Lo*ng") == TRUE);
        !            55:     CHECK(Str_Match("Long string", "Lo*ng ") == FALSE);
        !            56:     CHECK(Str_Match("Long string", "Lo*ng *") == TRUE);
        !            57:     CHECK(Str_Match("string", "stri?g") == TRUE);
        !            58:     CHECK(Str_Match("str?ng", "str\\?ng") == TRUE);
        !            59:     CHECK(Str_Match("striiiing", "str?*ng") == TRUE);
        !            60:     CHECK(Str_Match("Very long string just to see", "******a****") == FALSE);
        !            61:     CHECK(Str_Match("d[abc?", "d\\[abc\\?") == TRUE);
        !            62:     CHECK(Str_Match("d[abc!", "d\\[abc\\?") == FALSE);
        !            63:     CHECK(Str_Match("dwabc?", "d\\[abc\\?") == FALSE);
        !            64:     CHECK(Str_Match("da0", "d[bcda]0") == TRUE);
        !            65:     CHECK(Str_Match("da0", "d[z-a]0") == TRUE);
        !            66:     CHECK(Str_Match("d-0", "d[-a-z]0") == TRUE);
        !            67:     CHECK(Str_Match("dy0", "d[a\\-z]0") == FALSE);
        !            68:     CHECK(Str_Match("d-0", "d[a\\-z]0") == TRUE);
        !            69:     CHECK(Str_Match("dz0", "d[a\\]z]0") == TRUE);
1.1       espie      70:
                     71:     if (errors != 0)
                     72:        printf("Errors: %d\n", errors);
                     73:     exit(0);
                     74: }
                     75:
                     76: