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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// test_config_pusher.cc
//
// Copyright (C) 2007 Daniel Burrows
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include <cppunit/extensions/HelperMacros.h>
#include <generic/apt/config_signal.h>
class ConfigPusherTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ConfigPusherTest);
CPPUNIT_TEST(testConfigPush);
CPPUNIT_TEST_SUITE_END();
private:
void testConfigPush()
{
static const char * const testTree = "TestTree::CfgPusher";
Configuration cfg;
CPPUNIT_ASSERT_EQUAL(std::string("asdf"), cfg.Find(testTree, "asdf"));
{
config_change_pusher pusher(testTree, 6, cfg);
CPPUNIT_ASSERT_EQUAL(6, cfg.FindI(testTree, 0));
}
CPPUNIT_ASSERT_EQUAL(std::string("asdf"), cfg.Find(testTree, "asdf"));
{
config_change_pusher pusher(testTree, "Blah", cfg);
CPPUNIT_ASSERT_EQUAL(std::string("Blah"), cfg.Find(testTree, ""));
}
CPPUNIT_ASSERT_EQUAL(std::string("asdf"), cfg.Find(testTree, "asdf"));
{
config_change_pusher pusher(testTree, true, cfg);
CPPUNIT_ASSERT_EQUAL(true, cfg.FindB(testTree, false));
}
CPPUNIT_ASSERT_EQUAL(std::string("asdf"), cfg.Find(testTree, "asdf"));
cfg.Set(testTree, 10);
CPPUNIT_ASSERT_EQUAL(10, cfg.FindI(testTree, 0));
{
config_change_pusher pusher(testTree, 6, cfg);
CPPUNIT_ASSERT_EQUAL(6, cfg.FindI(testTree, 0));
}
CPPUNIT_ASSERT_EQUAL(10, cfg.FindI(testTree, 0));
cfg.Set(testTree, "Tada");
CPPUNIT_ASSERT_EQUAL(std::string("Tada"), cfg.Find(testTree, ""));
{
config_change_pusher pusher(testTree, "Blah", cfg);
CPPUNIT_ASSERT_EQUAL(std::string("Blah"), cfg.Find(testTree, ""));
}
CPPUNIT_ASSERT_EQUAL(std::string("Tada"), cfg.Find(testTree, ""));
cfg.Set(testTree, false);
CPPUNIT_ASSERT_EQUAL(false, cfg.FindB(testTree, false));
{
config_change_pusher pusher(testTree, true, cfg);
CPPUNIT_ASSERT_EQUAL(true, cfg.FindB(testTree, false));
}
CPPUNIT_ASSERT_EQUAL(false, cfg.FindB(testTree, false));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(ConfigPusherTest);
|