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]);
60 fail_unless(container->
carrying == 0,
"%s has already some carrying?", archs[
a]);
62 container->
stats.
Str = reduction[red];
64 for (i = 0; items[i] != NULL; i++) {
66 fail_unless(
item != NULL,
"couldn't find item %s to put", items[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, carrying, items[i], archs[
a], reduction[red]);
74 for (nrof = 0; add[nrof] != 0; nrof++) {
78 item->nrof = add[nrof];
83 fail_unless(
item->nrof == sum,
"invalid item count %d instead of %d",
item->nrof, sum);
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, 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;