archive/Lookup: move to fs/LookupFile.cxx
This can be used for other purposes as well.
This commit is contained in:
30
test/TestLookupFile.cxx
Normal file
30
test/TestLookupFile.cxx
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "fs/LookupFile.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TEST(ArchiveTest, Lookup)
|
||||
{
|
||||
EXPECT_THROW(LookupFile(Path::FromFS("")), std::system_error);
|
||||
|
||||
EXPECT_FALSE(LookupFile(Path::FromFS(".")));
|
||||
|
||||
EXPECT_FALSE(LookupFile(Path::FromFS("config.h")));
|
||||
|
||||
EXPECT_THROW(LookupFile(Path::FromFS("src/foo/bar")), std::system_error);
|
||||
|
||||
fclose(fopen("dummy", "w"));
|
||||
|
||||
auto result = LookupFile(Path::FromFS("dummy/foo/bar"));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ(result.archive.c_str(), "dummy");
|
||||
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
||||
|
||||
result = LookupFile(Path::FromFS("config.h/foo/bar"));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ(result.archive.c_str(), "config.h");
|
||||
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
||||
}
|
@@ -92,6 +92,9 @@ test('test_queue_priority', executable(
|
||||
test('TestFs', executable(
|
||||
'TestFs',
|
||||
'TestFs.cxx',
|
||||
'TestLookupFile.cxx',
|
||||
'../src/Log.cxx',
|
||||
'../src/LogBackend.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
fs_dep,
|
||||
@@ -339,18 +342,6 @@ endif
|
||||
#
|
||||
|
||||
if archive_glue_dep.found()
|
||||
test('test_archive', executable(
|
||||
'test_archive',
|
||||
'test_archive.cxx',
|
||||
'../src/Log.cxx',
|
||||
'../src/LogBackend.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
archive_glue_dep,
|
||||
gtest_dep,
|
||||
],
|
||||
))
|
||||
|
||||
executable(
|
||||
'visit_archive',
|
||||
'visit_archive.cxx',
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#include "archive/ArchiveLookup.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TEST(ArchiveTest, Lookup)
|
||||
{
|
||||
EXPECT_THROW(archive_lookup(Path::FromFS("")), std::system_error);
|
||||
|
||||
EXPECT_FALSE(archive_lookup(Path::FromFS(".")));
|
||||
|
||||
EXPECT_FALSE(archive_lookup(Path::FromFS("config.h")));
|
||||
|
||||
EXPECT_THROW(archive_lookup(Path::FromFS("src/foo/bar")), std::system_error);
|
||||
|
||||
fclose(fopen("dummy", "w"));
|
||||
|
||||
auto result = archive_lookup(Path::FromFS("dummy/foo/bar"));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ(result.archive.c_str(), "dummy");
|
||||
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
||||
|
||||
result = archive_lookup(Path::FromFS("config.h/foo/bar"));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ(result.archive.c_str(), "config.h");
|
||||
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
|
||||
}
|
Reference in New Issue
Block a user