1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
|
/*
* static char *rcsid_check_object_c =
* "$Id$";
*/
/*
* CrossFire, A Multiplayer game for X-windows
*
* Copyright (C) 2002 Mark Wedel & Crossfire Development Team
* Copyright (C) 1992 Frank Tore Johansen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* The authors can be reached via e-mail at crossfire-devel@real-time.com
*/
/*
* This is the unit tests file for common/object.c
*/
#include <global.h>
#include <stdlib.h>
#include <check.h>
#include <loader.h>
#include <toolkit_common.h>
#include "stringbuffer.h"
static void setup(void) {
cctk_setdatadir(BUILD_ROOT "lib");
cctk_setlog(LOGDIR "/unit/common/object.out");
printf("set log to %s\n", LOGDIR"/unit/common/object.out");
cctk_init_std_archetypes();
}
static void teardown(void) {
/* put any cleanup steps here, they will be run after each testcase */
}
/*
* Things to check
* object_update_turn_face
* object_update_speed
* object_remove_from_active_list
* object_update
* object_free_drop_inventory
* object_count_free
* object_count_used
* object_count_active
* object_sub_weight
* object_remove
* object_merge
* object_insert_in_map_at
* object_insert_in_map
* object_replace_insert_in_map
* object_split
* object_decrease_nrof
* object_add_weight
* object_insert_in_ob
* object_check_move_on
* map_find_by_archetype
* map_find_by_type
* object_present_in_ob
* object_present_in_ob_by_name
* arch_present_in_ob
* object_set_flag_inv
* object_unset_flag_inv
* object_set_cheat
* object_find_free_spot
* object_find_first_free_spot
* get_search_arr
* map_find_dir
* object_distance
* find_dir_2
* absdir
* dirdiff
* can_see_monsterP
* object_can_pick
* object_create_clone
* object_was_destroyed
* object_find_by_type_subtype
* object_get_key_value
* object_get_value
* object_set_value
* object_matches_string
*/
/** This is the test to check the behaviour of the method
* int object_can_merge(object *ob1, object *ob2);
*/
START_TEST(test_object_can_merge) {
object *ob1;
object *ob2;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
fail_unless(object_can_merge(ob1, ob2), "Should be able to merge 2 same object");
ob2->name = add_string("Not same name");
fail_unless(!object_can_merge(ob1, ob2), "Should not be able to merge 2 object with different names");
ob2 = cctk_create_game_object(NULL);
ob2->type++;
fail_unless(!object_can_merge(ob1, ob2), "Should not be able to merge 2 object with different types");
ob2 = cctk_create_game_object(NULL);
ob1->nrof = (1UL<<31)-1;
ob2->nrof = 1;
fail_unless(!object_can_merge(ob1, ob2), "Should not be able to merge 2 object if result nrof goes to 1<<31 or higher");
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* signed long object_sum_weight(object *op);
*/
START_TEST(test_object_sum_weight) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
unsigned long sum;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
ob1->weight = 10; /*This should not be taken into account by object_sum_weight*/
ob1->type = CONTAINER;
ob1->stats.Str = 40; /*40% reduction of weight*/
ob2->weight = 6;
ob2->nrof = 10;
ob3->weight = 7;
ob4->weight = 8;
object_insert_in_ob(ob2, ob1);
object_insert_in_ob(ob3, ob1);
object_insert_in_ob(ob4, ob1);
sum = object_sum_weight(ob1);
fail_unless(sum == 45, "Sum of object's inventory should be 45 ((6*10+7+8)*.6) but was %lu.", sum);
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_get_env_recursive(object *op);
*/
START_TEST(test_object_get_env_recursive) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
object *result;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
object_insert_in_ob(ob2, ob1);
object_insert_in_ob(ob3, ob2);
object_insert_in_ob(ob4, ob3);
result = object_get_env_recursive(ob4);
fail_unless(result == ob1, "Getting top level container for ob4(%p) should bring ob1(%p) but brought %p.", ob4, ob1, result);
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_get_player_container(object *op);
*/
START_TEST(test_object_get_player_container) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
object *result;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
object_insert_in_ob(ob2, ob1);
object_insert_in_ob(ob3, ob2);
object_insert_in_ob(ob4, ob3);
result = object_get_player_container(ob4);
fail_unless(result == NULL, "Getting containing player for ob4(%p) should bring NULL but brought %p while not contained in a player.", ob4, result);
ob1->type = PLAYER;
result = object_get_player_container(ob4);
fail_unless(result == ob1, "Getting containing player for ob4(%p) should bring ob1(%p) but brought %p while ob1 is player.", ob4, ob1, result);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_dump(object *op);
*/
START_TEST(test_object_dump) {
object *ob1;
object *ob2;
object *ob3;
StringBuffer *sb;
char *result;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
object_insert_in_ob(ob2, ob1);
object_insert_in_ob(ob3, ob2);
sb = stringbuffer_new();
object_dump(ob1, sb);
result = stringbuffer_finish(sb);
fail_unless(strstr(result, "arch") != NULL, "The object dump should contain 'arch' but was %s", sb);
free(result);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_dump_all(void);
*/
START_TEST(test_object_dump_all) {
cctk_create_game_object(NULL);
cctk_create_game_object(NULL);
cctk_create_game_object(NULL);
object_dump_all(); /*Should not crash, that all i can test*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_find_by_tag_global(tag_t i);
*/
START_TEST(test_object_find_by_tag_global) {
object *ob1;
object *result;
cctk_create_game_object(NULL);
cctk_create_game_object(NULL);
ob1 = cctk_create_game_object(NULL);
result = object_find_by_tag_global(ob1->count);
fail_unless(result == ob1, "Should find ob1(%p) while search for item %d but got %p", ob1, ob1->count, result);
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_find_by_name_global(const char *str);
*/
START_TEST(test_object_find_by_name_global) {
object *ob1;
object *result;
ob1 = cctk_create_game_object(NULL);
ob1->name = add_string("This is a name");
ob1 = cctk_create_game_object(NULL);
ob1->name = add_string("This is another name");
ob1 = cctk_create_game_object(NULL);
ob1->name = add_string("This is the key name");
result = object_find_by_name_global(add_string("This is the key name"));
fail_unless(result == ob1, "Searching for object with name 'This is the key name' returned %p(%s) instead of ob1(%p)", result, result ? result->name : "null", ob1);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_free_all_data(void);
*/
START_TEST(test_object_free_all_data) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_get_owner(object *op);
*/
START_TEST(test_object_get_owner) {
object *ob1;
object *ob2;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
object_set_owner(ob2, ob1);
CLEAR_FLAG(ob1, FLAG_REMOVED);
CLEAR_FLAG(ob2, FLAG_REMOVED);
fail_unless(object_get_owner(ob2) == ob1, "Owner of ob2(%p) shoud be ob1(%p) but was %p", ob2, ob1, object_get_owner(ob2));
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_clear_owner(object *op);
*/
START_TEST(test_object_clear_owner) {
object *ob1;
object *ob2;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
object_set_owner(ob2, ob1);
fail_unless(ob2->owner != NULL, "Prior to testing object_clear_owner, owner of ob2 was wrongly initialized"); /* XXX: use object_get_owner() */
object_clear_owner(ob2);
fail_unless(ob2->owner == NULL, "After object_clear_owner ob2 still had an owner"); /* XXX: use object_get_owner() */
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_set_owner(object *op, object *owner);
*/
START_TEST(test_object_set_owner) {
object *ob1;
object *ob2;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
object_set_owner(ob2, ob1);
fail_unless(ob2->owner == ob1, "After object_set_owner ob2(%p) owner should be ob1(%p) but was (%p)", ob2, ob1, ob2->owner); /* XXX: use object_get_owner() */
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_copy_owner(object *op, object *clone);
*/
START_TEST(test_object_copy_owner) {
object *ob1;
object *ob2;
object *ob3;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
object_set_owner(ob2, ob1);
object_copy_owner(ob3, ob2);
fail_unless(object_get_owner(ob2) == object_get_owner(ob3), "After object_copy_owner, ob3 and ob2 should have same owner (ob1=%p) but got %p and %p", object_get_owner(ob3), object_get_owner(ob2));
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_reset(object *op);
*/
START_TEST(test_object_reset) {
object *ob1;
ob1 = cctk_create_game_object(NULL);
object_reset(ob1);
fail_unless(ob1->name == NULL, "Field name of ob1 was not NULLified by object_reset");
fail_unless(ob1->name_pl == NULL, "Field name_pl of ob1 was not NULLified by object_reset");
fail_unless(ob1->title == NULL, "Field title of ob1 was not NULLified by object_reset");
fail_unless(ob1->race == NULL, "Field race of ob1 was not NULLified by object_reset");
fail_unless(ob1->slaying == NULL, "Field slaying of ob1 was not NULLified by object_reset");
fail_unless(ob1->skill == NULL, "Field skill of ob1 was not NULLified by object_reset");
fail_unless(ob1->msg == NULL, "Field msg of ob1 was not NULLified by object_reset");
fail_unless(ob1->materialname == NULL, "Field materialname of ob1 was not NULLified by object_reset");
fail_unless(ob1->lore == NULL, "Field lore of ob1 was not NULLified by object_reset");
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_clear(object *op);
*/
START_TEST(test_object_clear) {
object *ob1;
const char *reference;
ob1 = cctk_create_game_object(NULL);
cctk_set_object_strings(ob1, "This is a test String");
reference = add_string("This is a test String");
object_clear(ob1);
fail_unless(ob1->name == NULL, "Field name of ob1 was not cleaned by object_clear");
fail_unless(ob1->name_pl == NULL, "Field name_pl of ob1 was not cleaned by object_clear");
fail_unless(ob1->title == NULL, "Field title of ob1 was not cleaned by object_clear");
fail_unless(ob1->race == NULL, "Field race of ob1 was not cleaned by object_clear");
fail_unless(ob1->slaying == NULL, "Field slaying of ob1 was not cleaned by object_clear");
fail_unless(ob1->skill == NULL, "Field skill of ob1 was not cleaned by object_clear");
fail_unless(ob1->msg == NULL, "Field msg of ob1 was not cleaned by object_clear");
fail_unless(ob1->materialname == NULL, "Field materialname of ob1 was not cleaned by object_clear");
fail_unless(ob1->lore == NULL, "Field lore of ob1 was not cleaned by object_clear");
fail_unless(query_refcount(reference) == 1, "The number of references to string should drop back to 1 but was %d", query_refcount(reference));
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_copy(object *op2, object *op);
*/
START_TEST(test_object_copy) {
object *ob1;
object *ob2;
const char *reference;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
cctk_set_object_strings(ob1, "test String1");
cctk_set_object_strings(ob2, "test String2");
reference = add_string("test String2");
object_copy(ob1, ob2);
fail_unless(ob1->name == ob2->name, "Field name of ob1 should match ob2");
fail_unless(ob1->name_pl == ob2->name_pl, "Field name_pl of ob1 should match ob2");
fail_unless(ob1->title == ob2->title, "Field title of ob1 should match ob2");
fail_unless(ob1->race == ob2->race, "Field race of ob1 should match ob2");
fail_unless(ob1->slaying == ob2->slaying, "Field slaying of ob1 should match ob2");
fail_unless(ob1->skill == ob2->skill, "Field skill of ob1 should match ob2");
fail_unless(ob1->msg == ob2->msg, "Field msg of ob1 should match ob2");
fail_unless(ob1->materialname == ob2->materialname, "Field materialname of ob1 should match ob2");
fail_unless(ob1->lore == ob2->lore, "Field lore of ob1 should match ob2");
fail_unless(query_refcount(reference) == 1, "refcount of marker string is not dropped to 1 after copy object, some string field were not cleaned. refcount: %d", query_refcount(reference));
}
END_TEST
/**
* This is the test to check the behaviour of the method
* object *object_new(void);
*/
START_TEST(test_object_new) {
object *ob;
long int i;
ob = object_new();
fail_unless(ob != NULL, "Should get an object after calling object_new()");
fail_unless(ob->name == NULL, "Field name has not been nullified by object_new()");
fail_unless(ob->name_pl == NULL, "Field name_pl has not been nullified by object_new()");
fail_unless(ob->title == NULL, "Field title has not been nullified by object_new()");
fail_unless(ob->race == NULL, "Field race has not been nullified by object_new()");
fail_unless(ob->slaying == NULL, "Field slaying has not been nullified by object_new()");
fail_unless(ob->skill == NULL, "Field skill has not been nullified by object_new()");
fail_unless(ob->lore == NULL, "Field lore has not been nullified by object_new()");
fail_unless(ob->msg == NULL, "Field msg has not been nullified by object_new()");
fail_unless(ob->materialname == NULL, "Field materialname has not been nullified by object_new()");
fail_unless(ob->prev == NULL, "Field prev has not been nullified by object_new()");
fail_unless(ob->active_next == NULL, "Field active_next has not been nullified by object_new()");
fail_unless(ob->active_prev == NULL, "Field active_prev has not been nullified by object_new()");
/* did you really thing i'll go with only one object? */
/* let's go for about 2M allocations in a row, let's test roughness */
for (i = 0; i < 1L<<17; i++) {
ob = object_new();
fail_unless(ob != NULL, "Should get an object after calling object_new() (iteration %l)", i);
if (!(i&((1<<13)-1)))
LOG(llevDebug, "%ldk items created with object_new\n", i>>10);
}
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_update_turn_face(object *op);
*/
START_TEST(test_object_update_turn_face) {
object *ob1;
const Face *face1;
const Face *face2;
ob1 = cctk_create_game_object("arrow");
ob1->direction = 1;
object_update_turn_face(ob1);
face1 = ob1->face;
ob1->direction = 0;
object_update_turn_face(ob1);
face2 = ob1->face;
fail_unless(face2 != face1, "2 opposite direction should provide different faces after object_update_turn_face");
}
END_TEST
#define IS_OBJECT_ACTIVE(op) (op->active_next || op->active_prev || op == active_objects)
/** This is the test to check the behaviour of the method
* void object_update_speed(object *op);
*/
START_TEST(test_object_update_speed) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
ob1->speed = MIN_ACTIVE_SPEED;
object_update_speed(ob1);
fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed <=MIN_ACTIVE_SPEED(%f) should not be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
ob1->speed = -MIN_ACTIVE_SPEED;
object_update_speed(ob1);
fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed <=MIN_ACTIVE_SPEED(%f) should not be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
ob1->speed = MIN_ACTIVE_SPEED*2;
object_update_speed(ob1);
fail_unless(IS_OBJECT_ACTIVE(ob1), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
ob2->speed = -MIN_ACTIVE_SPEED*2;
object_update_speed(ob2);
fail_unless(IS_OBJECT_ACTIVE(ob2), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob2->speed);
ob4->speed = ob3->speed = ob2->speed;
object_update_speed(ob3);
object_update_speed(ob4);
fail_unless(IS_OBJECT_ACTIVE(ob3), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob3->speed);
fail_unless(IS_OBJECT_ACTIVE(ob4), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob4->speed);
ob1->speed = 0.0;
ob2->speed = 0.0;
ob3->speed = 0.0;
ob4->speed = 0.0;
object_update_speed(ob1);
object_update_speed(ob2);
object_update_speed(ob3);
object_update_speed(ob4);
fail_unless(!IS_OBJECT_ACTIVE(ob1), "Object with absolute speed 0.0 should be inactivated", ob1->speed);
fail_unless(!IS_OBJECT_ACTIVE(ob2), "Object with absolute speed 0.0 should be inactivated", ob2->speed);
fail_unless(!IS_OBJECT_ACTIVE(ob3), "Object with absolute speed 0.0 should be inactivated", ob3->speed);
fail_unless(!IS_OBJECT_ACTIVE(ob4), "Object with absolute speed 0.0 should be inactivated", ob4->speed);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_remove_from_active_list(object *op);
*/
START_TEST(test_object_remove_from_active_list) {
object *ob1;
ob1 = cctk_create_game_object(NULL);
ob1->speed = MIN_ACTIVE_SPEED*2;
object_update_speed(ob1);
fail_unless(IS_OBJECT_ACTIVE(ob1), "Object with absolute speed >MIN_ACTIVE_SPEED(%f) should be made active (speed=%f)", MIN_ACTIVE_SPEED, ob1->speed);
object_remove_from_active_list(ob1);
fail_unless(!IS_OBJECT_ACTIVE(ob1), "After call to object_remove_from_active_list, object should be made inactive");
}
END_TEST
#undef IS_OBJECT_ACTIVE
/** This is the test to check the behaviour of the method
* void object_update(object *op, int action);
*/
START_TEST(test_object_update) {
/*TESTME (this one need a map loading, left for later*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_free_drop_inventory(object *ob);
*/
START_TEST(test_object_free_drop_inventory) {
object *ob1;
object *ob2;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
object_insert_in_ob(ob2, ob1);
object_free_drop_inventory(ob1);
fail_unless(QUERY_FLAG(ob1, FLAG_FREED), "Freeing ob1 should mark it freed");
fail_unless(QUERY_FLAG(ob2, FLAG_FREED), "Freeing ob1 should mark it's content freed");
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_count_free(void);
*/
START_TEST(test_object_count_free) {
int free1, free2;
cctk_create_game_object(NULL);
free1 = object_count_free();
cctk_create_game_object(NULL);
free2 = object_count_free();
/* Behaviour under MEMORY_DEBUG is to allocate each object separately so
* both will be 0. Allow test suite to pass with this option.
*/
#ifdef MEMORY_DEBUG
fail_unless(((free2 == 0) && (free1 == 0)), "after creating an object, the object_count_free() should return 0 (compiled with MEMORY_DEBUG)", free1-1, free2);
#else
fail_unless((free2 == free1-1), "after creating an object, the object_count_free() should return one less (%d) but returned %d", free1-1, free2);
#endif
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_count_used(void);
*/
START_TEST(test_object_count_used) {
int used1, used2;
cctk_create_game_object(NULL);
used1 = object_count_used();
cctk_create_game_object(NULL);
used2 = object_count_used();
fail_unless((used2 == used1+1), "after creating an object, the object_count_used() should return one more (%d) but returned %d", used1-1, used2);
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_count_active(void);
*/
START_TEST(test_object_count_active) {
object *ob1;
int active1, active2;
ob1 = cctk_create_game_object(NULL);
ob1->speed = MIN_ACTIVE_SPEED*2;
object_update_speed(ob1);
active1 = object_count_active();
ob1 = cctk_create_game_object(NULL);
ob1->speed = MIN_ACTIVE_SPEED*2;
object_update_speed(ob1);
active2 = object_count_active();
fail_unless((active2 == active1+1), "after activating an additional object, object_count_active should return one less %d but returned %d", active1-1, active2);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_sub_weight(object *op, signed long weight);
*/
START_TEST(test_object_sub_weight) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
unsigned long sum;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
ob1->weight = 10; /*This should not be taken into account by object_sum_weight*/
ob1->type = CONTAINER;
ob2->type = CONTAINER;
ob3->type = CONTAINER;
ob1->stats.Str = 40; /*40% reduction of weight*/
ob2->weight = 10;
ob3->weight = 10;
ob4->weight = 10;
object_insert_in_ob(ob2, ob1);
object_insert_in_ob(ob3, ob2);
object_insert_in_ob(ob4, ob3);
sum = object_sum_weight(ob1);
fail_unless(sum == 18, "Sum of object's inventory should be 18 (30*0.6+10) but was %lu.", sum);
object_sub_weight(ob4, 10);
fail_unless(ob1->carrying == 12, "after call to object_sub_weight, carrying of ob1 should be 22 but was %d", ob1->carrying);
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_remove(object *op);
*/
START_TEST(test_object_remove) {
/*TESTME test those
* ob with more
* player inv
* remove from map
*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_merge(object *op, object *top);
*/
START_TEST(test_object_merge) {
object *ob1;
object *ob2;
object *ob3;
object *ob4;
ob1 = cctk_create_game_object(NULL);
ob2 = cctk_create_game_object(NULL);
ob3 = cctk_create_game_object(NULL);
ob4 = cctk_create_game_object(NULL);
cctk_create_game_object(NULL);
ob1->below = ob2;
ob2->below = ob3;
ob3->below = ob4;
ob2->above = ob1;
ob3->above = ob2;
ob4->above = ob3;
ob1->name = add_string("test");
ob2->name = add_string("test2");
ob3->name = add_string("test3");
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y);
*/
START_TEST(test_object_insert_in_map_at) {
mapstruct *map;
object *first = NULL;
object *got = NULL;
map = get_empty_map(5, 5);
fail_unless(map != NULL, "get_empty_map returned NULL.");
/* Single tile object */
first = cctk_create_game_object("barrel");
fail_unless(first != NULL, "create barrel failed");
got = object_insert_in_map_at(first, map, NULL, 0, 0, 0);
fail_unless(got == first, "item shouldn't be destroyed");
first = cctk_create_game_object("dragon");
fail_unless(first != NULL, "create dragon failed");
fail_unless(first->more != NULL, "no other body part");
got = object_insert_in_map_at(first, map, NULL, 0, 1, 1);
fail_unless(got == first, "item shouldn't be destroyed");
fail_unless(GET_MAP_OB(map, 1, 1) == first, "item isn't on 1,1");
fail_unless(GET_MAP_OB(map, 2, 1) != NULL, "no item on 2,1");
fail_unless(GET_MAP_OB(map, 2, 1)->head == first, "head of 2,1 isn't 1,1");
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_insert_in_map(object *op, mapstruct *m, object *originator, int flag);
*/
START_TEST(test_object_insert_in_map) {
mapstruct *map;
object *first = NULL;
object *second = NULL;
object *third = NULL;
object *floor = NULL;
object *got = NULL;
map = get_empty_map(5, 5);
fail_unless(map != NULL, "get_empty_map returned NULL.");
/* First, simple tests for insertion. */
floor = cctk_create_game_object("woodfloor");
fail_unless(floor != NULL, "create woodfloor failed");
floor->x = 3;
floor->y = 3;
got = object_insert_in_map(floor, map, NULL, 0);
fail_unless(got == floor, "woodfloor shouldn't disappear");
fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should be first object");
first = cctk_create_game_object("barrel");
fail_unless(first != NULL, "create barrel failed");
first->x = 3;
first->y = 3;
got = object_insert_in_map(first, map, NULL, 0);
fail_unless(got == first, "barrel shouldn't disappear");
fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
fail_unless(floor->above == first, "barrel should be above floor");
second = cctk_create_game_object("gem");
fail_unless(second != NULL, "create gem failed");
second->nrof = 1;
second->x = 3;
second->y = 3;
got = object_insert_in_map(second, map, NULL, INS_ABOVE_FLOOR_ONLY);
fail_unless(got == second, "gem shouldn't disappear");
fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
fail_unless(floor->above == second, "gem should be above floor");
fail_unless(second->above == first, "barrel should be above gem");
third = cctk_create_game_object("bed_1");
fail_unless(third != NULL, "create bed_1 failed");
third->nrof = 1;
third->x = 3;
third->y = 3;
got = object_insert_in_map(third, map, first, INS_BELOW_ORIGINATOR);
fail_unless(got == third, "bed_1 shouldn't disappear");
fail_unless(floor == GET_MAP_OB(map, 3, 3), "woodfloor should still be first object");
fail_unless(third->above == first, "bed should be below barrel");
fail_unless(third->below == second, "bed should be above gem");
/* Merging tests. */
third = cctk_create_game_object("gem");
fail_unless(third != NULL, "create gem failed");
third->nrof = 1;
third->x = 3;
third->y = 3;
got = object_insert_in_map(third, map, NULL, 0);
fail_unless(got == third, "gem shouldn't disappear");
fail_unless(QUERY_FLAG(second, FLAG_FREED), "first gem should have been removed.");
fail_unless(third->nrof == 2, "second gem should have nrof 2");
second = cctk_create_game_object("gem");
fail_unless(second != NULL, "create gem failed");
second->nrof = 1;
second->x = 3;
second->y = 3;
second->value = 1;
got = object_insert_in_map(second, map, NULL, 0);
fail_unless(got == second, "modified gem shouldn't disappear");
fail_unless(second->nrof == 1, "modified gem should have nrof 1");
/* Now check sacrificing, on another spot.
* Can't work here, as altar logic is in server.
* -> move that there.
*/
/*
first = cctk_create_game_object("altar");
fail_unless(first != NULL, "create altar failed");
first->x = 2;
first->y = 2;
first->stats.food = 5;
first->value = 0;
fail_unless(object_insert_in_map(first, map, NULL, 0) == first, "altar shouldn't disappear");
fail_unless(GET_MAP_MOVE_ON(map, 2, 2)&MOVE_WALK == MOVE_WALK, "floor should have MOVE_WALK set");
second = cctk_create_game_object("food");
fail_unless(second != NULL, "create food failed");
second->nrof = 5;
second->x = 2;
second->y = 2;
got = object_insert_in_map(second, map, NULL, 0);
fail_unless(got == NULL, "object_insert_in_map(food) should have returned NULL");
fail_unless(QUERY_FLAG(second, FLAG_FREED), "food should have been freed");
*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_replace_insert_in_map(const char *arch_string, object *op);
*/
START_TEST(test_object_replace_insert_in_map) {
mapstruct *map;
object *first = NULL, *second = NULL, *third = NULL;
tag_t tag_first, tag_second, tag_third;
object *got = NULL;
map = get_empty_map(5, 5);
fail_unless(map != NULL, "get_empty_map returned NULL.");
/* Single tile object */
first = cctk_create_game_object("barrel");
fail_unless(first != NULL, "create barrel failed");
tag_first = first->count;
got = object_insert_in_map_at(first, map, NULL, 0, 0, 0);
fail_unless(got == first, "item shouldn't be destroyed");
second = cctk_create_game_object("table");
fail_unless(second != NULL, "create table failed");
got = object_insert_in_map_at(second, map, NULL, 0, 0, 0);
fail_unless(got == second, "second item shouldn't be destroyed");
tag_second = second->count;
third = cctk_create_game_object("barrel");
fail_unless(third != NULL, "create 2nd barrel failed");
got = object_insert_in_map_at(third, map, NULL, 0, 0, 0);
fail_unless(got == third, "second barrel shouldn't be destroyed");
tag_third = third->count;
fail_unless(GET_MAP_OB(map, 0, 0) == first, "item at 0,0 isn't barrel");
fail_unless(GET_MAP_OB(map, 0, 0)->above == second, "second item at 0,0 isn't table");
fail_unless(GET_MAP_OB(map, 0, 0)->above->above == third, "third item at 0,0 isn't barrel");
object_replace_insert_in_map("barrel", second);
fail_unless(GET_MAP_OB(map, 0, 0) != first, "item at 0, 0 is still first?");
fail_unless(object_was_destroyed(first, tag_first), "1st barrel should be destroyed");
fail_unless(!object_was_destroyed(second, tag_second), "table shouldn't be destroyed");
fail_unless(object_was_destroyed(third, tag_third), "2nd barrel should be destroyed");
fail_unless(GET_MAP_OB(map, 0, 0) != NULL, "no item at 0,0 after object_replace_insert_in_map");
fail_unless(GET_MAP_OB(map, 0, 0) != second, "second at bottom at 0,0 after object_replace_insert_in_map");
fail_unless(GET_MAP_OB(map, 0, 0)->above == second, "table isn't above new barrel");
fail_unless(strcmp(GET_MAP_OB(map, 0, 0)->arch->name, "barrel") == 0, "item at 0,0 is not a barrel after object_replace_insert_in_map");
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_split(object *orig_ob, uint32_t nr);
*/
START_TEST(test_object_split) {
object *first = NULL;
object *second = NULL;
char err[50];
first = cctk_create_game_object("gem");
fail_unless(first != NULL, "create gem failed");
first->nrof = 5;
second = object_split(first, 2, err, sizeof(err));
fail_unless(second != NULL, "should return an item");
fail_unless(second->nrof == 2, "2 expected to split");
fail_unless(first->nrof == 3, "3 should be left");
second = object_split(first, 3, err, sizeof(err));
fail_unless(second != NULL, "should return an item");
fail_unless(QUERY_FLAG(first, FLAG_FREED), "first should be freed");
first = object_split(second, 10, err, sizeof(err));
fail_unless(first == NULL, "should return NULL");
fail_unless(second->nrof == 3, "3 should be left");
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_decrease_nrof(object *op, uint32_t i);
*/
START_TEST(test_object_decrease_nrof) {
object *first = NULL;
object *second = NULL;
first = cctk_create_game_object("gem");
fail_unless(first != NULL, "create gem failed");
first->nrof = 5;
second = object_decrease_nrof(first, 3);
fail_unless(second == first, "gem shouldn't be destroyed");
second = object_decrease_nrof(first, 2);
fail_unless(second == NULL, "object_decrease_nrof should return NULL");
fail_unless(QUERY_FLAG(first, FLAG_FREED), "gem should have been freed");
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_add_weight(object *op, signed long weight);
*/
START_TEST(test_object_add_weight) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_insert_in_ob(object *op, object *where);
*/
START_TEST(test_object_insert_in_ob) {
object *container = NULL;
object *item = NULL;
item = cctk_create_game_object("gem");
fail_unless(item != NULL, "create gem failed");
item->weight = 50;
/* Bookshelves have no weight reduction. */
container = cctk_create_game_object("bookshelf");
fail_unless(container != NULL, "create bookshelf failed");
object_insert_in_ob(item, container);
fail_unless(container->inv == item, "item not inserted");
fail_unless(container->carrying == 50, "container should carry 50 and not %d", container->carrying);
object_remove(item);
fail_unless(container->carrying == 0, "container should carry 0 and not %d", container->carrying);
/* Sacks have a Str of 10, so will reduce the weight. */
container = cctk_create_game_object("sack");
fail_unless(container != NULL, "create sack failed");
object_insert_in_ob(item, container);
fail_unless(container->inv == item, "item not inserted");
fail_unless(container->carrying == 45, "container should carry 45 and not %d", container->carrying);
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_check_move_on(object *op, object *originator);
*/
START_TEST(test_object_check_move_on) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at);
*/
START_TEST(test_map_find_by_archetype) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *map_find_by_type(mapstruct *m, int x, int y, unsigned char type);
*/
START_TEST(test_map_find_by_type) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_present_in_ob(unsigned char type, const object *op);
*/
START_TEST(test_object_present_in_ob) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_present_in_ob_by_name(int type, const char *str, const object *op);
*/
START_TEST(test_object_present_in_ob_by_name) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *arch_present_in_ob(const archetype *at, const object *op);
*/
START_TEST(test_arch_present_in_ob) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_set_flag_inv(object *op, int flag);
*/
START_TEST(test_object_set_flag_inv) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_unset_flag_inv(object *op, int flag);
*/
START_TEST(test_object_unset_flag_inv) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void object_set_cheat(object *op);
*/
START_TEST(test_object_set_cheat) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop);
*/
START_TEST(test_object_find_free_spot) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y);
*/
START_TEST(test_object_find_first_free_spot) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* void get_search_arr(int *search_arr);
*/
START_TEST(test_get_search_arr) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int map_find_dir(mapstruct *m, int x, int y, object *exclude);
*/
START_TEST(test_map_find_dir) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_distance(const object *ob1, const object *ob2);
*/
START_TEST(test_object_distance) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int find_dir_2(int x, int y);
*/
START_TEST(test_find_dir_2) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int absdir(int d);
*/
START_TEST(test_absdir) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int dirdiff(int dir1, int dir2);
*/
START_TEST(test_dirdiff) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int can_see_monsterP(mapstruct *m, int x, int y, int dir);
*/
START_TEST(test_can_see_monsterP) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_can_pick(const object *who, const object *item);
*/
START_TEST(test_object_can_pick) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_create_clone(object *asrc);
*/
START_TEST(test_object_create_clone) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_was_destroyed(const object *op, tag_t old_tag);
*/
START_TEST(test_object_was_destroyed) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* object *object_find_by_type_subtype(const object *who, int type, int subtype);
*/
START_TEST(test_object_find_by_type_subtype) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* key_value *object_get_key_value(const object *ob, const char *key);
*/
START_TEST(test_object_get_key_value) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* const char *object_get_value(const object *op, const char *const key);
*/
START_TEST(test_object_get_value) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_set_value(object *op, const char *key, const char *value, int add_key);
*/
START_TEST(test_object_set_value) {
/*TESTME*/
}
END_TEST
/** This is the test to check the behaviour of the method
* int object_matches_string(object *pl, object *op, const char *name);
*/
START_TEST(test_object_matches_string) {
object *pl;
object *o1, *o2;
int val;
pl = cctk_create_game_object("kobold");
fail_unless(pl != NULL, "couldn't create kobold");
pl->contr = (player *)calloc(1, sizeof(player));
fail_unless(pl->contr != NULL, "couldn't alloc contr");
o1 = cctk_create_game_object("cloak");
fail_unless(o1 != NULL, "couldn't find cloak archetype");
o1->title = add_string("of Gorokh");
CLEAR_FLAG(o1, FLAG_IDENTIFIED);
val = object_matches_string(pl, o1, "all");
fail_unless(val == 1, "all didn't match cloak");
val = object_matches_string(pl, o1, "Gorokh");
fail_unless(val == 0, "unidentified cloak matched title with value %d", val);
val = object_matches_string(pl, o1, "random");
fail_unless(val == 0, "unidentified cloak matched random value with value %d", val);
SET_FLAG(o1, FLAG_IDENTIFIED);
val = object_matches_string(pl, o1, "Gorokh");
fail_unless(val != 0, "identified cloak didn't match title with value %d", val);
o2 = cctk_create_game_object("cloak");
SET_FLAG(o2, FLAG_UNPAID);
val = object_matches_string(pl, o2, "unpaid");
fail_unless(val == 2, "unpaid cloak didn't match unpaid");
val = object_matches_string(pl, o2, "cloak");
fail_unless(val != 0, "unpaid cloak didn't match cloak with %d", val);
val = object_matches_string(pl, o2, "wrong");
fail_unless(val == 0, "unpaid cloak matched wrong name %d", val);
}
END_TEST
static Suite *object_suite(void) {
Suite *s = suite_create("object");
TCase *tc_core = tcase_create("Core");
/*setup and teardown will be called before each test in testcase 'tc_core' */
tcase_add_unchecked_fixture(tc_core, setup, teardown);
suite_add_tcase(s, tc_core);
tcase_add_test(tc_core, test_object_can_merge);
tcase_add_test(tc_core, test_object_sum_weight);
tcase_add_test(tc_core, test_object_get_env_recursive);
tcase_add_test(tc_core, test_object_get_player_container);
tcase_add_test(tc_core, test_object_dump);
tcase_add_test(tc_core, test_object_dump_all);
tcase_add_test(tc_core, test_object_find_by_tag_global);
tcase_add_test(tc_core, test_object_find_by_name_global);
tcase_add_test(tc_core, test_object_free_all_data);
tcase_add_test(tc_core, test_object_get_owner);
tcase_add_test(tc_core, test_object_clear_owner);
tcase_add_test(tc_core, test_object_set_owner);
tcase_add_test(tc_core, test_object_copy_owner);
tcase_add_test(tc_core, test_object_reset);
tcase_add_test(tc_core, test_object_clear);
tcase_add_test(tc_core, test_object_copy);
tcase_add_test(tc_core, test_object_new);
tcase_add_test(tc_core, test_object_update_turn_face);
tcase_add_test(tc_core, test_object_update_speed);
tcase_add_test(tc_core, test_object_remove_from_active_list);
tcase_add_test(tc_core, test_object_update);
tcase_add_test(tc_core, test_object_free_drop_inventory);
tcase_add_test(tc_core, test_object_count_free);
tcase_add_test(tc_core, test_object_count_used);
tcase_add_test(tc_core, test_object_count_active);
tcase_add_test(tc_core, test_object_sub_weight);
tcase_add_test(tc_core, test_object_remove);
tcase_add_test(tc_core, test_object_merge);
tcase_add_test(tc_core, test_object_insert_in_map_at);
tcase_add_test(tc_core, test_object_insert_in_map);
tcase_add_test(tc_core, test_object_replace_insert_in_map);
tcase_add_test(tc_core, test_object_split);
tcase_add_test(tc_core, test_object_decrease_nrof);
tcase_add_test(tc_core, test_object_add_weight);
tcase_add_test(tc_core, test_object_insert_in_ob);
tcase_add_test(tc_core, test_object_check_move_on);
tcase_add_test(tc_core, test_map_find_by_archetype);
tcase_add_test(tc_core, test_map_find_by_type);
tcase_add_test(tc_core, test_object_present_in_ob);
tcase_add_test(tc_core, test_object_present_in_ob_by_name);
tcase_add_test(tc_core, test_arch_present_in_ob);
tcase_add_test(tc_core, test_object_set_flag_inv);
tcase_add_test(tc_core, test_object_unset_flag_inv);
tcase_add_test(tc_core, test_object_set_cheat);
tcase_add_test(tc_core, test_object_find_free_spot);
tcase_add_test(tc_core, test_object_find_first_free_spot);
tcase_add_test(tc_core, test_get_search_arr);
tcase_add_test(tc_core, test_map_find_dir);
tcase_add_test(tc_core, test_object_distance);
tcase_add_test(tc_core, test_find_dir_2);
tcase_add_test(tc_core, test_absdir);
tcase_add_test(tc_core, test_dirdiff);
tcase_add_test(tc_core, test_can_see_monsterP);
tcase_add_test(tc_core, test_object_can_pick);
tcase_add_test(tc_core, test_object_create_clone);
tcase_add_test(tc_core, test_object_was_destroyed);
tcase_add_test(tc_core, test_object_find_by_type_subtype);
tcase_add_test(tc_core, test_object_get_key_value);
tcase_add_test(tc_core, test_object_get_value);
tcase_add_test(tc_core, test_object_set_value);
tcase_add_test(tc_core, test_object_matches_string);
return s;
}
int main(void) {
int nf;
SRunner *sr;
Suite *s = object_suite();
sr = srunner_create(s);
srunner_set_xml(sr, LOGDIR "/unit/common/object.xml");
/* if you wish to debug, uncomment the following line. */
/* srunner_set_fork_status(sr, CK_NOFORK);*/
srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|