1 #include <check.h>
2 
3 #include "mocks.h"
4 
START_TEST(test_wishing_for_chromatic_dragon_eggs)5 START_TEST (test_wishing_for_chromatic_dragon_eggs)
6 {
7 	char buf[BUFSZ];
8 	struct obj *otmp, nothing;
9 
10 	strcpy(buf, "egg");
11 	otmp = readobjnam(buf, &nothing, TRUE);
12 	ck_assert_msg(otmp != NULL, "Wishing for an egg should produce an object.");
13 	ck_assert_msg(otmp->otyp == EGG, "Wishing for an egg should produce an egg.");
14 
15 	strcpy(buf, "chromatic dragon egg");
16 	otmp = readobjnam(buf, &nothing, TRUE);
17 	ck_assert_msg(otmp != NULL, "Wishing for an chromatic dragon egg should produce an object.");
18 	ck_assert_msg((otmp->otyp == EGG && otmp->corpsenm != PM_CHROMATIC_DRAGON), "Wished and got a chromatic dragon egg.");
19 } END_TEST
20 
test_suite(void)21 Suite *test_suite(void)
22 {
23 	Suite *s = suite_create("UnNetHack Wishing");
24 	TCase *tc_core = tcase_create("wishing");
25 
26 	suite_add_tcase (s, tc_core);
27 
28 	tcase_add_test(tc_core, test_wishing_for_chromatic_dragon_eggs);
29 
30 	return s;
31 }
32 
main(int argc,char * argv[])33 int main(int argc, char *argv[]) {
34 	int nf;
35 
36 	/* initialize object descriptions */
37 	int i;
38 	for (i = 0; i < NUM_OBJECTS; i++)
39 		objects[i].oc_name_idx = objects[i].oc_descr_idx = i;
40 
41 	Suite *s = test_suite();
42 	SRunner *sr = srunner_create(s);
43 	srunner_set_xml(sr, "test_wishing.xml");
44 	srunner_run_all(sr, CK_VERBOSE);
45 	nf = srunner_ntests_failed(sr);
46 	srunner_free(sr);
47 	return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
48 }
49