|
Atrinik Server 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00026 #include <global.h> 00027 #include <check.h> 00028 00029 START_TEST(test_put_object_in_sack) 00030 { 00031 mapstruct *test_map; 00032 object *sack, *obj, *dummy; 00033 00034 dummy = get_archetype("raas"); 00035 dummy->custom_attrset = (player *) calloc(1, sizeof(player)); 00036 dummy->type = PLAYER; 00037 SET_FLAG(dummy, FLAG_NO_FIX_PLAYER); 00038 00039 test_map = get_empty_map(5, 5); 00040 fail_if(test_map == NULL, "Can't create test map."); 00041 00042 sack = get_archetype("sack"); 00043 insert_ob_in_map(sack, test_map, NULL, 0); 00044 fail_if(GET_MAP_OB(test_map, 0, 0) != sack); 00045 00046 obj = get_archetype("letter"); 00047 obj->nrof = 1; 00048 obj->x = 1; 00049 insert_ob_in_map(obj, test_map, NULL, 0); 00050 put_object_in_sack(dummy, sack, obj, 1); 00051 fail_if(GET_MAP_OB(test_map, 1, 0) != obj, "Object was removed from map?"); 00052 fail_if(sack->inv != NULL, "Sack's inventory isn't null?"); 00053 remove_ob(sack); 00054 00055 /* Basic insertion. */ 00056 sack = get_archetype("sack"); 00057 sack->nrof = 1; 00058 fail_if(sack->type != CONTAINER, "Sack isn't a container?"); 00059 insert_ob_in_map(sack, test_map, NULL, 0); 00060 fail_if(GET_MAP_OB(test_map, 0, 0) != sack, "Sack not put on map?"); 00061 00062 SET_FLAG(sack, FLAG_APPLIED); 00063 put_object_in_sack(dummy, sack, obj, 1); 00064 fail_if(sack->inv != obj, "Object not inserted into sack?"); 00065 fail_if(GET_MAP_OB(test_map, 1, 0) != NULL, "Object wasn't removed from map?"); 00066 00067 remove_ob(obj); 00068 obj->x = 1; 00069 insert_ob_in_map(obj, test_map, NULL, 0); 00070 sack->weight_limit = 1; 00071 obj->weight = 5; 00072 00073 put_object_in_sack(dummy, sack, obj, 1); 00074 fail_if(sack->inv != NULL, "Item was put in sack even if too heavy?"); 00075 fail_if(GET_MAP_OB(test_map, 1, 0) != obj, "Object was removed from map?"); 00076 } 00077 END_TEST 00078 00079 static Suite *object_suite() 00080 { 00081 Suite *s = suite_create("object"); 00082 TCase *tc_core = tcase_create("Core"); 00083 00084 tcase_add_checked_fixture(tc_core, NULL, NULL); 00085 00086 suite_add_tcase(s, tc_core); 00087 tcase_add_test(tc_core, test_put_object_in_sack); 00088 00089 return s; 00090 } 00091 00092 void check_commands_object() 00093 { 00094 Suite *s = object_suite(); 00095 SRunner *sr = srunner_create(s); 00096 00097 srunner_set_xml(sr, "unit/commands/object.xml"); 00098 srunner_set_log(sr, "unit/commands/object.out"); 00099 srunner_run_all(sr, CK_ENV); 00100 srunner_ntests_failed(sr); 00101 srunner_free(sr); 00102 }
1.7.4