2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2015-04-26 01:24:19 -04:00
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include "gamedef.h"
|
|
|
|
#include "nodedef.h"
|
2017-06-06 16:19:04 +02:00
|
|
|
#include "content_mapnode.h"
|
2015-04-26 01:24:19 -04:00
|
|
|
|
2017-04-23 09:52:40 +02:00
|
|
|
class TestMapNode : public TestBase
|
|
|
|
{
|
2015-04-26 01:24:19 -04:00
|
|
|
public:
|
|
|
|
TestMapNode() { TestManager::registerTestModule(this); }
|
|
|
|
const char *getName() { return "TestMapNode"; }
|
|
|
|
|
|
|
|
void runTests(IGameDef *gamedef);
|
|
|
|
|
2018-02-10 22:04:16 +02:00
|
|
|
void testNodeProperties(const NodeDefManager *nodedef);
|
2015-04-26 01:24:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static TestMapNode g_test_instance;
|
|
|
|
|
|
|
|
void TestMapNode::runTests(IGameDef *gamedef)
|
|
|
|
{
|
|
|
|
TEST(testNodeProperties, gamedef->getNodeDefManager());
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-02-10 22:04:16 +02:00
|
|
|
void TestMapNode::testNodeProperties(const NodeDefManager *nodedef)
|
2015-04-26 01:24:19 -04:00
|
|
|
{
|
|
|
|
MapNode n(CONTENT_AIR);
|
|
|
|
|
2022-10-09 10:50:26 -04:00
|
|
|
ContentLightingFlags f = nodedef->getLightingFlags(n);
|
2015-04-26 01:24:19 -04:00
|
|
|
UASSERT(n.getContent() == CONTENT_AIR);
|
2022-10-09 10:50:26 -04:00
|
|
|
UASSERT(n.getLight(LIGHTBANK_DAY, f) == 0);
|
|
|
|
UASSERT(n.getLight(LIGHTBANK_NIGHT, f) == 0);
|
2015-04-26 01:24:19 -04:00
|
|
|
|
|
|
|
// Transparency
|
|
|
|
n.setContent(CONTENT_AIR);
|
|
|
|
UASSERT(nodedef->get(n).light_propagates == true);
|
|
|
|
}
|