aboutsummaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
authorv-rob <robinsonvincent89@gmail.com>2020-07-10 03:11:26 -0700
committerGitHub <noreply@github.com>2020-07-10 12:11:26 +0200
commitb1ff04e06da531dc52f6ee91e2967b39743033e6 (patch)
tree3d1af58d8c8003c5099122d0021b46d87c076c6f /src/script/common
parent2384c10e104fd0c945f3677130e7d25c0a841482 (diff)
downloadminetest-b1ff04e06da531dc52f6ee91e2967b39743033e6.tar.gz
minetest-b1ff04e06da531dc52f6ee91e2967b39743033e6.tar.bz2
minetest-b1ff04e06da531dc52f6ee91e2967b39743033e6.zip
Formspec: Make dropdowns optionally return event based on index, not value (#9496)
Diffstat (limited to 'src/script/common')
0 files changed, 0 insertions, 0 deletions
> 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

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 <sstream>

#include "irrlichttypes_extrabloated.h"
#include "log.h"
#include "serialization.h"
#include "nodedef.h"
#include "noise.h"

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

	void runTests(IGameDef *gamedef);

	void testRLECompression();
	void testZlibCompression();
	void testZlibLargeData();
};

static TestCompression g_test_instance;

void TestCompression::runTests(IGameDef *gamedef)
{
	TEST(testRLECompression);
	TEST(testZlibCompression);
	TEST(testZlibLargeData);
}

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

void TestCompression::testRLECompression()
{
	SharedBuffer<u8> fromdata(4);
	fromdata[0]=1;
	fromdata[1]=5;
	fromdata[2]=5;
	fromdata[3]=1;

	std::ostringstream os(std::ios_base::binary);
	compress(fromdata, os, 0);

	std::string str_out = os.str();

	infostream << "str_out.size()="<<str_out.size()<<std::endl;
	infostream << "TestCompress: 1,5,5,1 -> ";
	for (char i : str_out)
		infostream << (u32) i << ",";
	infostream << std::endl;

	UASSERT(str_out.size() == 10);

	UASSERT(str_out[0] == 0);
	UASSERT(str_out[1] == 0);
	UASSERT(str_out[2] == 0);
	UASSERT(str_out[3] == 4);
	UASSERT(str_out[4] == 0);
	UASSERT(str_out[5] == 1);
	UASSERT(str_out[6] == 1);
	UASSERT(str_out[7] == 5);
	UASSERT(str_out[8] == 0);
	UASSERT(str_out[9] == 1);

	std::istringstream is(str_out, std::ios_base::binary);
	std::ostringstream os2(std::ios_base::binary);

	decompress(is, os2, 0);
	std::string str_out2 = os2.str();

	infostream << "decompress: ";
	for (char i : str_out2)
		infostream << (u32) i << ",";
	infostream << std::endl;

	UASSERTEQ(size_t, str_out2.size(), fromdata.getSize());