From 47311cc8b211a7fef033d744d9eba9f308726ea8 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 20 Jan 2015 00:53:49 +0100 Subject: Refactored stuff surrounding the ResourceLocator class, implemented StaticResourceLocator which can be used for registering static resources (mainly for testing or if certain resources need to be available from the executable) --- test/core/resource/ResourceLocatorTest.cpp | 53 ++++++++++-------------------- 1 file changed, 18 insertions(+), 35 deletions(-) (limited to 'test/core/resource') diff --git a/test/core/resource/ResourceLocatorTest.cpp b/test/core/resource/ResourceLocatorTest.cpp index ebb164d..d009883 100644 --- a/test/core/resource/ResourceLocatorTest.cpp +++ b/test/core/resource/ResourceLocatorTest.cpp @@ -18,48 +18,31 @@ #include -#include - -#include +#include 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 stream( - const std::string &location) const override - { - // trivial test implementation. - std::unique_ptr ss(new std::stringstream()); - (*ss) << "test"; - return std::move(ss); - } -}; - -TEST(ResourceLocator, locate) +TEST(StaticResourceLocator, locate) { - TestResourceLocator instance; - ResourceLocator::Location location = - instance.locate("path", "", ResourceLocator::Type::DOMAIN_DESC); - ASSERT_TRUE(location.found); - ASSERT_EQ(ResourceLocator::Type::DOMAIN_DESC, location.type); - ASSERT_EQ("path", location.location); + StaticResourceLocator locator; + locator.store("path", "test"); + + Resource res; + ASSERT_TRUE(locator.locate(res, "path")); + ASSERT_TRUE(res.isValid()); + ASSERT_EQ(ResourceType::UNKNOWN, res.getType()); + ASSERT_EQ("path", res.getLocation()); } -TEST(ResourceLocator, stream) +TEST(StaticResourceLocator, stream) { - TestResourceLocator instance; - ResourceLocator::Location location = - instance.locate("path", "", ResourceLocator::Type::DOMAIN_DESC); - std::unique_ptr is = location.stream(); + StaticResourceLocator locator; + locator.store("path", "test"); + + Resource res; + ASSERT_TRUE(locator.locate(res, "path")); + + auto is = res.stream(); std::string str; *is >> str; -- cgit v1.2.3