aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/CoverageMappingTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index 82e7574..4854b7f 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -895,4 +895,29 @@ INSTANTIATE_TEST_CASE_P(ParameterizedCovMapTest, CoverageMappingTest,
std::pair<bool, bool>({true, false}),
std::pair<bool, bool>({true, true})),);
+TEST(CoverageMappingTest, filename_roundtrip) {
+ std::vector<StringRef> Paths({"a", "b", "c", "d", "e"});
+
+ for (bool Compress : {false, true}) {
+ std::string EncodedFilenames;
+ {
+ raw_string_ostream OS(EncodedFilenames);
+ CoverageFilenamesSectionWriter Writer(Paths);
+ Writer.write(OS, Compress);
+ }
+
+ std::vector<StringRef> ReadFilenames;
+ RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
+ BinaryCoverageReader::DecompressedData Decompressed;
+ EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
+ Succeeded());
+ if (!Compress)
+ ASSERT_EQ(Decompressed.size(), 0U);
+
+ ASSERT_EQ(ReadFilenames.size(), Paths.size());
+ for (unsigned I = 0; I < Paths.size(); ++I)
+ ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
+ }
+}
+
} // end anonymous namespace