/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#undef NDEBUG

#include <map>
#include <ox/std/error.hpp>
#include <ox/mc/write.hpp>
#include <nostalgia/gfx/gfx.hpp>

using namespace nostalgia;

static std::map<ox::StringView, ox::Error(*)()> tests = {
	{
		"readWriteTileSheet",
		[] -> ox::Error {
			gfx::TileSheet const in;
			OX_REQUIRE(buff, ox::writeMC(in));
			OX_REQUIRE(out, ox::readMC<gfx::TileSheet>(buff));
			ox::expect(in.subsheet.name, out.subsheet.name);
			return {};
		}
	},
};

int main(int argc, char const **argv) {
	int retval = -1;
	if (argc > 0) {
		auto const args = ox::Span{argv, static_cast<size_t>(argc)};
		auto const testName = ox::StringView(args[1]);
		if (tests.contains(testName)) {
			retval = static_cast<int>(tests[testName]());
		} else {
			retval = 1;
		}
	}
	return retval;
}
