From 4b76ba887c04458367c37eb3458cbd113475c27f Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 6 May 2022 16:34:06 +0200 Subject: [PATCH] [clangd] Eliminate direct usage of isAvailable() matcher. NFC This prepares to replace the implementation of EXPECT_[UN]AVAILABLE with something more efficient. --- .../clangd/unittests/tweaks/DumpRecordLayoutTests.cpp | 8 ++++---- .../clangd/unittests/tweaks/SwapIfBranchesTests.cpp | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp index 7f7f629..fb0eda2 100644 --- a/clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp +++ b/clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp @@ -22,10 +22,10 @@ TWEAK_TEST(DumpRecordLayout); TEST_F(DumpRecordLayoutTest, Test) { EXPECT_AVAILABLE("^s^truct ^X ^{ int x; ^};"); - EXPECT_THAT("struct X { int ^a; };", Not(isAvailable())); - EXPECT_THAT("struct ^X;", Not(isAvailable())); - EXPECT_THAT("template struct ^X { T t; };", Not(isAvailable())); - EXPECT_THAT("enum ^X {};", Not(isAvailable())); + EXPECT_UNAVAILABLE("struct X { int ^a; };"); + EXPECT_UNAVAILABLE("struct ^X;"); + EXPECT_UNAVAILABLE("template struct ^X { T t; };"); + EXPECT_UNAVAILABLE("enum ^X {};"); EXPECT_THAT(apply("struct ^X { int x; int y; };"), AllOf(StartsWith("message:"), HasSubstr("0 | int x"))); diff --git a/clang-tools-extra/clangd/unittests/tweaks/SwapIfBranchesTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/SwapIfBranchesTests.cpp index b22da9d..0bfada8 100644 --- a/clang-tools-extra/clangd/unittests/tweaks/SwapIfBranchesTests.cpp +++ b/clang-tools-extra/clangd/unittests/tweaks/SwapIfBranchesTests.cpp @@ -27,19 +27,17 @@ TEST_F(SwapIfBranchesTest, Test) { EXPECT_AVAILABLE("^i^f^^(^t^r^u^e^) { return; } ^e^l^s^e^ { return; }"); EXPECT_UNAVAILABLE("if (true) {^return ^;^ } else { ^return^;^ }"); // Available in subexpressions of the condition; - EXPECT_THAT("if(2 + [[2]] + 2) { return; } else {return;}", isAvailable()); + EXPECT_AVAILABLE("if(2 + [[2]] + 2) { return; } else {return;}"); // But not as part of the branches. - EXPECT_THAT("if(2 + 2 + 2) { [[return]]; } else { return; }", - Not(isAvailable())); + EXPECT_UNAVAILABLE("if(2 + 2 + 2) { [[return]]; } else { return; }"); // Range covers the "else" token, so available. - EXPECT_THAT("if(2 + 2 + 2) { return[[; } else {return;]]}", isAvailable()); + EXPECT_AVAILABLE("if(2 + 2 + 2) { return[[; } else {return;]]}"); // Not available in compound statements in condition. - EXPECT_THAT("if([]{return [[true]];}()) { return; } else { return; }", - Not(isAvailable())); + EXPECT_UNAVAILABLE("if([]{return [[true]];}()) { return; } else { return; }"); // Not available if both sides aren't braced. - EXPECT_THAT("^if (1) return; else { return; }", Not(isAvailable())); + EXPECT_UNAVAILABLE("^if (1) return; else { return; }"); // Only one if statement is supported! - EXPECT_THAT("[[if(1){}else{}if(2){}else{}]]", Not(isAvailable())); + EXPECT_UNAVAILABLE("[[if(1){}else{}if(2){}else{}]]"); } } // namespace -- 2.7.4