mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 09:46:05 +00:00

The error messages in tests are far better when a test fails if the test is written using ASSERT_/EXPECT_<operator>(A, B) rather than ASSERT_/EXPECT_TRUE(A <operator> B). This commit updates all of llvm/unittests/Support to use these macros where possible. This change has not been possible in: - llvm/unittests/Support/FSUniqueIDTest.cpp - due to not overloading operators beyond ==, != and <. - llvm/unittests/Support/BranchProbabilityTest.cpp - where the unchanged tests are of the operator overloads themselves. There are other possibilities of this conversion not being valid, which have not applied in these tests, as they do not use NULL (they use nullptr), and they do not use const char* (they use std::string or StringRef). Reviewed By: mubashar_ Differential Revision: https://reviews.llvm.org/D117319
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
//===- llvm/unittest/Support/FSUniqueIDTest.cpp - Test sys::fs::UniqueID --===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Support/FileSystem/UniqueID.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::sys::fs;
|
|
|
|
namespace {
|
|
|
|
TEST(FSUniqueIDTest, construct) {
|
|
EXPECT_EQ(20u, UniqueID(20, 10).getDevice());
|
|
EXPECT_EQ(10u, UniqueID(20, 10).getFile());
|
|
}
|
|
|
|
TEST(FSUniqueIDTest, equals) {
|
|
EXPECT_EQ(UniqueID(20, 10), UniqueID(20, 10));
|
|
EXPECT_NE(UniqueID(20, 20), UniqueID(20, 10));
|
|
EXPECT_NE(UniqueID(10, 10), UniqueID(20, 10));
|
|
}
|
|
|
|
TEST(FSUniqueIDTest, less) {
|
|
EXPECT_FALSE(UniqueID(20, 2) < UniqueID(20, 2));
|
|
EXPECT_FALSE(UniqueID(20, 3) < UniqueID(20, 2));
|
|
EXPECT_FALSE(UniqueID(30, 2) < UniqueID(20, 2));
|
|
EXPECT_FALSE(UniqueID(30, 2) < UniqueID(20, 40));
|
|
EXPECT_TRUE(UniqueID(20, 2) < UniqueID(20, 3));
|
|
EXPECT_TRUE(UniqueID(20, 2) < UniqueID(30, 2));
|
|
EXPECT_TRUE(UniqueID(20, 40) < UniqueID(30, 2));
|
|
}
|
|
|
|
} // anonymous namespace
|