summaryrefslogtreecommitdiff
path: root/test/core/script
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-10-16 01:02:12 +0000
committerandreas <andreas@daaaf23c-2e50-4459-9457-1e69db5a47bf>2014-10-16 01:02:12 +0000
commit97f6ec9bbb3615c9a505e29c76b7ecc6993b6791 (patch)
tree3cf25e87f848502af527bd6fbfbf72c4ae27ab36 /test/core/script
parent0e426ff6dfb960c105908a437c435924e59eb822 (diff)
fixed typeo in RangeSet, added unit test for Variant
git-svn-id: file:///var/local/svn/basicwriter@59 daaaf23c-2e50-4459-9457-1e69db5a47bf
Diffstat (limited to 'test/core/script')
-rw-r--r--test/core/script/Variant.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/core/script/Variant.cpp b/test/core/script/Variant.cpp
new file mode 100644
index 0000000..164bcab
--- /dev/null
+++ b/test/core/script/Variant.cpp
@@ -0,0 +1,71 @@
+/*
+ Ousía
+ Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel
+
+ 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 3 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. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <gtest/gtest.h>
+
+#include <core/script/Variant.hpp>
+
+namespace ousia {
+namespace script {
+
+TEST(Variant, getIntegerValue)
+{
+ Variant vi{(int64_t)42};
+ Variant vf{42.0};
+
+ ASSERT_EQ(42, vi.getIntegerValue());
+ ASSERT_EQ(42, vf.getIntegerValue());
+}
+
+TEST(Variant, getNumberValue)
+{
+ Variant vi{(int64_t)42};
+ Variant vf{42.5};
+
+ ASSERT_EQ(42, vi.getNumberValue());
+ ASSERT_EQ(42.5, vf.getNumberValue());
+}
+
+TEST(Variant, getStringValue)
+{
+ Variant v{"hello world"};
+ ASSERT_EQ("hello world", v.getStringValue());
+}
+
+TEST(Variant, getArrayValue)
+{
+ Variant v{{"test1", (int64_t)42}};
+ ASSERT_EQ(2, v.getArrayValue().size());
+ ASSERT_EQ("test1", v.getArrayValue()[0].getStringValue());
+ ASSERT_EQ(42, v.getArrayValue()[1].getIntegerValue());
+}
+
+TEST(Variant, getMapValue)
+{
+ Variant v{{{"key1", "entry1"}, {"key2", "entry2"}}};
+
+ auto map = v.getMapValue();
+ ASSERT_EQ(2, map.size());
+
+ ASSERT_EQ("entry1", (*map.find("key1")).second.getStringValue());
+ ASSERT_EQ("entry2", (*map.find("key2")).second.getStringValue());
+}
+
+}
+}
+