Welcome to mirror list, hosted at ThFree Co, Russian Federation.

unload_block_tests.cpp « tests « script « src - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8835b0f47adc4c24996d728a3cb4f182be442282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
 * \file   unload_block_tests.cpp
 * \brief  Automated tests for configuration block unloading from the script environment.
 * \author Copyright (c) 2008 Jason Perkins and the Premake project
 */

#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "script/script_internal.h"
}


struct FxUnloadBlock
{
	lua_State* L;
	Script     script;
	Block      blk;

	FxUnloadBlock()
	{
		script = script_create();
		L = script_get_lua(script);

		blk = block_create();

		script_run_string(script,
			"solution('MySolution');"
			"  configurations { 'Debug', 'Release' };"
			"  configuration 'Debug';"
			"    defines { 'DEBUG', 'DEBUG2' };"
			"  return configuration()");
	}

	~FxUnloadBlock()
	{
		block_destroy(blk);
		script_destroy(script);
	}
};


SUITE(unload)
{
	TEST_FIXTURE(FxUnloadBlock, UnloadBlock_UnloadsDefines)
	{
		unload_block(L, blk);
		Strings defines = block_get_values(blk, BlockDefines);
		CHECK(strings_size(defines) == 2);
		if (strings_size(defines) == 2) {
			CHECK_EQUAL("DEBUG",  strings_item(defines, 0));
			CHECK_EQUAL("DEBUG2", strings_item(defines, 1));
		}
	}

	TEST_FIXTURE(FxUnloadBlock, UnloadBlock_UnloadsTerms)
	{
		unload_block(L, blk);
		Strings terms = block_get_values(blk, BlockTerms);
		CHECK(strings_size(terms) == 1);
		if (strings_size(terms) == 1) {
			CHECK_EQUAL("Debug", strings_item(terms, 0));
		}
	}
}