@@ -43,25 +43,27 @@ std::optional<std::string> GetFileContents(const std::filesystem::path& path) {
4343}
4444} // namespace
4545
46- TEST (FileCopierTest, ToIndexPath ) {
46+ TEST (FileCopierTest, AbsoluteToIndexPath ) {
4747 auto tmp_dir_path = std::filesystem::path (::testing::TempDir ());
4848 auto base_path = tmp_dir_path / " src" ;
4949 auto index_path = tmp_dir_path / " idx" ;
5050 FileCopier file_copier (base_path.string (), index_path.string (), {" /" });
5151
52- EXPECT_EQ (file_copier.ToIndexPath (" /a/b/c/d.cc" ), " /a/b/c/d.cc" );
53- EXPECT_EQ (file_copier.ToIndexPath ((base_path / " a/b/c/d.cc" ).string ()),
54- " a/b/c/d.cc" );
55- EXPECT_EQ (file_copier.ToIndexPath (" a/b/c/d.cc" ), " a/b/c/d.cc" );
52+ EXPECT_EQ (file_copier.AbsoluteToIndexPath (" /a/b/c/d.cc" ), " /a/b/c/d.cc" );
53+ EXPECT_EQ (
54+ file_copier.AbsoluteToIndexPath ((base_path / " a/b/c/d.cc" ).string ()),
55+ " a/b/c/d.cc" );
56+ EXPECT_DEATH (file_copier.AbsoluteToIndexPath (" a/b/c/d.cc" ),
57+ " Absolute path expected" );
5658}
5759
58- TEST (FileCopierTest, ToIndexPathOutside ) {
60+ TEST (FileCopierTest, AbsoluteToIndexPathOutside ) {
5961 auto tmp_dir_path = std::filesystem::path (::testing::TempDir ());
6062 auto base_path = tmp_dir_path / " src" ;
6163 auto index_path = tmp_dir_path / " idx" ;
6264 FileCopier file_copier (base_path.string (), index_path.string (), {" /sysroot" });
6365
64- EXPECT_DEATH (file_copier.ToIndexPath (" /a/b/c/d.cc" ), " /a/b/c/d.cc" );
66+ EXPECT_DEATH (file_copier.AbsoluteToIndexPath (" /a/b/c/d.cc" ), " /a/b/c/d.cc" );
6567}
6668
6769TEST (FileCopierTest, FileCopying) {
@@ -85,9 +87,12 @@ TEST(FileCopierTest, FileCopying) {
8587 auto file_c_copy = index_path / " absolute" /
8688 sysroot_path.lexically_relative (" /" ) / " y/z/c.cc" ;
8789
88- file_copier.RegisterIndexedFile (file_copier.ToIndexPath (file_a.string ()));
89- file_copier.RegisterIndexedFile (file_copier.ToIndexPath (file_b.string ()));
90- file_copier.RegisterIndexedFile (file_copier.ToIndexPath (file_c.string ()));
90+ file_copier.RegisterIndexedFile (
91+ file_copier.AbsoluteToIndexPath (file_a.string ()));
92+ file_copier.RegisterIndexedFile (
93+ file_copier.AbsoluteToIndexPath (file_b.string ()));
94+ file_copier.RegisterIndexedFile (
95+ file_copier.AbsoluteToIndexPath (file_c.string ()));
9196
9297 file_copier.CopyIndexedFiles ();
9398
0 commit comments