Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit ca70b13

Browse files
committed
test: Bring back the unit tests of deprecated features
1 parent f96ed08 commit ca70b13

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

test/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ add_executable(
1212
evmc-unittests
1313
loader_mock.h
1414
test_cpp.cpp
15+
test_deprecated.cpp
1516
test_helpers.cpp
1617
test_instructions.cpp
1718
test_loader.cpp

test/unittests/test_deprecated.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// EVMC: Ethereum Client-VM Connector API.
2+
// Copyright 2019 The EVMC Authors.
3+
// Licensed under the Apache License, Version 2.0.
4+
5+
#include <evmc/helpers.hpp>
6+
7+
#include <gtest/gtest.h>
8+
#include <map>
9+
#include <unordered_map>
10+
11+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
12+
13+
TEST(helpers, fnv1a)
14+
{
15+
const uint8_t text[] = {'E', 'V', 'M', 'C'};
16+
const auto h = fnv1a(text, sizeof(text));
17+
EXPECT_EQ(h, sizeof(size_t) == 8 ? 0x15e05d6d22fed89a : 0xffaa6a9a);
18+
}
19+
20+
TEST(helpers, is_zero)
21+
{
22+
auto a = evmc_address{};
23+
EXPECT_TRUE(is_zero(a));
24+
a.bytes[0] = 1;
25+
EXPECT_FALSE(is_zero(a));
26+
27+
auto b = evmc_bytes32{};
28+
EXPECT_TRUE(is_zero(b));
29+
b.bytes[0] = 1;
30+
EXPECT_FALSE(is_zero(b));
31+
}
32+
33+
TEST(helpers, maps)
34+
{
35+
std::map<evmc_address, bool> addresses;
36+
addresses[{}] = true;
37+
ASSERT_EQ(addresses.size(), 1);
38+
39+
std::unordered_map<evmc_address, bool> unordered_addresses;
40+
unordered_addresses.emplace(*addresses.begin());
41+
EXPECT_EQ(unordered_addresses.size(), 1);
42+
43+
std::map<evmc_bytes32, bool> storage;
44+
storage[{}] = true;
45+
ASSERT_EQ(storage.size(), 1);
46+
47+
std::unordered_map<evmc_bytes32, bool> unordered_storage;
48+
unordered_storage.emplace(*storage.begin());
49+
EXPECT_EQ(unordered_storage.size(), 1);
50+
}

0 commit comments

Comments
 (0)