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

host_help_tests.cpp « tests « host « src - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5917a5a317fd2a8671143b627995a2583311e765 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
 * \file   host_help_tests.cpp
 * \brief  Automated test for application help and version display.
 * \author Copyright (c) 2008 Jason Perkins and the Premake project
 */

#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "host/host.h"
#include "base/error.h"
#include "base/stream.h"
}

struct FxHostHelp
{
	Host host;
	Session sess;
	char buffer[8192];

	FxHostHelp()
	{
		host = host_create();
		sess = session_create();
		stream_set_buffer(Console, buffer);
	}

	~FxHostHelp()
	{
		session_destroy(sess);
		host_destroy(host);
		error_clear();
	}
};


SUITE(host)
{
	/**********************************************************************
	 * Do nothing if an action is set.
	 **********************************************************************/

	TEST_FIXTURE(FxHostHelp, Help_ReturnsOkay_OnAction)
	{
		const char* argv[] = { "premake", "vs2005", NULL };
		host_set_argv(host, argv);
		int result = host_show_help(host);
		CHECK(result == OKAY);
	}

	TEST_FIXTURE(FxHostHelp, Help_PrintsNothing_OnAction)
	{
		const char* argv[] = { "premake", "vs2005", NULL };
		host_set_argv(host, argv);
		host_show_help(host);
		CHECK_EQUAL("", buffer);
	}


	/**********************************************************************
	 * Should display short help (and end loop) if there is no action set.
	 **********************************************************************/

	TEST_FIXTURE(FxHostHelp, Help_ReturnsNotOkay_OnNoAction)
	{
		const char* argv[] = { "premake", NULL };
		host_set_argv(host, argv);
		int result = host_show_help(host);
		CHECK(result != OKAY);
	}

	TEST_FIXTURE(FxHostHelp, Help_ShowsShortHelp_OnNoAction)
	{
		const char* argv[] = { "premake", NULL };
		host_set_argv(host, argv);
		host_show_help(host);
		CHECK_EQUAL(HOST_SHORT_HELP "\n", buffer);
	}
}