summaryrefslogtreecommitdiffstats
path: root/src/common/test/profile_test.cpp
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2012-08-09 23:04:29 +0200
committererihel <erihel@gmail.com>2012-08-09 23:04:29 +0200
commit9946459c0cd65c3b66719a2aefc42c7ab2a29c04 (patch)
tree78e68a3a434082c5f42926f907adb05db9ae24dd /src/common/test/profile_test.cpp
parentf1d1cdceee3ec49546ba800a1b53a2dfb9c21e11 (diff)
downloadcolobot-9946459c0cd65c3b66719a2aefc42c7ab2a29c04.tar.gz
colobot-9946459c0cd65c3b66719a2aefc42c7ab2a29c04.tar.bz2
colobot-9946459c0cd65c3b66719a2aefc42c7ab2a29c04.zip
* changed 0, NULL to nullptr
* changed profile.cpp to use SimpleIni to load config files * added new CProfile singleton class for loading config * added SimpleIni to lib/ dir * added config loading tests
Diffstat (limited to 'src/common/test/profile_test.cpp')
-rw-r--r--src/common/test/profile_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/common/test/profile_test.cpp b/src/common/test/profile_test.cpp
new file mode 100644
index 0000000..3ba0fad
--- /dev/null
+++ b/src/common/test/profile_test.cpp
@@ -0,0 +1,35 @@
+#include "../profile.h"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+int main()
+{
+ CProfile profile;
+ profile.InitCurrentDirectory(); // load colobot.ini file
+
+ string result;
+ profile.GetLocalProfileString("test_string", "string_value", result);
+ if (result != "Hello world") {
+ cout << "GetLocalProfileString failed!" << endl;
+ return 1;
+ }
+
+ int int_value;
+ profile.GetLocalProfileInt("test_int", "int_value", int_value);
+ if (int_value != 42) {
+ cout << "GetLocalProfileInt failed!" << endl;
+ return 1;
+ }
+
+ float float_value;
+ profile.GetLocalProfileFloat("test_float", "float_value", float_value);
+ if (float_value != 1.5) {
+ cout << "GetLocalProfileFloat failed!" << endl;
+ return 1;
+ }
+
+ return 0;
+}