[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.3

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