aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.h
diff options
context:
space:
mode:
authorAaron Suen <warr1024@gmail.com>2019-10-13 09:32:39 -0400
committersfan5 <sfan5@live.de>2019-10-13 17:11:00 +0200
commit0df646e0689b5324c7bdb13205c2a63e42ebe8e8 (patch)
treef68dfef27e4e064a70939be7176eb2342dd7de96 /src/script/lua_api/l_env.h
parent47d07793654c1bdd92afbcb486e1ff1429f29a8f (diff)
downloadminetest-0df646e0689b5324c7bdb13205c2a63e42ebe8e8.tar.gz
minetest-0df646e0689b5324c7bdb13205c2a63e42ebe8e8.tar.bz2
minetest-0df646e0689b5324c7bdb13205c2a63e42ebe8e8.zip
Fix rotate_node to return the correct itemstack.
All on_* hooks that return an itemstack are NOT guaranteed to modify and return the original stack. We cannot count on the behavior of the existing builtin definitions not to be overridden by game/mod logic.
Diffstat (limited to 'src/script/lua_api/l_env.h')
0 files changed, 0 insertions, 0 deletions
n129'>129
/*
Minetest
Copyright (C) 2016 sfan5 <sfan5@live.de>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 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 <string>
#include "exceptions.h"
#include "client/keycode.h"

class TestKeycode : public TestBase {
public:
	TestKeycode() { TestManager::registerTestModule(this); }
	const char *getName() { return "TestKeycode"; }

	void runTests(IGameDef *gamedef);

	void testCreateFromString();
	void testCreateFromSKeyInput();
	void testCompare();
};

static TestKeycode g_test_instance;

void TestKeycode::runTests(IGameDef *gamedef)
{
	TEST(testCreateFromString);
	TEST(testCreateFromSKeyInput);
	TEST(testCompare);
}

////////////////////////////////////////////////////////////////////////////////

#define UASSERTEQ_STR(one, two) UASSERT(strcmp(one, two) == 0)

void TestKeycode::testCreateFromString()
{
	KeyPress k;

	// Character key, from char
	k = KeyPress("R");
	UASSERTEQ_STR(k.sym(), "KEY_KEY_R");
	UASSERTCMP(int, >, strlen(k.name()), 0); // should have human description

	// Character key, from identifier
	k = KeyPress("KEY_KEY_B");
	UASSERTEQ_STR(k.sym(), "KEY_KEY_B");