void test::FSTestFixture::SetUp() {
	auto currentTest = ::testing::UnitTest::GetInstance()->current_test_info();
	pushModDir(currentTest->name());

	init_cmdline();

	timer_init();

#ifndef NDEBUG
	outwnd_init();
	mprintf(("TEST: Setting up test '%s.%s'\n", currentTest->test_case_name(), currentTest->name()));
#endif

	os_init("Test", "Test");

	if (_initFlags & INIT_CFILE) {
		SCP_string cfile_dir(TEST_DATA_PATH);
		cfile_dir += DIR_SEPARATOR_CHAR;
		cfile_dir += "test"; // Cfile expects something after the path

		if (cfile_init(cfile_dir.c_str())) {
			FAIL() << "Cfile init failed!";
		}

		if (_initFlags & INIT_MOD_TABLE) {
			mod_table_init();        // load in all the mod dependent settings
		}

		lcl_init(-1);
		lcl_xstr_init();

		if (_initFlags & INIT_MOD_TABLE) {
			mod_table_init(); // load in all the mod dependent settings
		}

		if (_initFlags & INIT_GRAPHICS) {
			if (!gr_init(nullptr, GR_STUB, 1024, 768)) {
				FAIL() << "Graphics init failed!";
			}

			if (_initFlags & INIT_FONTS) {
				font::init();
			}
		}

		if (_initFlags & INIT_SHIPS) {
			ship_init();
		}
	}
}
Example #2
0
C4Value AulTest::RunCode(const char *code, bool wrap)
{
	class OnScopeExit
	{
	public:
		~OnScopeExit()
		{
			GameScript.Clear();
			ScriptEngine.Clear();
		}
	} _cleanup;

	InitCoreFunctionMap(&ScriptEngine);
	FixedRandom(0x40490fdb);

	std::string wrapped;
	if (wrap)
	{
		wrapped = "func Main() {\n";
		wrapped += code;
		wrapped += "\n}\n";
	}
	else
	{
		wrapped = code;
	}
	std::string src("<");
	auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
	src += test_info->test_case_name();
	src += "::";
	src += test_info->name();
	src += ">";

	GameScript.LoadData(src.c_str(), wrapped.c_str(), NULL);
	ScriptEngine.Link(NULL);
		
	return GameScript.Call("Main", nullptr, true);
}
Example #3
0
 /** default package 名を含む TestCase 名の取得 */
 ::std::string testcase_name_with_default_package_name() const
 {
     return TestEnv::AddDefaultPackageName(test_case_name());
 }