diff options
author | Yi Kong <yikong@google.com> | 2018-08-02 17:31:13 -0700 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2018-08-02 18:09:44 -0700 |
commit | 32bc0fcf69dfccb3726fe572833a38b01179580e (patch) | |
tree | abca656f500087493e0997d5cf38cbcc9ec98eb8 /tests/stdlib_test.cpp | |
parent | 65f82092a17518080178ff7004cc6db362ebfbcd (diff) |
Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
Diffstat (limited to 'tests/stdlib_test.cpp')
-rw-r--r-- | tests/stdlib_test.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp index 2fbd937da..6e41555b5 100644 --- a/tests/stdlib_test.cpp +++ b/tests/stdlib_test.cpp @@ -281,35 +281,35 @@ TEST(stdlib, aligned_alloc_size_not_multiple_of_alignment) { TEST(stdlib, realpath__NULL_filename) { errno = 0; // Work around the compile-time error generated by FORTIFY here. - const char* path = NULL; - char* p = realpath(path, NULL); - ASSERT_TRUE(p == NULL); + const char* path = nullptr; + char* p = realpath(path, nullptr); + ASSERT_TRUE(p == nullptr); ASSERT_EQ(EINVAL, errno); } TEST(stdlib, realpath__empty_filename) { errno = 0; - char* p = realpath("", NULL); - ASSERT_TRUE(p == NULL); + char* p = realpath("", nullptr); + ASSERT_TRUE(p == nullptr); ASSERT_EQ(ENOENT, errno); } TEST(stdlib, realpath__ENOENT) { errno = 0; - char* p = realpath("/this/directory/path/almost/certainly/does/not/exist", NULL); - ASSERT_TRUE(p == NULL); + char* p = realpath("/this/directory/path/almost/certainly/does/not/exist", nullptr); + ASSERT_TRUE(p == nullptr); ASSERT_EQ(ENOENT, errno); } TEST(stdlib, realpath__component_after_non_directory) { errno = 0; - char* p = realpath("/dev/null/.", NULL); - ASSERT_TRUE(p == NULL); + char* p = realpath("/dev/null/.", nullptr); + ASSERT_TRUE(p == nullptr); ASSERT_EQ(ENOTDIR, errno); errno = 0; - p = realpath("/dev/null/..", NULL); - ASSERT_TRUE(p == NULL); + p = realpath("/dev/null/..", nullptr); + ASSERT_TRUE(p == nullptr); ASSERT_EQ(ENOTDIR, errno); } @@ -324,7 +324,7 @@ TEST(stdlib, realpath) { char* p = realpath("/proc/self/exe", buf); ASSERT_STREQ(executable_path, p); - p = realpath("/proc/self/exe", NULL); + p = realpath("/proc/self/exe", nullptr); ASSERT_STREQ(executable_path, p); free(p); } @@ -354,18 +354,18 @@ TEST(stdlib, qsort) { static void* TestBug57421_child(void* arg) { pthread_t main_thread = reinterpret_cast<pthread_t>(arg); - pthread_join(main_thread, NULL); + pthread_join(main_thread, nullptr); char* value = getenv("ENVIRONMENT_VARIABLE"); - if (value == NULL) { + if (value == nullptr) { setenv("ENVIRONMENT_VARIABLE", "value", 1); } - return NULL; + return nullptr; } static void TestBug57421_main() { pthread_t t; - ASSERT_EQ(0, pthread_create(&t, NULL, TestBug57421_child, reinterpret_cast<void*>(pthread_self()))); - pthread_exit(NULL); + ASSERT_EQ(0, pthread_create(&t, nullptr, TestBug57421_child, reinterpret_cast<void*>(pthread_self()))); + pthread_exit(nullptr); } // Even though this isn't really a death test, we have to say "DeathTest" here so gtest knows to @@ -483,20 +483,20 @@ TEST(stdlib, strtold) { } TEST(stdlib, strtof_2206701) { - ASSERT_EQ(0.0f, strtof("7.0064923216240853546186479164495e-46", NULL)); - ASSERT_EQ(1.4e-45f, strtof("7.0064923216240853546186479164496e-46", NULL)); + ASSERT_EQ(0.0f, strtof("7.0064923216240853546186479164495e-46", nullptr)); + ASSERT_EQ(1.4e-45f, strtof("7.0064923216240853546186479164496e-46", nullptr)); } TEST(stdlib, strtod_largest_subnormal) { // This value has been known to cause javac and java to infinite loop. // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ - ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-308", NULL)); - ASSERT_EQ(2.2250738585072014e-308, strtod("0.00022250738585072012e-304", NULL)); - ASSERT_EQ(2.2250738585072014e-308, strtod("00000002.2250738585072012e-308", NULL)); - ASSERT_EQ(2.2250738585072014e-308, strtod("2.225073858507201200000e-308", NULL)); - ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-00308", NULL)); - ASSERT_EQ(2.2250738585072014e-308, strtod("2.22507385850720129978001e-308", NULL)); - ASSERT_EQ(-2.2250738585072014e-308, strtod("-2.2250738585072012e-308", NULL)); + ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-308", nullptr)); + ASSERT_EQ(2.2250738585072014e-308, strtod("0.00022250738585072012e-304", nullptr)); + ASSERT_EQ(2.2250738585072014e-308, strtod("00000002.2250738585072012e-308", nullptr)); + ASSERT_EQ(2.2250738585072014e-308, strtod("2.225073858507201200000e-308", nullptr)); + ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-00308", nullptr)); + ASSERT_EQ(2.2250738585072014e-308, strtod("2.22507385850720129978001e-308", nullptr)); + ASSERT_EQ(-2.2250738585072014e-308, strtod("-2.2250738585072012e-308", nullptr)); } TEST(stdlib, quick_exit) { @@ -584,7 +584,7 @@ TEST(stdlib, ptsname_r_EINVAL) { int fd = getpt(); ASSERT_NE(-1, fd); errno = 0; - char* buf = NULL; + char* buf = nullptr; ASSERT_EQ(EINVAL, ptsname_r(fd, buf, 128)); ASSERT_EQ(EINVAL, errno); close(fd); @@ -635,7 +635,7 @@ TEST(stdlib, ttyname_r_EINVAL) { int fd = getpt(); ASSERT_NE(-1, fd); errno = 0; - char* buf = NULL; + char* buf = nullptr; ASSERT_EQ(EINVAL, ttyname_r(fd, buf, 128)); ASSERT_EQ(EINVAL, errno); close(fd); |