Skip to content

Commit

Permalink
Add version.h header with information about the library version
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Feb 19, 2019
1 parent fedc1b7 commit 5f0c399
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ values =
rel

[bumpversion:file:CMakeLists.txt]
[bumpversion:file:include/ethash/version.h]

18 changes: 18 additions & 0 deletions include/ethash/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ethash: C/C++ implementation of Ethash, the Ethereum Proof of Work algorithm.
* Copyright 2019 Pawel Bylica.
* Licensed under the Apache License, Version 2.0.
*/

#pragma once

/** The ethash library version. */
#define ETHASH_VERSION "0.4.2"

#if __cplusplus >= 201103L
namespace ethash
{
/// The ethash library version.
constexpr auto version = ETHASH_VERSION;

} // namespace ethash
#endif
3 changes: 3 additions & 0 deletions test/integration/cmake-config/cmake_config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
// Licensed under the Apache License, Version 2.0. See the LICENSE file.

#include <ethash/ethash.hpp>
#include <ethash/version.h>

int main()
{
static_assert(sizeof(ethash::version) >= 6, "incorrect ethash::version");

uint8_t seed_bytes[32] = {0};
ethash::hash256 seed = ethash::hash256_from_bytes(seed_bytes);
return ethash::find_epoch_number(seed);
Expand Down
3 changes: 3 additions & 0 deletions test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ add_executable(
test_managed.cpp
test_primes.cpp
test_progpow.cpp
test_version.cpp
)

set_source_files_properties(test_version.cpp PROPERTIES COMPILE_DEFINITIONS TEST_PROJECT_VERSION="${PROJECT_VERSION}")

target_link_libraries(ethash-test PRIVATE ethash GTest::gtest GTest::main)
target_include_directories(ethash-test PRIVATE ${ETHASH_PRIVATE_INCLUDE_DIR})
set_target_properties(ethash-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
15 changes: 15 additions & 0 deletions test/unittests/test_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// ethash: C/C++ implementation of Ethash, the Ethereum Proof of Work algorithm.
// Copyright 2019 Pawel Bylica.
// Licensed under the Apache License, Version 2.0.

#include <ethash/version.h>

#include <gtest/gtest.h>

TEST(libethash, version)
{
static_assert(sizeof(ethash::version) >= 6, "incorrect ethash::version");

EXPECT_EQ(ETHASH_VERSION, TEST_PROJECT_VERSION);
EXPECT_EQ(ethash::version, TEST_PROJECT_VERSION);
}

0 comments on commit 5f0c399

Please sign in to comment.