From 1b033795a1780639c1c289524d2ef9ac3e36659d Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 15 Feb 2015 23:23:17 +0100 Subject: Added OsmlParserTest --- test/formats/osml/OsmlParserTest.cpp | 95 ++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 test/formats/osml/OsmlParserTest.cpp (limited to 'test/formats/osml/OsmlParserTest.cpp') diff --git a/test/formats/osml/OsmlParserTest.cpp b/test/formats/osml/OsmlParserTest.cpp new file mode 100644 index 0000000..1ab55f2 --- /dev/null +++ b/test/formats/osml/OsmlParserTest.cpp @@ -0,0 +1,95 @@ +/* + 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 . +*/ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace ousia { + +namespace RttiTypes { +extern const Rtti Document; +extern const Rtti Domain; +extern const Rtti Typesystem; +} + +struct OsmlStandaloneEnvironment : public StandaloneEnvironment { + OsmlParser parser; + FileLocator fileLocator; + + OsmlStandaloneEnvironment(ConcreteLogger &logger) + : StandaloneEnvironment(logger) + { + fileLocator.addDefaultSearchPaths(); + fileLocator.addUnittestSearchPath("osmlparser"); + + registry.registerDefaultExtensions(); + registry.registerParser({"text/vnd.ousia.osml"}, {&RttiTypes::Node}, + &parser); + registry.registerResourceLocator(&fileLocator); + } +}; + +static TerminalLogger logger(std::cerr, true); + +TEST(OsmlParser, empty_document) +{ + OsmlStandaloneEnvironment env(logger); + Rooted node = + env.parse("empty_document.osml", "", "", RttiSet{&RttiTypes::Node}); + + ASSERT_TRUE(node != nullptr); + ASSERT_TRUE(node->isa(&RttiTypes::Document)); +} + +TEST(OsmlParser, empty_domain) +{ + OsmlStandaloneEnvironment env(logger); + Rooted node = + env.parse("empty_domain.osml", "", "", RttiSet{&RttiTypes::Node}); + + ASSERT_TRUE(node != nullptr); + ASSERT_TRUE(node->isa(&RttiTypes::Domain)); + ASSERT_EQ("testDomain", node->getName()); +} + +TEST(OsmlParser, empty_typesystem) +{ + OsmlStandaloneEnvironment env(logger); + Rooted node = + env.parse("empty_typesystem.osml", "", "", RttiSet{&RttiTypes::Node}); + + ASSERT_TRUE(node != nullptr); + ASSERT_TRUE(node->isa(&RttiTypes::Typesystem)); + ASSERT_EQ("testTypesystem", node->getName()); +} +} + -- cgit v1.2.3