aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods
Commit message (Collapse)AuthorAge
* Add missing mapgen.lua to games/minimalPerttu Ahola2012-04-06
|
* experimental:soundblock dig_immediate=3Perttu Ahola2012-04-06
|
* Make the minimal development test somewhat playable by adding ore generation ↵Perttu Ahola2012-04-05
| | | | and removing the player visual switch test
* Fix sound direction and add experimental:soundblock alias sb in minimal for ↵Perttu Ahola2012-04-04
| | | | testing
* initial_properties field in entity definitionPerttu Ahola2012-03-31
|
* Add minetest.get_connected_players()Perttu Ahola2012-03-30
|
* ObjectRef:set_armor_groups() and ObjectRef:set_properties() - works on ↵Perttu Ahola2012-03-30
| | | | players too!
* Modify minimal/give_initial_stuff to always give stuffPerttu Ahola2012-03-29
|
* Rework tool_capabilities a bit (maxwear->uses, scale dig time according to ↵Perttu Ahola2012-03-29
| | | | leveldiff)
* Make mapgen use mapgen_* node aliases rather than the LEGN macroPerttu Ahola2012-03-28
|
* Add PseudoRandom in Lua APIPerttu Ahola2012-03-28
|
* Add minetest.after(time, func)Perttu Ahola2012-03-27
|
* Add default_grass_footstep.1.ogg as a test sound in minimalPerttu Ahola2012-03-27
|
* Move games/minetest to games/minimal and update README.txtPerttu Ahola2012-03-26
com">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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "test.h" #include "settings.h" #include "noise.h" class TestSettings : public TestBase { public: TestSettings() { TestManager::registerTestModule(this); } const char *getName() { return "TestSettings"; } void runTests(IGameDef *gamedef); void testAllSettings(); static const char *config_text_before; static const std::string config_text_after; }; static TestSettings g_test_instance; void TestSettings::runTests(IGameDef *gamedef) { TEST(testAllSettings); } //////////////////////////////////////////////////////////////////////////////// const char *TestSettings::config_text_before = "leet = 1337\n" "leetleet = 13371337\n" "leetleet_neg = -13371337\n" "floaty_thing = 1.1\n" "stringy_thing = asd /( ¤%&(/\" BLÖÄRP\n" "coord = (1, 2, 4.5)\n" " # this is just a comment\n" "this is an invalid line\n" "asdf = {\n" " a = 5\n" " bb = 2.5\n" " ccc = \"\"\"\n" "testy\n" " testa \n" "\"\"\"\n" "\n" "}\n" "blarg = \"\"\" \n" "some multiline text\n" " with leading whitespace!\n" "\"\"\"\n" "np_terrain = 5, 40, (250, 250, 250), 12341, 5, 0.7, 2.4\n" "zoop = true"; const std::string TestSettings::config_text_after = "leet = 1337\n" "leetleet = 13371337\n" "leetleet_neg = -13371337\n" "floaty_thing = 1.1\n" "stringy_thing = asd /( ¤%&(/\" BLÖÄRP\n" "coord = (1, 2, 4.5)\n" " # this is just a comment\n" "this is an invalid line\n" "asdf = {\n" " a = 5\n" " bb = 2.5\n" " ccc = \"\"\"\n" "testy\n" " testa \n" "\"\"\"\n" "\n" "}\n" "blarg = \"\"\" \n" "some multiline text\n" " with leading whitespace!\n" "\"\"\"\n" "np_terrain = {\n" " flags = defaults\n" " lacunarity = 2.4\n" " octaves = 6\n" " offset = 3.5\n" " persistence = 0.7\n" " scale = 40\n" " seed = 12341\n" " spread = (250,250,250)\n" "}\n" "zoop = true\n" "coord2 = (1,2,3.3)\n" "floaty_thing_2 = 1.2\n" "groupy_thing = {\n" " animals = cute\n" " num_apples = 4\n" " num_oranges = 53\n" "}\n"; void TestSettings::testAllSettings() { try { Settings s; // Test reading of settings std::istringstream is(config_text_before); s.parseConfigLines(is); UASSERT(s.getS32("leet") == 1337); UASSERT(s.getS16("leetleet") == 32767); UASSERT(s.getS16("leetleet_neg") == -32768); // Not sure if 1.1 is an exact value as a float, but doesn't matter UASSERT(fabs(s.getFloat("floaty_thing") - 1.1) < 0.001); UASSERT(s.get("stringy_thing") == "asd /( ¤%&(/\" BLÖÄRP"); UASSERT(fabs(s.getV3F("coord").X - 1.0) < 0.001); UASSERT(fabs(s.getV3F("coord").Y - 2.0) < 0.001); UASSERT(fabs(s.getV3F("coord").Z - 4.5) < 0.001); // Test the setting of settings too s.setFloat("floaty_thing_2", 1.2); s.setV3F("coord2", v3f(1, 2, 3.3)); UASSERT(s.get("floaty_thing_2").substr(0,3) == "1.2"); UASSERT(fabs(s.getFloat("floaty_thing_2") - 1.2) < 0.001); UASSERT(fabs(s.getV3F("coord2").X - 1.0) < 0.001); UASSERT(fabs(s.getV3F("coord2").Y - 2.0) < 0.001); UASSERT(fabs(s.getV3F("coord2").Z - 3.3) < 0.001); // Test settings groups Settings *group = s.getGroup("asdf"); UASSERT(group != NULL); UASSERT(s.getGroupNoEx("zoop", group) == false); UASSERT(group->getS16("a") == 5); UASSERT(fabs(group->getFloat("bb") - 2.5) < 0.001); Settings *group3 = new Settings; group3->set("cat", "meow"); group3->set("dog", "woof"); Settings *group2 = new Settings; group2->setS16("num_apples", 4); group2->setS16("num_oranges", 53); group2->setGroup("animals", group3); group2->set("animals", "cute"); //destroys group 3 s.setGroup("groupy_thing", group2); // Test set failure conditions UASSERT(s.set("Zoop = Poop\nsome_other_setting", "false") == false); UASSERT(s.set("sneaky", "\"\"\"\njabberwocky = false") == false);