| 1 |
/** |
| 2 |
* FreeDink test suite - Map |
| 3 |
|
| 4 |
* Copyright (C) 2015 Sylvain Beucler |
| 5 |
|
| 6 |
* This file is part of GNU FreeDink |
| 7 |
|
| 8 |
* GNU FreeDink is free software; you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU General Public License as |
| 10 |
* published by the Free Software Foundation; either version 3 of the |
| 11 |
* License, or (at your option) any later version. |
| 12 |
|
| 13 |
* GNU FreeDink is distributed in the hope that it will be useful, but |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
* General Public License for more details. |
| 17 |
|
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see |
| 20 |
* <http://www.gnu.org/licenses/>. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include <config.h> |
| 25 |
#endif |
| 26 |
|
| 27 |
#include "EditorMap.h" |
| 28 |
#include "DMod.h" |
| 29 |
#include "paths.h" |
| 30 |
|
| 31 |
class TestEditorMap : public CxxTest::TestSuite { |
| 32 |
public: |
| 33 |
void setUp() {} |
| 34 |
void tearDown() {} |
| 35 |
|
| 36 |
void test_new() { |
| 37 |
ts_paths_init(); |
| 38 |
TS_ASSERT_EQUALS(g_dmod.map.load(), false); |
| 39 |
TS_ASSERT_EQUALS(g_dmod.map.dink_dat.c_str(), "dink.dat"); |
| 40 |
TS_ASSERT_EQUALS(g_dmod.map.loc[1], 0); |
| 41 |
|
| 42 |
EditorMap testmap2("dink2.dat", "map2.dat"); |
| 43 |
TS_ASSERT_EQUALS(testmap2.load(), false); |
| 44 |
TS_ASSERT_EQUALS(testmap2.dink_dat.c_str(), "dink2.dat"); |
| 45 |
TS_ASSERT_EQUALS(testmap2.map_dat.c_str(), "map2.dat"); |
| 46 |
|
| 47 |
EditorMap testmapsave; |
| 48 |
TS_ASSERT_EQUALS(testmapsave.dink_dat.c_str(), "dink.dat"); |
| 49 |
TS_ASSERT_EQUALS(testmapsave.map_dat.c_str(), "map.dat"); |
| 50 |
TS_ASSERT_EQUALS(testmapsave.loc[1], 0); |
| 51 |
TS_ASSERT_EQUALS(testmapsave.music[1], 0); |
| 52 |
TS_ASSERT_EQUALS(testmapsave.indoor[1], 0); |
| 53 |
testmapsave.loc[1] = 1; |
| 54 |
testmapsave.music[1] = 1; |
| 55 |
testmapsave.indoor[1] = 1; |
| 56 |
testmapsave.loc[768] = 768; |
| 57 |
testmapsave.music[768] = 768; |
| 58 |
testmapsave.indoor[768] = 768; |
| 59 |
testmapsave.save(); |
| 60 |
|
| 61 |
EditorMap testmapload; |
| 62 |
TS_ASSERT_EQUALS(testmapload.dink_dat.c_str(), "dink.dat"); |
| 63 |
TS_ASSERT_EQUALS(testmapload.map_dat.c_str(), "map.dat"); |
| 64 |
TS_ASSERT_EQUALS(testmapload.load(), true); |
| 65 |
TS_ASSERT_EQUALS(testmapload.loc[1], 1); |
| 66 |
TS_ASSERT_EQUALS(testmapload.music[1], 1); |
| 67 |
TS_ASSERT_EQUALS(testmapload.indoor[1], 1); |
| 68 |
TS_ASSERT_EQUALS(testmapload.loc[768], 768); |
| 69 |
TS_ASSERT_EQUALS(testmapload.music[768], 768); |
| 70 |
TS_ASSERT_EQUALS(testmapload.indoor[768], 768); |
| 71 |
} |
| 72 |
}; |