|
Atrinik Server 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00026 #include <global.h> 00027 #include <check.h> 00028 00029 static void check_re_cmp(const char *str, const char *regex) 00030 { 00031 fail_if(re_cmp(str, regex) == NULL, "Failed to match '%s' with regex '%s'.", str, regex); 00032 } 00033 00034 START_TEST(test_re_cmp) 00035 { 00036 check_re_cmp("dragon183", "dragon[1-9]+$"); 00037 check_re_cmp("dragon18", "dragon[1-9][1-9]"); 00038 check_re_cmp("dragon18", "dragon[1-2][1-9]$"); 00039 check_re_cmp("dragon18", "dragon[81]+"); 00040 check_re_cmp("treasure", "^treas"); 00041 check_re_cmp("treasure", "^treasure$"); 00042 check_re_cmp("where is treasure", "treasure$"); 00043 check_re_cmp("where is treasure?", "treasure[?.]$"); 00044 } 00045 END_TEST 00046 00047 static Suite *re_cmp_suite() 00048 { 00049 Suite *s = suite_create("re_cmp"); 00050 TCase *tc_core = tcase_create("Core"); 00051 00052 tcase_add_checked_fixture(tc_core, NULL, NULL); 00053 00054 suite_add_tcase(s, tc_core); 00055 tcase_add_test(tc_core, test_re_cmp); 00056 00057 return s; 00058 } 00059 00060 void check_server_re_cmp() 00061 { 00062 Suite *s = re_cmp_suite(); 00063 SRunner *sr = srunner_create(s); 00064 00065 srunner_set_xml(sr, "unit/server/re_cmp.xml"); 00066 srunner_set_log(sr, "unit/server/re_cmp.out"); 00067 srunner_run_all(sr, CK_ENV); 00068 srunner_ntests_failed(sr); 00069 srunner_free(sr); 00070 }
1.7.4