-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
39 lines (33 loc) · 1.14 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <hash.hpp>
#include <array-hash.hpp>
TEST_CASE("hashes", "Implements hashes") {
/* Our hash object */
ht::superfast hash;
SECTION("length", "Provides impl for length-provided char*") {
int foo = 5;
REQUIRE(hash(reinterpret_cast<char*>(&foo), sizeof(foo)));
}
}
TEST_CASE("array-hash", "Implements the Array Hash") {
ht::ArrayHash<int> hash;
SECTION("insert / retrieve", "Implements insertions") {
SECTION("bracket operator", "Can insert with the bracket operator") {
REQUIRE(hash.exists("foo") == false);
hash["foo"] = 5;
REQUIRE(hash.exists("foo"));
REQUIRE(hash["foo"] == 5);
}
SECTION("no length", "Can insert with a null-terminated char*") {
REQUIRE(hash.exists("testing") == false);
hash.insert("testing", 5);
REQUIRE(hash.exists("testing"));
/* Simple retrieve */
REQUIRE(hash["testing"] == 5);
/* Update */
hash["testing"] = 10;
REQUIRE(hash["testing"] == 10);
}
}
}