43 const int reduction[] = { 0, 30, 50, 70, -1 };
45 const char *archs[] = {
"sack",
"luggage",
"luggage",
"luggage", NULL };
47 const char *items[] = {
"scroll",
"crown",
"gem",
"tooth", NULL };
49 const int add[] = { 2, 5, 7, 3, 3, 9, -5, -7, 11, -8, -9, -11, 0 };
53 object *container, *
item;
55 for (red = 0; reduction[red] != -1; red++) {
56 for (
a = 0; archs[
a] != NULL;
a++) {
58 FAIL_UNLESS(container != NULL,
"couldn't find container arch %s!", archs[
a]);
62 container->
stats.
Str = reduction[red];
64 for (i = 0; items[i] != NULL; i++) {
67 FAIL_UNLESS(
item->nrof == 1,
"can't test item %s with nrof != 1", items[i]);
71 carrying = (
signed long)(
item->weight * (100 - container->
stats.
Str) / 100);
72 FAIL_UNLESS(container->
carrying == carrying,
"invalid weight %d instead of %d for %s in %s reduction %d!", container->
carrying,
int(carrying), items[i], archs[
a], reduction[red]);
74 for (nrof = 0; add[nrof] != 0; nrof++) {
78 item->nrof = add[nrof];
84 carrying = (
signed long)(
item->nrof *
item->weight * (100 - container->
stats.
Str) / 100);
85 FAIL_UNLESS(container->
carrying == carrying,
"invalid weight %d instead of %d for %s in %s reduction %d after adding %d!", container->
carrying,
int(carrying), items[i], archs[
a], reduction[red], add[nrof]);
89 FAIL_UNLESS(container->
carrying == 0,
"container %s is still carrying %d from %s instead of 0!", archs[
a], container->
carrying, items[i]);
98 Suite *s = suite_create(
"bug");
99 TCase *tc_core = tcase_create(
"Core");
103 suite_add_tcase(s, tc_core);
104 tcase_add_test(tc_core, test_weight_reduction);
105 tcase_set_timeout(tc_core, 0);
113 SRunner *sr = srunner_create(s);
115 srunner_set_fork_status(sr, CK_NOFORK);
119 srunner_set_xml(sr, LOGDIR
"/bugs/bugtrack/weight_reduction.xml");
120 srunner_set_log(sr, LOGDIR
"/bugs/bugtrack/weight_reduction.out");
121 srunner_run_all(sr, CK_ENV);
122 nf = srunner_ntests_failed(sr);
124 return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE;