aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/alloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-05-02 14:42:04 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-05-02 14:42:04 +0200
commit1b2adfe710e4092cd8d5fe0464b905b13d573837 (patch)
tree8ed3117bca7ebc0fc31c37404f2ac5b0cac7de37 /vespalib/src/tests/alloc
parent0f646f10b377b90fc37e9911f9fe383d112ff157 (diff)
Fix warnings hidden earlier due to including application headers as system includes
Diffstat (limited to 'vespalib/src/tests/alloc')
-rw-r--r--vespalib/src/tests/alloc/alloc_test.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp
index 5da06091796..11372c0aebd 100644
--- a/vespalib/src/tests/alloc/alloc_test.cpp
+++ b/vespalib/src/tests/alloc/alloc_test.cpp
@@ -1,11 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
-#include <stddef.h>
-#include <vespa/log/log.h>
-LOG_SETUP("alloc_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/alloc.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <cstddef>
using namespace vespalib;
using namespace vespalib::alloc;
@@ -16,11 +14,11 @@ testSwap(T & a, T & b)
{
void * tmpA(a.get());
void * tmpB(b.get());
- EXPECT_EQUAL(4096u, a.size());
- EXPECT_EQUAL(8192, b.size());
+ EXPECT_EQUAL(4096ul, a.size());
+ EXPECT_EQUAL(8192ul, b.size());
std::swap(a, b);
- EXPECT_EQUAL(4096u, b.size());
- EXPECT_EQUAL(8192, a.size());
+ EXPECT_EQUAL(4096ul, b.size());
+ EXPECT_EQUAL(8192ul, a.size());
EXPECT_EQUAL(tmpA, b.get());
EXPECT_EQUAL(tmpB, a.get());
}
@@ -87,46 +85,46 @@ TEST("no rounding of small heap buffer") {
TEST("no rounding of large heap buffer") {
Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE*11+3, MemoryAllocator::HUGEPAGE_SIZE*16);
- EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*11+3, buf.size());
+ EXPECT_EQUAL(size_t(MemoryAllocator::HUGEPAGE_SIZE*11+3), buf.size());
}
TEST("rounding of small mmaped buffer") {
Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE);
EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE, buf.size());
buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE+1);
- EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*2, buf.size());
+ EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*2ul, buf.size());
}
TEST("rounding of large mmaped buffer") {
Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE*11+3);
- EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12, buf.size());
+ EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12ul, buf.size());
}
TEST("heap alloc can not be extended") {
Alloc buf = Alloc::allocHeap(100);
void * oldPtr = buf.get();
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(101));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
}
TEST("auto alloced heap alloc can not be extended") {
Alloc buf = Alloc::alloc(100);
void * oldPtr = buf.get();
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(101));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
}
TEST("auto alloced heap alloc can not be extended, even if resize will be mmapped") {
Alloc buf = Alloc::alloc(100);
void * oldPtr = buf.get();
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(MemoryAllocator::HUGEPAGE_SIZE*3));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(100, buf.size());
+ EXPECT_EQUAL(100ul, buf.size());
}
TEST("auto alloced mmap alloc can be extended if room") {
@@ -183,10 +181,10 @@ TEST("mmap alloc can be extended if room") {
}
void * oldPtr = buf.get();
- EXPECT_EQUAL(4096, buf.size());
+ EXPECT_EQUAL(4096ul, buf.size());
EXPECT_TRUE(buf.resize_inplace(4097));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(8192, buf.size());
+ EXPECT_EQUAL(8192ul, buf.size());
}
TEST("mmap alloc can not be extended if no room") {
@@ -199,37 +197,37 @@ TEST("mmap alloc can not be extended if no room") {
EXPECT_EQUAL(reserved.get(), static_cast<const char *>(buf.get()) + buf.size());
void * oldPtr = buf.get();
- EXPECT_EQUAL(4096, buf.size());
+ EXPECT_EQUAL(4096ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(4097));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(4096, buf.size());
+ EXPECT_EQUAL(4096ul, buf.size());
}
TEST("heap alloc can not be shrinked") {
Alloc buf = Alloc::allocHeap(101);
void * oldPtr = buf.get();
- EXPECT_EQUAL(101, buf.size());
+ EXPECT_EQUAL(101ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(100));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(101, buf.size());
+ EXPECT_EQUAL(101ul, buf.size());
}
TEST("mmap alloc can be shrinked") {
Alloc buf = Alloc::allocMMap(4097);
void * oldPtr = buf.get();
- EXPECT_EQUAL(8192, buf.size());
+ EXPECT_EQUAL(8192ul, buf.size());
EXPECT_TRUE(buf.resize_inplace(4095));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(4096, buf.size());
+ EXPECT_EQUAL(4096ul, buf.size());
}
TEST("auto alloced heap alloc can not be shrinked") {
Alloc buf = Alloc::alloc(101);
void * oldPtr = buf.get();
- EXPECT_EQUAL(101, buf.size());
+ EXPECT_EQUAL(101ul, buf.size());
EXPECT_FALSE(buf.resize_inplace(100));
EXPECT_EQUAL(oldPtr, buf.get());
- EXPECT_EQUAL(101, buf.size());
+ EXPECT_EQUAL(101ul, buf.size());
}
TEST("auto alloced mmap alloc can be shrinked") {