kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay,
ilya-biryukov.
Herald added a project: clang.
When dereferencing Optional's it makes sense to use ASSERT_TRUE for better
test failures readability. Switch from EXPECT_TRUE to ASSERT_TRUE where
it is appropriate.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84535
Files:
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -49,11 +49,11 @@
"clangd/unittests/remote/MarshallingTests.cpp",
Strings);
auto Serialized = ProtobufMarshaller.toProtobuf(Original);
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
EXPECT_EQ(Serialized->location().file_path(),
"clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
- EXPECT_TRUE(Deserialized);
+ ASSERT_TRUE(Deserialized);
EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -73,7 +73,7 @@
// Can not use URIs with scheme different from "file".
auto UnittestURI =
URI::create(testPath("project/lib/HelloWorld.cpp"), "unittest");
- EXPECT_TRUE(bool(UnittestURI));
+ ASSERT_TRUE(bool(UnittestURI));
WithInvalidURI.Location.FileURI =
Strings.save(UnittestURI->toString()).begin();
Serialized = ProtobufMarshaller.toProtobuf(WithInvalidURI);
@@ -92,7 +92,7 @@
clangd::Symbol Sym;
auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
- EXPECT_TRUE(bool(ID));
+ ASSERT_TRUE(bool(ID));
Sym.ID = *ID;
index::SymbolInfo Info;
@@ -140,9 +140,9 @@
// Check that symbols are exactly the same if the path to indexed project is
// the same on indexing machine and the client.
auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
- EXPECT_TRUE(Deserialized);
+ ASSERT_TRUE(Deserialized);
EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
// Serialized paths are relative and have UNIX slashes.
EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -154,7 +154,7 @@
// Missing definition is OK.
Sym.Definition = clangd::SymbolLocation();
Serialized = ProtobufMarshaller.toProtobuf(Sym);
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
EXPECT_TRUE(Deserialized);
@@ -172,7 +172,7 @@
// Schemes other than "file" can not be used.
auto UnittestURI = URI::create(testPath("home/SomePath.h"), "unittest");
- EXPECT_TRUE(bool(UnittestURI));
+ ASSERT_TRUE(bool(UnittestURI));
Location.FileURI = Strings.save(UnittestURI->toString()).begin();
Sym.Definition = Location;
Serialized = ProtobufMarshaller.toProtobuf(Sym);
@@ -183,9 +183,9 @@
Sym.Definition = Location;
// Check that the symbol is valid and passing the correct path works.
Serialized = ProtobufMarshaller.toProtobuf(Sym);
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
- EXPECT_TRUE(Deserialized);
+ ASSERT_TRUE(Deserialized);
EXPECT_STREQ(Deserialized->Definition.FileURI,
testPathURI("home/File.h", Strings));
// Fail with a wrong root.
@@ -214,9 +214,9 @@
testPath("llvm-project/"));
auto Serialized = ProtobufMarshaller.toProtobuf(Ref);
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
- EXPECT_TRUE(Deserialized);
+ ASSERT_TRUE(Deserialized);
EXPECT_EQ(toYAML(Ref), toYAML(*Deserialized));
}
@@ -272,9 +272,9 @@
auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
EXPECT_EQ(static_cast<size_t>(Serialized->headers_size()),
ValidHeaders.size());
- EXPECT_TRUE(Serialized);
+ ASSERT_TRUE(Serialized);
auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
- EXPECT_TRUE(Deserialized);
+ ASSERT_TRUE(Deserialized);
Sym.IncludeHeaders = ValidHeaders;
EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits