TEST_F(VFSFromYAMLTest, TrailingSlashes) { IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); Lower->addRegularFile("//root/other"); // file in roots IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString( "{ 'roots': [\n" " { 'type': 'directory', 'name': '//root/path/to////',\n" " 'contents': [ { 'type': 'file', 'name': 'file',\n" " 'external-contents': '//root/other' }]}]\n" "}", Lower); ASSERT_TRUE(nullptr != FS.getPtr()); EXPECT_FALSE(FS->status("//root/path/to/file").getError()); EXPECT_FALSE(FS->status("//root/path/to").getError()); EXPECT_FALSE(FS->status("//root/path").getError()); EXPECT_FALSE(FS->status("//root/").getError()); }
TEST_F(VFSFromYAMLTest, UseExternalName) { IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); Lower->addRegularFile("//root/external/file"); IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString( "{ 'roots': [\n" " { 'type': 'file', 'name': '//root/A',\n" " 'external-contents': '//root/external/file'\n" " },\n" " { 'type': 'file', 'name': '//root/B',\n" " 'use-external-name': true,\n" " 'external-contents': '//root/external/file'\n" " },\n" " { 'type': 'file', 'name': '//root/C',\n" " 'use-external-name': false,\n" " 'external-contents': '//root/external/file'\n" " }\n" "] }", Lower); ASSERT_TRUE(nullptr != FS.getPtr()); // default true EXPECT_EQ("//root/external/file", FS->status("//root/A")->getName()); // explicit EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); // global configuration FS = getFromYAMLString( "{ 'use-external-names': false,\n" " 'roots': [\n" " { 'type': 'file', 'name': '//root/A',\n" " 'external-contents': '//root/external/file'\n" " },\n" " { 'type': 'file', 'name': '//root/B',\n" " 'use-external-name': true,\n" " 'external-contents': '//root/external/file'\n" " },\n" " { 'type': 'file', 'name': '//root/C',\n" " 'use-external-name': false,\n" " 'external-contents': '//root/external/file'\n" " }\n" "] }", Lower); ASSERT_TRUE(nullptr != FS.getPtr()); // default EXPECT_EQ("//root/A", FS->status("//root/A")->getName()); // explicit EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); }