Atrinik Server  4.0
sound_ambient.c
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
25 #include <global.h>
26 #include <check.h>
27 #include <checkstd.h>
28 #include <check_proto.h>
29 #include <stdarg.h>
30 #include <arch.h>
31 #include <object.h>
32 #include <sound_ambient.h>
33 
34 START_TEST(test_sound_ambient_match_parse)
35 {
36  object *ob;
37  const char *match[] = {
38  "hour == 1",
39  "hour > 1",
40  "hour < 1",
41  "hour >= 1",
42  "hour <= 1",
43 
44  "minute == 5",
45  "minute > 5",
46  "minute < 5",
47  "minute >= 5",
48  "minute <= 5",
49 
50  "hour + 5 == 1",
51  "hour - 5 > 1",
52  "hour * 5 < 1",
53  "hour / 5 >= 1",
54  "hour % 5 <= 1",
55 
56  "hour == 1 && minute == 5",
57  "hour > 1 && minute > 5",
58  "hour < 1 && minute < 5",
59  "hour >= 1 && minute >= 5",
60  "hour <= 1 && minute <= 5",
61 
62  "hour == 1 || minute == 5",
63  "hour > 1 || minute > 5",
64  "hour < 1 || minute < 5",
65  "hour >= 1 || minute >= 5",
66  "hour <= 1 || minute <= 5",
67 
68  "(hour == 1 || minute == 5)",
69  "((hour == 1 || minute == 5))",
70  "(hour == 1 || (minute == 5))",
71  "((hour == 1) || minute == 5)",
72  "((hour == 1) || (minute == 5))",
73  "(hour == 1) || (minute == 5)",
74 
75  "hour < 10 && ((minute > 5 && hour < 1) || "
76  "(minute < 10 && minute > 10)) && hour > 1",
77  "(minute > 5 || minute < 10) && hour < 10 && hour > 1",
78 
79  NULL};
80  size_t i;
81 
82  ob = arch_get("sound_ambient");
83  ck_assert_ptr_ne(ob, NULL);
84 
85  for (i = 0; match[i] != NULL; i++) {
86  sound_ambient_match_parse(ob, match[i]);
87  ck_assert_str_eq(match[i], sound_ambient_match_str(ob));
88  }
89 
90  object_destroy(ob);
91 }
92 
93 END_TEST
94 
95 static Suite *suite(void)
96 {
97  Suite *s = suite_create("sound_ambient");
98  TCase *tc_core = tcase_create("Core");
99 
100  tcase_add_unchecked_fixture(tc_core, check_setup, check_teardown);
101  tcase_add_checked_fixture(tc_core, check_test_setup, check_test_teardown);
102 
103  suite_add_tcase(s, tc_core);
104  tcase_add_test(tc_core, test_sound_ambient_match_parse);
105 
106  return s;
107 }
108 
109 void check_types_sound_ambient(void)
110 {
111  check_run_suite(suite(), __FILE__);
112 }
void object_destroy(object *ob)
Definition: object.c:1441
object * arch_get(const char *name)
Definition: arch.c:430
const char * sound_ambient_match_str(object *op)
void sound_ambient_match_parse(object *op, const char *str)