Commit e81bc089 authored by Xiao Shi's avatar Xiao Shi Committed by Facebook Github Bot

clean up tests run for the fallback F14 version

Summary:
Some of the test cases are only appropriate for the F14 version with vector
instructions. Move or delete those that should not be run for the fallback
version.

Reviewed By: nbronson

Differential Revision: D9405419

fbshipit-source-id: 99c3dd689c157da71e36f4f315c0b6982203b174
parent d4a28e37
......@@ -63,11 +63,8 @@ void runAllocatedMemorySizeTest() {
TMap<K, V, DefaultHasher<K>, DefaultKeyEqual<K>, A> m;
EXPECT_EQ(testAllocatedMemorySize, m.getAllocatedMemorySize());
std::size_t maxSize = 0;
for (size_t i = 0; i < 1000; ++i) {
m.insert(std::make_pair(folly::to<K>(i), V{}));
maxSize = std::max(m.size(), maxSize);
EXPECT_GT(maxSize, (m.bucket_count() / 2) & ~std::size_t{1});
m.erase(folly::to<K>(i / 10 + 2));
EXPECT_EQ(testAllocatedMemorySize, m.getAllocatedMemorySize());
std::size_t size = 0;
......
......@@ -96,37 +96,6 @@ TEST(F14Set, getAllocatedMemorySize) {
runAllocatedMemorySizeTests<double>();
runAllocatedMemorySizeTests<std::string>();
runAllocatedMemorySizeTests<folly::fbstring>();
{
folly::F14ValueSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 4 * sizeof(void*));
if (alignof(folly::max_align_t) == 16) {
// chunks will be allocated as 2 max_align_t-s
EXPECT_EQ(set.getAllocatedMemorySize(), 32);
} else {
// chunks will be allocated using aligned_malloc with the true size
EXPECT_EQ(set.getAllocatedMemorySize(), 24);
}
}
{
folly::F14NodeSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 4 * sizeof(void*));
if (alignof(folly::max_align_t) == 16) {
// chunks will be allocated as 2 max_align_t-s
EXPECT_EQ(set.getAllocatedMemorySize(), 36);
} else {
// chunks will be allocated using aligned_malloc with the true size
EXPECT_EQ(set.getAllocatedMemorySize(), 20 + 2 * sizeof(void*));
}
}
{
folly::F14VectorSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 8 + 2 * sizeof(void*));
EXPECT_EQ(set.getAllocatedMemorySize(), 32);
}
}
template <typename S>
......@@ -513,6 +482,39 @@ TEST(F14FastSet, simple) {
runSimple<F14FastSet<std::string>>();
}
TEST(F14Set, ContainerSize) {
{
folly::F14ValueSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 4 * sizeof(void*));
if (alignof(folly::max_align_t) == 16) {
// chunks will be allocated as 2 max_align_t-s
EXPECT_EQ(set.getAllocatedMemorySize(), 32);
} else {
// chunks will be allocated using aligned_malloc with the true size
EXPECT_EQ(set.getAllocatedMemorySize(), 24);
}
}
{
folly::F14NodeSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 4 * sizeof(void*));
if (alignof(folly::max_align_t) == 16) {
// chunks will be allocated as 2 max_align_t-s
EXPECT_EQ(set.getAllocatedMemorySize(), 36);
} else {
// chunks will be allocated using aligned_malloc with the true size
EXPECT_EQ(set.getAllocatedMemorySize(), 20 + 2 * sizeof(void*));
}
}
{
folly::F14VectorSet<int> set;
set.insert(10);
EXPECT_EQ(sizeof(set), 8 + 2 * sizeof(void*));
EXPECT_EQ(set.getAllocatedMemorySize(), 32);
}
}
TEST(F14VectorMap, reverse_iterator) {
using TSet = F14VectorSet<uint64_t>;
auto populate = [](TSet& h, uint64_t lo, uint64_t hi) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment