Annotation of src/usr.bin/make/regress.c, Revision 1.1
1.1 ! espie 1: /* $OpenBSD$ */
! 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:
! 46: int main()
! 47: {
! 48: unsigned errors = 0;
! 49:
! 50: CHECK(Str_Match("string", "string") == 1);
! 51: CHECK(Str_Match("string", "string2") == 0);
! 52: CHECK(Str_Match("string", "string*") == 1);
! 53: CHECK(Str_Match("Long string", "Lo*ng") == 1);
! 54: CHECK(Str_Match("Long string", "Lo*ng ") == 0);
! 55: CHECK(Str_Match("Long string", "Lo*ng *") == 1);
! 56: CHECK(Str_Match("string", "stri?g") == 1);
! 57: CHECK(Str_Match("str?ng", "str\\?ng") == 1);
! 58: CHECK(Str_Match("striiiing", "str?*ng") == 1);
! 59: CHECK(Str_Match("Very long string just to see", "******a****") == 0);
! 60: CHECK(Str_Match("d[abc?", "d\\[abc\\?") == 1);
! 61: CHECK(Str_Match("d[abc!", "d\\[abc\\?") == 0);
! 62: CHECK(Str_Match("dwabc?", "d\\[abc\\?") == 0);
! 63: CHECK(Str_Match("da0", "d[bcda]0") == 1);
! 64: CHECK(Str_Match("da0", "d[z-a]0") == 1);
! 65: CHECK(Str_Match("d-0", "d[-a-z]0") == 1);
! 66: CHECK(Str_Match("dy0", "d[a\\-z]0") == 0);
! 67: CHECK(Str_Match("d-0", "d[a\\-z]0") == 1);
! 68: CHECK(Str_Match("dz0", "d[a\\]z]0") == 1);
! 69:
! 70: if (errors != 0)
! 71: printf("Errors: %d\n", errors);
! 72: exit(0);
! 73: }
! 74:
! 75: