diff options
Diffstat (limited to 'unittests/Support')
-rw-r--r-- | unittests/Support/Casting.cpp | 8 | ||||
-rw-r--r-- | unittests/Support/CommandLineTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/DataExtractorTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/ErrorOrTest.cpp | 8 | ||||
-rw-r--r-- | unittests/Support/ManagedStatic.cpp | 10 | ||||
-rw-r--r-- | unittests/Support/MemoryBufferTest.cpp | 20 | ||||
-rw-r--r-- | unittests/Support/MemoryTest.cpp | 93 | ||||
-rw-r--r-- | unittests/Support/ProgramTest.cpp | 36 | ||||
-rw-r--r-- | unittests/Support/ThreadLocalTest.cpp | 4 | ||||
-rw-r--r-- | unittests/Support/TimeValueTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/YAMLIOTest.cpp | 48 | ||||
-rw-r--r-- | unittests/Support/raw_ostream_test.cpp | 4 |
12 files changed, 122 insertions, 115 deletions
diff --git a/unittests/Support/Casting.cpp b/unittests/Support/Casting.cpp index 228c90bb8b..88c7d19aa4 100644 --- a/unittests/Support/Casting.cpp +++ b/unittests/Support/Casting.cpp @@ -18,7 +18,7 @@ namespace llvm { // Used to test illegal cast. If a cast doesn't match any of the "real" ones, // it will match this one. struct IllegalCast; -template <typename T> IllegalCast *cast(...) { return 0; } +template <typename T> IllegalCast *cast(...) { return nullptr; } // set up two example classes // with conversion facility @@ -90,7 +90,7 @@ static_assert(std::is_same<simplify_type<foo *>::SimpleType, foo *>::value, namespace { -const foo *null_foo = NULL; +const foo *null_foo = nullptr; bar B; extern bar &B1; @@ -175,7 +175,7 @@ TEST(CastingTest, dyn_cast_or_null) { const bar *B2 = &B; } // anonymous namespace -bar *llvm::fub() { return 0; } +bar *llvm::fub() { return nullptr; } namespace { namespace inferred_upcasting { @@ -203,7 +203,7 @@ TEST(CastingTest, UpcastIsInferred) { Derived D; EXPECT_TRUE(isa<Base>(D)); Base *BP = dyn_cast<Base>(&D); - EXPECT_TRUE(BP != NULL); + EXPECT_TRUE(BP != nullptr); } diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp index b0f1eb1ad6..b2d71ab795 100644 --- a/unittests/Support/CommandLineTest.cpp +++ b/unittests/Support/CommandLineTest.cpp @@ -23,7 +23,7 @@ class TempEnvVar { TempEnvVar(const char *name, const char *value) : name(name) { const char *old_value = getenv(name); - EXPECT_EQ(NULL, old_value) << old_value; + EXPECT_EQ(nullptr, old_value) << old_value; #if HAVE_SETENV setenv(name, value, true); #else diff --git a/unittests/Support/DataExtractorTest.cpp b/unittests/Support/DataExtractorTest.cpp index ec8bd3d18c..81de983d22 100644 --- a/unittests/Support/DataExtractorTest.cpp +++ b/unittests/Support/DataExtractorTest.cpp @@ -94,7 +94,7 @@ TEST(DataExtractorTest, Strings) { EXPECT_EQ(stringData, DE.getCStr(&offset)); EXPECT_EQ(11U, offset); - EXPECT_EQ(NULL, DE.getCStr(&offset)); + EXPECT_EQ(nullptr, DE.getCStr(&offset)); EXPECT_EQ(11U, offset); } diff --git a/unittests/Support/ErrorOrTest.cpp b/unittests/Support/ErrorOrTest.cpp index 18ce507b88..7ace5e3e81 100644 --- a/unittests/Support/ErrorOrTest.cpp +++ b/unittests/Support/ErrorOrTest.cpp @@ -54,10 +54,10 @@ struct B {}; struct D : B {}; TEST(ErrorOr, Covariant) { - ErrorOr<B*> b(ErrorOr<D*>(0)); - b = ErrorOr<D*>(0); + ErrorOr<B*> b(ErrorOr<D*>(nullptr)); + b = ErrorOr<D*>(nullptr); - ErrorOr<std::unique_ptr<B> > b1(ErrorOr<std::unique_ptr<D> >(0)); - b1 = ErrorOr<std::unique_ptr<D> >(0); + ErrorOr<std::unique_ptr<B> > b1(ErrorOr<std::unique_ptr<D> >(nullptr)); + b1 = ErrorOr<std::unique_ptr<D> >(nullptr); } } // end anon namespace diff --git a/unittests/Support/ManagedStatic.cpp b/unittests/Support/ManagedStatic.cpp index 1497f4e340..ad2fc977e6 100644 --- a/unittests/Support/ManagedStatic.cpp +++ b/unittests/Support/ManagedStatic.cpp @@ -25,7 +25,7 @@ namespace test1 { llvm::ManagedStatic<int> ms; void *helper(void*) { *ms; - return NULL; + return nullptr; } // Valgrind's leak checker complains glibc's stack allocation. @@ -49,10 +49,10 @@ TEST(Initialize, MultipleThreads) { llvm_start_multithreaded(); pthread_t t1, t2; - pthread_create(&t1, &a1, test1::helper, NULL); - pthread_create(&t2, &a2, test1::helper, NULL); - pthread_join(t1, NULL); - pthread_join(t2, NULL); + pthread_create(&t1, &a1, test1::helper, nullptr); + pthread_create(&t2, &a2, test1::helper, nullptr); + pthread_join(t1, nullptr); + pthread_join(t2, nullptr); free(p1); free(p2); llvm_stop_multithreaded(); diff --git a/unittests/Support/MemoryBufferTest.cpp b/unittests/Support/MemoryBufferTest.cpp index 6790d0c53b..b7d0c206e8 100644 --- a/unittests/Support/MemoryBufferTest.cpp +++ b/unittests/Support/MemoryBufferTest.cpp @@ -43,15 +43,15 @@ protected: TEST_F(MemoryBufferTest, get) { // Default name and null-terminator flag OwningBuffer MB1(MemoryBuffer::getMemBuffer(data)); - EXPECT_TRUE(0 != MB1.get()); + EXPECT_TRUE(nullptr != MB1.get()); // RequiresNullTerminator = false OwningBuffer MB2(MemoryBuffer::getMemBuffer(data, "one", false)); - EXPECT_TRUE(0 != MB2.get()); + EXPECT_TRUE(nullptr != MB2.get()); // RequiresNullTerminator = true OwningBuffer MB3(MemoryBuffer::getMemBuffer(data, "two", true)); - EXPECT_TRUE(0 != MB3.get()); + EXPECT_TRUE(nullptr != MB3.get()); // verify all 3 buffers point to the same address EXPECT_EQ(MB1->getBufferStart(), MB2->getBufferStart()); @@ -89,11 +89,11 @@ TEST_F(MemoryBufferTest, NullTerminator4K) { TEST_F(MemoryBufferTest, copy) { // copy with no name OwningBuffer MBC1(MemoryBuffer::getMemBufferCopy(data)); - EXPECT_TRUE(0 != MBC1.get()); + EXPECT_TRUE(nullptr != MBC1.get()); // copy with a name OwningBuffer MBC2(MemoryBuffer::getMemBufferCopy(data, "copy")); - EXPECT_TRUE(0 != MBC2.get()); + EXPECT_TRUE(nullptr != MBC2.get()); // verify the two copies do not point to the same place EXPECT_NE(MBC1->getBufferStart(), MBC2->getBufferStart()); @@ -102,25 +102,25 @@ TEST_F(MemoryBufferTest, copy) { TEST_F(MemoryBufferTest, make_new) { // 0-sized buffer OwningBuffer Zero(MemoryBuffer::getNewUninitMemBuffer(0)); - EXPECT_TRUE(0 != Zero.get()); + EXPECT_TRUE(nullptr != Zero.get()); // uninitialized buffer with no name OwningBuffer One(MemoryBuffer::getNewUninitMemBuffer(321)); - EXPECT_TRUE(0 != One.get()); + EXPECT_TRUE(nullptr != One.get()); // uninitialized buffer with name OwningBuffer Two(MemoryBuffer::getNewUninitMemBuffer(123, "bla")); - EXPECT_TRUE(0 != Two.get()); + EXPECT_TRUE(nullptr != Two.get()); // 0-initialized buffer with no name OwningBuffer Three(MemoryBuffer::getNewMemBuffer(321, data)); - EXPECT_TRUE(0 != Three.get()); + EXPECT_TRUE(nullptr != Three.get()); for (size_t i = 0; i < 321; ++i) EXPECT_EQ(0, Three->getBufferStart()[0]); // 0-initialized buffer with name OwningBuffer Four(MemoryBuffer::getNewMemBuffer(123, "zeros")); - EXPECT_TRUE(0 != Four.get()); + EXPECT_TRUE(nullptr != Four.get()); for (size_t i = 0; i < 123; ++i) EXPECT_EQ(0, Four->getBufferStart()[0]); } diff --git a/unittests/Support/MemoryTest.cpp b/unittests/Support/MemoryTest.cpp index 9d0cb54a13..f85f3dc312 100644 --- a/unittests/Support/MemoryTest.cpp +++ b/unittests/Support/MemoryTest.cpp @@ -58,10 +58,10 @@ protected: TEST_P(MappedMemoryTest, AllocAndRelease) { error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(sizeof(int), M1.size()); EXPECT_FALSE(Memory::releaseMappedMemory(M1)); @@ -69,18 +69,18 @@ TEST_P(MappedMemoryTest, AllocAndRelease) { TEST_P(MappedMemoryTest, MultipleAllocAndRelease) { error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC); + MemoryBlock M2 = Memory::allocateMappedMemory(64, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC); + MemoryBlock M3 = Memory::allocateMappedMemory(32, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(16U, M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(64U, M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(32U, M3.size()); EXPECT_FALSE(doesOverlap(M1, M2)); @@ -89,9 +89,9 @@ TEST_P(MappedMemoryTest, MultipleAllocAndRelease) { EXPECT_FALSE(Memory::releaseMappedMemory(M1)); EXPECT_FALSE(Memory::releaseMappedMemory(M3)); - MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC); + MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M4.base()); + EXPECT_NE((void*)nullptr, M4.base()); EXPECT_LE(16U, M4.size()); EXPECT_FALSE(Memory::releaseMappedMemory(M4)); EXPECT_FALSE(Memory::releaseMappedMemory(M2)); @@ -104,10 +104,10 @@ TEST_P(MappedMemoryTest, BasicWrite) { return; error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(sizeof(int), M1.size()); int *a = (int*)M1.base(); @@ -123,22 +123,25 @@ TEST_P(MappedMemoryTest, MultipleWrite) { !((Flags & Memory::MF_READ) && (Flags & Memory::MF_WRITE))) return; error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC); + MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC); + MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); EXPECT_FALSE(doesOverlap(M1, M2)); EXPECT_FALSE(doesOverlap(M2, M3)); EXPECT_FALSE(doesOverlap(M1, M3)); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(1U * sizeof(int), M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(8U * sizeof(int), M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(4U * sizeof(int), M3.size()); int *x = (int*)M1.base(); @@ -159,9 +162,10 @@ TEST_P(MappedMemoryTest, MultipleWrite) { EXPECT_FALSE(Memory::releaseMappedMemory(M1)); EXPECT_FALSE(Memory::releaseMappedMemory(M3)); - MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC); + MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), nullptr, + Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M4.base()); + EXPECT_NE((void*)nullptr, M4.base()); EXPECT_LE(64U * sizeof(int), M4.size()); x = (int*)M4.base(); *x = 4; @@ -177,18 +181,21 @@ TEST_P(MappedMemoryTest, MultipleWrite) { TEST_P(MappedMemoryTest, EnabledWrite) { error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC); + MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); - MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC); + MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags, + EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(2U * sizeof(int), M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(8U * sizeof(int), M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(4U * sizeof(int), M3.size()); EXPECT_FALSE(Memory::protectMappedMemory(M1, getTestableEquivalent(Flags))); @@ -216,9 +223,9 @@ TEST_P(MappedMemoryTest, EnabledWrite) { EXPECT_FALSE(Memory::releaseMappedMemory(M3)); EXPECT_EQ(6, y[6]); - MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC); + MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M4.base()); + EXPECT_NE((void*)nullptr, M4.base()); EXPECT_LE(16U, M4.size()); EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags))); x = (int*)M4.base(); @@ -230,18 +237,18 @@ TEST_P(MappedMemoryTest, EnabledWrite) { TEST_P(MappedMemoryTest, SuccessiveNear) { error_code EC; - MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC); + MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC); EXPECT_EQ(error_code(), EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC); EXPECT_EQ(error_code(), EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(16U, M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(64U, M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(32U, M3.size()); EXPECT_FALSE(doesOverlap(M1, M2)); @@ -263,11 +270,11 @@ TEST_P(MappedMemoryTest, DuplicateNear) { MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(16U, M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(64U, M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(32U, M3.size()); EXPECT_FALSE(Memory::releaseMappedMemory(M1)); @@ -277,7 +284,7 @@ TEST_P(MappedMemoryTest, DuplicateNear) { TEST_P(MappedMemoryTest, ZeroNear) { error_code EC; - MemoryBlock Near(0, 0); + MemoryBlock Near(nullptr, 0); MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC); EXPECT_EQ(error_code(), EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC); @@ -285,11 +292,11 @@ TEST_P(MappedMemoryTest, ZeroNear) { MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(16U, M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(64U, M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(32U, M3.size()); EXPECT_FALSE(doesOverlap(M1, M2)); @@ -311,11 +318,11 @@ TEST_P(MappedMemoryTest, ZeroSizeNear) { MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(16U, M1.size()); - EXPECT_NE((void*)0, M2.base()); + EXPECT_NE((void*)nullptr, M2.base()); EXPECT_LE(64U, M2.size()); - EXPECT_NE((void*)0, M3.base()); + EXPECT_NE((void*)nullptr, M3.base()); EXPECT_LE(32U, M3.size()); EXPECT_FALSE(doesOverlap(M1, M2)); @@ -333,7 +340,7 @@ TEST_P(MappedMemoryTest, UnalignedNear) { MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC); EXPECT_EQ(error_code(), EC); - EXPECT_NE((void*)0, M1.base()); + EXPECT_NE((void*)nullptr, M1.base()); EXPECT_LE(sizeof(int), M1.size()); EXPECT_FALSE(Memory::releaseMappedMemory(M1)); diff --git a/unittests/Support/ProgramTest.cpp b/unittests/Support/ProgramTest.cpp index d8cb42af03..4e7316fb3a 100644 --- a/unittests/Support/ProgramTest.cpp +++ b/unittests/Support/ProgramTest.cpp @@ -54,7 +54,7 @@ static void CopyEnvironment(std::vector<const char *> &out) { // environ seems to work for Windows and most other Unices. char **envp = environ; #endif - while (*envp != 0) { + while (*envp != nullptr) { out.push_back(*envp); ++envp; } @@ -76,14 +76,14 @@ TEST(ProgramTest, CreateProcessTrailingSlash) { "--gtest_filter=ProgramTest.CreateProcessTrailingSlash", "-program-test-string-arg1", "has\\\\ trailing\\", "-program-test-string-arg2", "has\\\\ trailing\\", - 0 + nullptr }; // Add LLVM_PROGRAM_TEST_CHILD to the environment of the child. std::vector<const char *> envp; CopyEnvironment(envp); envp.push_back("LLVM_PROGRAM_TEST_CHILD=1"); - envp.push_back(0); + envp.push_back(nullptr); std::string error; bool ExecutionFailed; @@ -93,7 +93,7 @@ TEST(ProgramTest, CreateProcessTrailingSlash) { #else StringRef nul("/dev/null"); #endif - const StringRef *redirects[] = { &nul, &nul, 0 }; + const StringRef *redirects[] = { &nul, &nul, nullptr }; int rc = ExecuteAndWait(my_exe, argv, &envp[0], redirects, /*secondsToWait=*/ 10, /*memoryLimit=*/ 0, &error, &ExecutionFailed); @@ -114,19 +114,19 @@ TEST(ProgramTest, TestExecuteNoWait) { const char *argv[] = { Executable.c_str(), "--gtest_filter=ProgramTest.TestExecuteNoWait", - 0 + nullptr }; // Add LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT to the environment of the child. std::vector<const char *> envp; CopyEnvironment(envp); envp.push_back("LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT=1"); - envp.push_back(0); + envp.push_back(nullptr); std::string Error; bool ExecutionFailed; - ProcessInfo PI1 = - ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed); + ProcessInfo PI1 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0, + &Error, &ExecutionFailed); ASSERT_FALSE(ExecutionFailed) << Error; ASSERT_NE(PI1.Pid, 0) << "Invalid process id"; @@ -144,8 +144,8 @@ TEST(ProgramTest, TestExecuteNoWait) { EXPECT_EQ(LoopCount, 1u) << "LoopCount should be 1"; - ProcessInfo PI2 = - ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed); + ProcessInfo PI2 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0, + &Error, &ExecutionFailed); ASSERT_FALSE(ExecutionFailed) << Error; ASSERT_NE(PI2.Pid, 0) << "Invalid process id"; @@ -175,32 +175,32 @@ TEST(ProgramTest, TestExecuteAndWaitTimeout) { const char *argv[] = { Executable.c_str(), "--gtest_filter=ProgramTest.TestExecuteAndWaitTimeout", - 0 + nullptr }; // Add LLVM_PROGRAM_TEST_TIMEOUT to the environment of the child. std::vector<const char *> envp; CopyEnvironment(envp); envp.push_back("LLVM_PROGRAM_TEST_TIMEOUT=1"); - envp.push_back(0); + envp.push_back(nullptr); std::string Error; bool ExecutionFailed; int RetCode = - ExecuteAndWait(Executable, argv, &envp[0], 0, /*secondsToWait=*/1, 0, + ExecuteAndWait(Executable, argv, &envp[0], nullptr, /*secondsToWait=*/1, 0, &Error, &ExecutionFailed); ASSERT_EQ(-2, RetCode); } TEST(ProgramTest, TestExecuteNegative) { std::string Executable = "i_dont_exist"; - const char *argv[] = { Executable.c_str(), 0 }; + const char *argv[] = { Executable.c_str(), nullptr }; { std::string Error; bool ExecutionFailed; - int RetCode = - ExecuteAndWait(Executable, argv, 0, 0, 0, 0, &Error, &ExecutionFailed); + int RetCode = ExecuteAndWait(Executable, argv, nullptr, nullptr, 0, 0, + &Error, &ExecutionFailed); ASSERT_TRUE(RetCode < 0) << "On error ExecuteAndWait should return 0 or " "positive value indicating the result code"; ASSERT_TRUE(ExecutionFailed); @@ -210,8 +210,8 @@ TEST(ProgramTest, TestExecuteNegative) { { std::string Error; bool ExecutionFailed; - ProcessInfo PI = - ExecuteNoWait(Executable, argv, 0, 0, 0, &Error, &ExecutionFailed); + ProcessInfo PI = ExecuteNoWait(Executable, argv, nullptr, nullptr, 0, + &Error, &ExecutionFailed); ASSERT_EQ(PI.Pid, 0) << "On error ExecuteNoWait should return an invalid ProcessInfo"; ASSERT_TRUE(ExecutionFailed); diff --git a/unittests/Support/ThreadLocalTest.cpp b/unittests/Support/ThreadLocalTest.cpp index dd4d706f5c..ea751be230 100644 --- a/unittests/Support/ThreadLocalTest.cpp +++ b/unittests/Support/ThreadLocalTest.cpp @@ -25,14 +25,14 @@ struct S { TEST_F(ThreadLocalTest, Basics) { ThreadLocal<const S> x; - EXPECT_EQ(0, x.get()); + EXPECT_EQ(nullptr, x.get()); S s; x.set(&s); EXPECT_EQ(&s, x.get()); x.erase(); - EXPECT_EQ(0, x.get()); + EXPECT_EQ(nullptr, x.get()); } } diff --git a/unittests/Support/TimeValueTest.cpp b/unittests/Support/TimeValueTest.cpp index 8058812ff4..3d2b9780c0 100644 --- a/unittests/Support/TimeValueTest.cpp +++ b/unittests/Support/TimeValueTest.cpp @@ -16,7 +16,7 @@ namespace { TEST(TimeValue, time_t) { sys::TimeValue now = sys::TimeValue::now(); - time_t now_t = time(NULL); + time_t now_t = time(nullptr); EXPECT_TRUE(std::abs(static_cast<long>(now_t - now.toEpochTime())) < 2); } diff --git a/unittests/Support/YAMLIOTest.cpp b/unittests/Support/YAMLIOTest.cpp index ffabbcfe05..8aed98012f 100644 --- a/unittests/Support/YAMLIOTest.cpp +++ b/unittests/Support/YAMLIOTest.cpp @@ -1204,7 +1204,7 @@ TEST(YAMLIO, TestValidatingInput) { std::vector<MyValidation> docList; Input yin("--- \nvalue: 3.0\n" "--- \nvalue: -1.0\n...\n", - NULL, suppressErrorMessages); + nullptr, suppressErrorMessages); yin >> docList; EXPECT_TRUE(!!yin.error()); } @@ -1224,7 +1224,7 @@ TEST(YAMLIO, TestColorsReadError) { "c2: purple\n" "c3: green\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> map; EXPECT_TRUE(!!yin.error()); @@ -1241,7 +1241,7 @@ TEST(YAMLIO, TestFlagsReadError) { "f2: [ round, hollow ]\n" "f3: []\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> map; @@ -1260,7 +1260,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint8Error) { "- 0\n" "- 257\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1279,7 +1279,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint16Error) { "- 0\n" "- 66000\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1298,7 +1298,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint32Error) { "- 0\n" "- 5000000000\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1317,7 +1317,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint64Error) { "- 0\n" "- 19446744073709551615\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1337,7 +1337,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint8OverError) { "- 127\n" "- 128\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1355,7 +1355,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint8UnderError) { "- 127\n" "- -129\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1375,7 +1375,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint16UnderError) { "- -32768\n" "- -32769\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1394,7 +1394,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint16OverError) { "- -32768\n" "- 32768\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1414,7 +1414,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint32UnderError) { "- -2147483648\n" "- -2147483649\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1432,7 +1432,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint32OverError) { "- -2147483648\n" "- 2147483649\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1452,7 +1452,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint64UnderError) { "- 9223372036854775807\n" "- -9223372036854775809\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1470,7 +1470,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint64OverError) { "- 9223372036854775807\n" "- 9223372036854775809\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1489,7 +1489,7 @@ TEST(YAMLIO, TestReadBuiltInTypesFloatError) { "- -123.456\n" "- 1.2.3\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1508,7 +1508,7 @@ TEST(YAMLIO, TestReadBuiltInTypesDoubleError) { "- -123.456\n" "- 1.2.3\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1526,7 +1526,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex8Error) { "- 0xFE\n" "- 0x123\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1545,7 +1545,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex16Error) { "- 0xFEFF\n" "- 0x12345\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1563,7 +1563,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex32Error) { "- 0xFEFF0000\n" "- 0x1234556789\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1581,7 +1581,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex64Error) { "- 0xFFEEDDCCBBAA9988\n" "- 0x12345567890ABCDEF0\n" "...\n", - /*Ctxt=*/NULL, + /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; @@ -1593,13 +1593,13 @@ TEST(YAMLIO, TestMalformedMapFailsGracefully) { { // We pass the suppressErrorMessages handler to handle the error // message generated in the constructor of Input. - Input yin("{foo:3, bar: 5}", /*Ctxt=*/NULL, suppressErrorMessages); + Input yin("{foo:3, bar: 5}", /*Ctxt=*/nullptr, suppressErrorMessages); yin >> doc; EXPECT_TRUE(!!yin.error()); } { - Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/NULL, suppressErrorMessages); + Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/nullptr, suppressErrorMessages); yin >> doc; EXPECT_TRUE(!!yin.error()); } @@ -1685,7 +1685,7 @@ TEST(YAMLIO, TestEmptyStringSucceedsForMapWithOptionalFields) { TEST(YAMLIO, TestEmptyStringSucceedsForSequence) { std::vector<uint8_t> seq; - Input yin("", /*Ctxt=*/NULL, suppressErrorMessages); + Input yin("", /*Ctxt=*/nullptr, suppressErrorMessages); yin >> seq; EXPECT_FALSE(yin.error()); diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp index 2b797b4366..44d27d0410 100644 --- a/unittests/Support/raw_ostream_test.cpp +++ b/unittests/Support/raw_ostream_test.cpp @@ -69,7 +69,7 @@ TEST(raw_ostreamTest, Types_Buffered) { EXPECT_EQ("1.100000e+00", printToString(1.1)); // void* - EXPECT_EQ("0x0", printToString((void*) 0)); + EXPECT_EQ("0x0", printToString((void*) nullptr)); EXPECT_EQ("0xbeef", printToString((void*) 0xbeef)); EXPECT_EQ("0xdeadbeef", printToString((void*) 0xdeadbeef)); @@ -100,7 +100,7 @@ TEST(raw_ostreamTest, Types_Unbuffered) { EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1)); // void* - EXPECT_EQ("0x0", printToStringUnbuffered((void*) 0)); + EXPECT_EQ("0x0", printToStringUnbuffered((void*) nullptr)); EXPECT_EQ("0xbeef", printToStringUnbuffered((void*) 0xbeef)); EXPECT_EQ("0xdeadbeef", printToStringUnbuffered((void*) 0xdeadbeef)); |