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
|
/**
* \file fields_tests.cpp
* \brief Automated tests for the Fields class.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "project/fields.h"
}
enum TestFields
{
TestStringValue,
TestListValue
};
static FieldInfo TestFieldInfo[] =
{
{ "stringval", StringField },
{ "listval", ListField },
{ 0, StringField }
};
struct FxFields
{
Fields fields;
FxFields()
{
fields = fields_create(TestFieldInfo);
}
~FxFields()
{
fields_destroy(fields);
}
};
SUITE(fields)
{
TEST_FIXTURE(FxFields, GetValue_ReturnsNull_OnUnsetString)
{
const char* result = fields_get_value(fields, TestStringValue);
CHECK(result == NULL);
}
TEST_FIXTURE(FxFields, SetValue_CanRoundtrip)
{
fields_set_value(fields, TestStringValue, "String Value");
const char* result = fields_get_value(fields, TestStringValue);
CHECK_EQUAL("String Value", result);
}
TEST_FIXTURE(FxFields, SetValues_CanRoundtrip)
{
Strings values = strings_create();
fields_set_values(fields, TestListValue, values);
CHECK(values == fields_get_values(fields, TestListValue));
}
}
|