Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: base/allocator/allocator_unittest.cc

Issue 415773009: Re-enable various MSVC warnings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't test new exception handling Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/allocator_unittest.cc
diff --git a/base/allocator/allocator_unittest.cc b/base/allocator/allocator_unittest.cc
index eb20b38ab6156f640d938edfe28914146ac3e15e..5c832d87e2054b286472c0cacf9e916332935190 100644
--- a/base/allocator/allocator_unittest.cc
+++ b/base/allocator/allocator_unittest.cc
@@ -15,10 +15,6 @@ static const int kSizeBits = 8 * sizeof(size_t);
static const size_t kMaxSize = ~static_cast<size_t>(0);
// Maximum positive size of a size_t if it were signed.
static const size_t kMaxSignedSize = ((size_t(1) << (kSizeBits-1)) - 1);
-// An allocation size which is not too big to be reasonable.
-static const size_t kNotTooBig = 100000;
-// An allocation size which is just too big.
-static const size_t kTooBig = ~static_cast<size_t>(0);
namespace {
@@ -287,50 +283,6 @@ static void TestCalloc(size_t n, size_t s, bool ok) {
}
}
-
-// A global test counter for number of times the NewHandler is called.
-static int news_handled = 0;
-static void TestNewHandler() {
- ++news_handled;
- throw std::bad_alloc();
-}
-
-// Because we compile without exceptions, we expect these will not throw.
-static void TestOneNewWithoutExceptions(void* (*func)(size_t),
- bool should_throw) {
- // success test
- try {
- void* ptr = (*func)(kNotTooBig);
- EXPECT_NE(reinterpret_cast<void*>(NULL), ptr) <<
- "allocation should not have failed.";
- } catch(...) {
- EXPECT_EQ(0, 1) << "allocation threw unexpected exception.";
- }
-
- // failure test
- try {
- void* rv = (*func)(kTooBig);
brettw 2014/07/25 20:19:20 I kind of like this test for the behavior that a "
Peter Kasting 2014/07/25 20:54:42 I think there are two options. One would be to #p
- EXPECT_EQ(NULL, rv);
- EXPECT_FALSE(should_throw) << "allocation should have thrown.";
- } catch(...) {
- EXPECT_TRUE(should_throw) << "allocation threw unexpected exception.";
- }
-}
-
-static void TestNothrowNew(void* (*func)(size_t)) {
- news_handled = 0;
-
- // test without new_handler:
- std::new_handler saved_handler = std::set_new_handler(0);
- TestOneNewWithoutExceptions(func, false);
-
- // test with new_handler:
- std::set_new_handler(TestNewHandler);
- TestOneNewWithoutExceptions(func, true);
- EXPECT_EQ(news_handled, 1) << "nothrow new_handler was not called.";
- std::set_new_handler(saved_handler);
-}
-
} // namespace
//-----------------------------------------------------------------------------
@@ -383,11 +335,6 @@ TEST(Allocators, Calloc) {
TestCalloc(kMaxSignedSize, kMaxSignedSize, false);
}
-TEST(Allocators, New) {
- TestNothrowNew(&::operator new);
- TestNothrowNew(&::operator new[]);
-}
-
// This makes sure that reallocing a small number of bytes in either
// direction doesn't cause us to allocate new memory.
TEST(Allocators, Realloc1) {
« no previous file with comments | « no previous file | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698