Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
jsw_init_test.cc
Go to the documentation of this file.
1
2#include <gtest/gtest.h>
3#include <hash-fct.H>
4#include <string>
5
6using namespace Aleph;
7
9{
10 // Note: This test assumes it's the first one to run in its process
11 // or that jsw was not initialized yet.
12 // Since we cannot easily reset static state, we just check consistency.
13
14 const std::string key = "test_key";
15
16 // This should not throw anymore, even if init_jsw wasn't called
17 size_t h1 = jsw_hash(key);
19
20 size_t h2 = jsw_hash(key);
21 EXPECT_EQ(h1, h2);
22}
23
25{
26 const std::string key = "test_key";
27
28 init_jsw(12345);
29 size_t h1 = jsw_hash(key);
30
31 init_jsw(12345); // Same seed
32 size_t h2 = jsw_hash(key);
33 EXPECT_EQ(h1, h2);
34
35 init_jsw(54321); // Different seed
36 size_t h3 = jsw_hash(key);
37 EXPECT_NE(h1, h3);
38}
#define TEST(name)
size_t jsw_hash(const void *key, size_t len) noexcept
JSW hash (Julienne Walker)
Definition hash-fct.C:247
bool is_jsw_initialized() noexcept
Checks if the jsw_hash() lookup table has been initialized.
Definition hash-fct.C:211
void init_jsw() noexcept
Initializes the randomized lookup table used by jsw_hash().
Definition hash-fct.C:219
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.