diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-10 02:41:23 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-10 02:41:23 +0100 |
commit | a8f78252f05327d37aec3b853109b6d1359af452 (patch) | |
tree | 1eb136057bc59c6cf19ac52d2830c5a186149ce8 /test | |
parent | d84efdc312a9c5d0b6757c826810809a8e78f1e2 (diff) | |
parent | 325d78169620094178513303d65c71d933182ae4 (diff) |
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'test')
-rw-r--r-- | test/core/ResourceLocatorTest.cpp | 69 | ||||
-rw-r--r-- | test/core/variant/VariantTest.cpp | 15 | ||||
-rw-r--r-- | test/plugins/css/CSSParserTest.cpp | 2 |
3 files changed, 85 insertions, 1 deletions
diff --git a/test/core/ResourceLocatorTest.cpp b/test/core/ResourceLocatorTest.cpp new file mode 100644 index 0000000..38cfc3e --- /dev/null +++ b/test/core/ResourceLocatorTest.cpp @@ -0,0 +1,69 @@ +/* + 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/ResourceLocator.hpp> + +#include <sstream> + +namespace ousia { + +class TestResourceLocator : public ResourceLocator { +public: + ResourceLocator::Location locate( + const std::string &path, const std::string &relativeTo, + const ResourceLocator::Type type) const override + { + // trivial test implementation. + return ResourceLocator::Location(true, *this, type, path); + } + + std::unique_ptr<std::istream> stream( + const std::string &location) const override + { + // trivial test implementation. + std::unique_ptr<std::stringstream> ss(new std::stringstream()); + (*ss) << "test"; + return std::move(ss); + } +}; + +TEST(ResourceLocator, locate) +{ + TestResourceLocator instance; + ResourceLocator::Location location = + instance.locate("path", "", ResourceLocator::Type::DOMAIN); + ASSERT_TRUE(location.found); + ASSERT_EQ(ResourceLocator::Type::DOMAIN, location.type); + ASSERT_EQ("path", location.location); +} + +TEST(ResourceLocator, stream) +{ + TestResourceLocator instance; + ResourceLocator::Location location = + instance.locate("path", "", ResourceLocator::Type::DOMAIN); + std::unique_ptr<std::istream> is = location.stream(); + + std::string str; + *is >> str; + + ASSERT_EQ("test", str); +} +} diff --git a/test/core/variant/VariantTest.cpp b/test/core/variant/VariantTest.cpp index 270c350..e51cf36 100644 --- a/test/core/variant/VariantTest.cpp +++ b/test/core/variant/VariantTest.cpp @@ -121,6 +121,21 @@ TEST(Variant, mapValue) ASSERT_EQ(2, v2.asMap().find("key1")->second.asArray()[1].asInt()); } +TEST(Variant, relationalOperators){ + Variant a{4}; + Variant b{4}; + + ASSERT_EQ(a,b); + + b.setInt(5); + ASSERT_TRUE(a < b); + + b.setDouble(4); + ASSERT_FALSE(a == b); + + a.setDouble(4); + ASSERT_EQ(a,b); +} } diff --git a/test/plugins/css/CSSParserTest.cpp b/test/plugins/css/CSSParserTest.cpp index 8873673..6499375 100644 --- a/test/plugins/css/CSSParserTest.cpp +++ b/test/plugins/css/CSSParserTest.cpp @@ -120,7 +120,7 @@ TEST(CSSParser, testParseSelectors) Rooted<SelectorNode> Ag = children[1]; ASSERT_EQ("A", Ag->getName()); { - PseudoSelector select{"g", {"4", "2", "3"}, true}; + PseudoSelector select{"g", {Variant(4), Variant(2), Variant(3)}, true}; ASSERT_EQ(select, Ag->getPseudoSelector()); } ASSERT_EQ(0, Ag->getEdges().size()); |