3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "Profile/Profile.hpp"
24 #include "IO/FileLineReader.hpp"
25 #include "TestUtil.hpp"
34 ok1(!Profile::Exists("key1"));
35 ok1(!Profile::Get("key1", value
));
36 Profile::Set("key1", 4);
37 ok1(Profile::Exists("key1"));
38 ok1(Profile::Get("key1", value
));
44 ok1(!Profile::Get("key2", value
));
45 Profile::Set("key2", 123);
46 ok1(Profile::Get("key2", value
));
52 ok1(!Profile::Get("key3", value
));
53 Profile::Set("key3", -42);
54 ok1(Profile::Get("key3", value
));
60 ok1(!Profile::Get("key4", value
));
61 Profile::Set("key4", true);
62 ok1(Profile::Get("key4", value
));
64 Profile::Set("key4", false);
65 ok1(Profile::Get("key4", value
));
71 ok1(!Profile::Get("key5", value
));
72 Profile::Set("key5", fixed(1.337));
73 ok1(Profile::Get("key5", value
));
74 ok1(equals(value
, 1.337));
82 Profile::Set("key1", 4);
83 Profile::Set("key2", "value2");
85 Profile::SaveFile(_T("output/TestProfileWriter.prf"));
87 FileLineReader
reader(_T("output/TestProfileWriter.prf"));
89 skip(3, 0, "read error");
94 bool found1
= false, found2
= false;
97 while ((line
= reader
.ReadLine()) != NULL
) {
98 if (_tcscmp(line
, _T("key1=\"4\"")) == 0)
100 if (_tcscmp(line
, _T("key2=\"value2\"")) == 0)
115 Profile::LoadFile(_T("test/data/TestProfileReader.prf"));
119 ok1(Profile::Exists("key1"));
120 ok1(Profile::Get("key1", value
));
125 StaticString
<32> value
;
126 ok1(Profile::Exists("key2"));
127 ok1(Profile::Get("key2", value
));
128 ok1(value
== _T("value"));
133 ok1(Profile::Exists("key3"));
134 ok1(Profile::Get("key3", value
));
139 int main(int argc
, char **argv
)
147 return exit_status();