[NFC] ASSERT_EQ before accessing items in containers
authorKirill Bobyrev <kbobyrev@google.com>
Tue, 26 Nov 2019 12:45:04 +0000 (13:45 +0100)
committerKirill Bobyrev <kbobyrev@google.com>
Tue, 26 Nov 2019 12:45:04 +0000 (13:45 +0100)
commitc547c22f18973dceaf5b40dae1b4ad7d3dd4eab7
tree5e39c0760d95bd09ad47793872fe49b89380e3d4
parentf69ac55d60d916e295ae0e507c5f4c2655360089
[NFC] ASSERT_EQ before accessing items in containers

As discussed offline, something different from `EXPECT_EQ` should be
used to check if the container contains enough items before accessing
them so that other tests can still be run even if the assertion fails as
opposed to having `EXPECT_EQ` failing and then aborting the run due to
the errors caused by out-of-bounds memory access.

Reviewed by: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D70528
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp