Fix for kTargetNodeSize too large

pull/5/head
Josh MacDonald 2011-12-13 10:48:14 -08:00
parent 1a14ff58c9
commit dd97f135d0
3 changed files with 20 additions and 19 deletions

View File

@ -1435,6 +1435,11 @@ class btree : public Params::key_compare {
sizeof(key_compare_checker(key_compare_helper()(key_type(), key_type()))) ==
sizeof(base::big_),
key_comparison_function_must_return_bool);
// Note: We insist on kTargetValues, which is computed from
// Params::kTargetNodeSize, falling under 256 because of the uint8
// fields of base_fields.
COMPILE_ASSERT(kNodeValues < 256, target_node_size_too_large);
};
////

View File

@ -40,7 +40,11 @@ TEST_COMPARE_TO(int);
#elif defined(TEST_compare_to_float)
TEST_COMPARE_TO(float);
#elif defined(TEST_compare_to_pointer)
TEST_COMPARE_TO(pointer);
TEST_COMPARE_TO(void*);
#elif defined(TEST_large_nodesize)
void LargeNode() {
util::btree::btree_set<int64, less<int64>, std::allocator<int64>, 10000> set;
}
#endif
} // namespace

View File

@ -30,28 +30,20 @@ class BtreeNegativeUnitTest(googletest.TestCase):
# Test that int does not work as a return type for key comparison.
('int',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that float does not work as a return type for key comparison.
('float',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that void* does not work as a return type for key comparison.
('pointer',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that bool does not work as a return type for compare-to
# comparison.
('compare_to_bool',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that int works as a return type for compare-to comparison.
('compare_to_int', None), # None means compilation should succeed.
@ -59,16 +51,16 @@ class BtreeNegativeUnitTest(googletest.TestCase):
# Test that float does not work as a return type for compare-to
# comparison.
('compare_to_float',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that void* does not work as a return type for compare-to
# comparison.
('compare_to_pointer',
[r'error: creating array with negative size', # for gcc
r'', # for icc
]),
[r'key_comparison_function_must_return_bool']),
# Test that large node sizes do not compile.
('large_nodesize',
[r'target_node_size_too_large']),
]
# Runs the list of tests.