diff options
| author | Stefan Boberg <[email protected]> | 2025-11-07 14:49:13 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-11-07 14:49:13 +0100 |
| commit | 24e43a913f29ac3b314354e8ce5175f135bcc64f (patch) | |
| tree | ca442937ceeb63461012b33a4576e9835099f106 /thirdparty/robin-map/tests/policy_tests.cpp | |
| parent | get oplog attachments (#622) (diff) | |
| download | zen-24e43a913f29ac3b314354e8ce5175f135bcc64f.tar.xz zen-24e43a913f29ac3b314354e8ce5175f135bcc64f.zip | |
switch to xmake for package management (#611)
This change removes our dependency on vcpkg for package management, in favour of bringing some code in-tree in the `thirdparty` folder as well as using the xmake build-in package management feature. For the latter, all the package definitions are maintained in the zen repo itself, in the `repo` folder.
It should now also be easier to build the project as it will no longer depend on having the right version of vcpkg installed, which has been a common problem for new people coming in to the codebase. Now you should only need xmake to build.
* Bumps xmake requirement on github runners to 2.9.9 to resolve an issue where xmake on Windows invokes cmake with `v144` toolchain which does not exist
* BLAKE3 is now in-tree at `thirdparty/blake3`
* cpr is now in-tree at `thirdparty/cpr`
* cxxopts is now in-tree at `thirdparty/cxxopts`
* fmt is now in-tree at `thirdparty/fmt`
* robin-map is now in-tree at `thirdparty/robin-map`
* ryml is now in-tree at `thirdparty/ryml`
* sol2 is now in-tree at `thirdparty/sol2`
* spdlog is now in-tree at `thirdparty/spdlog`
* utfcpp is now in-tree at `thirdparty/utfcpp`
* xmake package repo definitions is in `repo`
* implemented support for sanitizers. ASAN is supported on windows, TSAN, UBSAN, MSAN etc are supported on Linux/MacOS though I have not yet tested it extensively on MacOS
* the zencore encryption implementation also now supports using mbedTLS which is used on MacOS, though for now we still use openssl on Linux
* crashpad
* bumps libcurl to 8.11.0 (from 8.8.0) which should address a rare build upload bug
Diffstat (limited to 'thirdparty/robin-map/tests/policy_tests.cpp')
| -rw-r--r-- | thirdparty/robin-map/tests/policy_tests.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/thirdparty/robin-map/tests/policy_tests.cpp b/thirdparty/robin-map/tests/policy_tests.cpp new file mode 100644 index 000000000..798a22d14 --- /dev/null +++ b/thirdparty/robin-map/tests/policy_tests.cpp @@ -0,0 +1,97 @@ +/** + * MIT License + * + * Copyright (c) 2017 Thibaut Goetghebuer-Planchon <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include <tsl/robin_growth_policy.h> + +#include <boost/mpl/list.hpp> +#include <boost/test/unit_test.hpp> +#include <cstddef> +#include <limits> +#include <ratio> +#include <stdexcept> + +#include "utils.h" + +BOOST_AUTO_TEST_SUITE(test_policy) + +using test_types = + boost::mpl::list<tsl::rh::power_of_two_growth_policy<2>, + tsl::rh::power_of_two_growth_policy<4>, + tsl::rh::prime_growth_policy, tsl::rh::mod_growth_policy<>, + tsl::rh::mod_growth_policy<std::ratio<7, 2>>>; + +BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy, Policy, test_types) { + // Call next_bucket_count() on the policy until we reach its + // max_bucket_count() + std::size_t bucket_count = 0; + Policy policy(bucket_count); + + BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0); + BOOST_CHECK_EQUAL(bucket_count, 0); + +#ifndef TSL_RH_NO_EXCEPTIONS + bool exception_thrown = false; + try { + while (true) { + const std::size_t previous_bucket_count = bucket_count; + + bucket_count = policy.next_bucket_count(); + policy = Policy(bucket_count); + + BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0); + BOOST_CHECK(bucket_count > previous_bucket_count); + } + } catch (const std::length_error&) { + exception_thrown = true; + } + + BOOST_CHECK(exception_thrown); +#endif +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy_min_bucket_count, Policy, + test_types) { + // Check policy when a bucket_count of 0 is asked. + std::size_t bucket_count = 0; + Policy policy(bucket_count); + + BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy_max_bucket_count, Policy, + test_types) { + // Test a bucket_count equals to the max_bucket_count limit and above + std::size_t bucket_count = 0; + Policy policy(bucket_count); + + bucket_count = policy.max_bucket_count(); + Policy policy2(bucket_count); + + bucket_count = std::numeric_limits<std::size_t>::max(); + TSL_RH_CHECK_THROW((Policy(bucket_count)), std::length_error); + + bucket_count = policy.max_bucket_count() + 1; + TSL_RH_CHECK_THROW((Policy(bucket_count)), std::length_error); +} + +BOOST_AUTO_TEST_SUITE_END() |