2014-01-24 00:09:37 +01:00
|
|
|
#include "archive/ArchiveLookup.hxx"
|
2018-08-20 16:19:17 +02:00
|
|
|
#include "util/Compiler.h"
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2018-10-16 19:01:13 +02:00
|
|
|
#include <gtest/gtest.h>
|
2013-10-17 00:19:22 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
2013-11-05 17:28:23 +01:00
|
|
|
#include <stdlib.h>
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2018-10-16 19:01:13 +02:00
|
|
|
TEST(ArchiveTest, Lookup)
|
2013-10-17 00:19:22 +02:00
|
|
|
{
|
2019-06-15 14:06:50 +02:00
|
|
|
EXPECT_THROW(archive_lookup(Path::FromFS("")), std::system_error);
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2019-06-15 14:06:50 +02:00
|
|
|
EXPECT_FALSE(archive_lookup(Path::FromFS(".")));
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2019-06-15 14:06:50 +02:00
|
|
|
EXPECT_FALSE(archive_lookup(Path::FromFS("config.h")));
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2019-06-15 14:06:50 +02:00
|
|
|
EXPECT_THROW(archive_lookup(Path::FromFS("src/foo/bar")), std::system_error);
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2017-12-29 17:12:55 +01:00
|
|
|
fclose(fopen("dummy", "w"));
|
|
|
|
|
2019-06-15 14:06:50 +02:00
|
|
|
auto result = archive_lookup(Path::FromFS("dummy/foo/bar"));
|
2019-05-31 19:29:13 +02:00
|
|
|
EXPECT_TRUE(result);
|
|
|
|
EXPECT_STREQ(result.archive.c_str(), "dummy");
|
|
|
|
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
2013-10-17 00:19:22 +02:00
|
|
|
|
2019-06-15 14:06:50 +02:00
|
|
|
result = archive_lookup(Path::FromFS("config.h/foo/bar"));
|
2019-05-31 19:29:13 +02:00
|
|
|
EXPECT_TRUE(result);
|
|
|
|
EXPECT_STREQ(result.archive.c_str(), "config.h");
|
|
|
|
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
2013-10-17 00:19:22 +02:00
|
|
|
}
|