forked from EvergreenCrypto/docker-finance
docker-finance | modern accounting for the power-user
Dedicated to Michael Morgan: a beautiful, beautiful soul.
---
Internal signing keys:
Aaron Fiore (sole author)
- 518A22F85BEFD32BCC99C48603F90C4F35E0213E
- 31ECA5C347A0CC0815EDE730A3EACCFCDA7E685E
- C8187C585CB07A4DA81CC0F37318B50EBE9C0DA8
Internal repositories (rebased from):
Staging:
$ git log -n1 --pretty=format:"%H"
c8e0cd66f6c89fa7b3c62f72fb524a4cc454b7b6
$ git rev-list --max-parents=0 HEAD
ac3863b8c234755855f1aea3a07a853122decdf2
Private:
$ git log -n1 --pretty=format:"%H"
69bb3591eaa2990a9637832bb484690e00c4f926
$ git rev-list --max-parents=0 HEAD
a5c1cc9fb593c4cf09bc0adfef6cb6d2964511ae
This commit is contained in:
284
container/src/root/test/unit/utility.hh
Normal file
284
container/src/root/test/unit/utility.hh
Normal file
@@ -0,0 +1,284 @@
|
||||
// docker-finance | modern accounting for the power-user
|
||||
//
|
||||
// Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! \file
|
||||
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
|
||||
//! \since docker-finance 1.0.0
|
||||
|
||||
#ifndef CONTAINER_SRC_ROOT_TEST_UNIT_UTILITY_HH_
|
||||
#define CONTAINER_SRC_ROOT_TEST_UNIT_UTILITY_HH_
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "../common/utility.hh"
|
||||
|
||||
//! \namespace docker_finance
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace docker_finance
|
||||
{
|
||||
//! \namespace docker_finance::tests
|
||||
//! \brief docker-finance common test framework
|
||||
//! \ingroup cpp_tests
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace tests
|
||||
{
|
||||
//! \namespace docker_finance::tests::unit
|
||||
//! \brief docker-finance unit test cases
|
||||
//! \ingroup cpp_tests
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace unit
|
||||
{
|
||||
//! \brief Tools utility fixture
|
||||
//! \since docker-finance 1.0.0
|
||||
struct Tools : public ::testing::Test, public tests::ToolsFixture
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(Tools, random_dist_TRandom1)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandom1>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandom2)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandom2>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandom3)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandom3>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomMixMax)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomMixMax>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomMixMax17)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomMixMax17>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomMixMax256)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomMixMax256>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomMT64)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomMT64>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomRanlux48)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomRanlux48>(min, max));
|
||||
}
|
||||
|
||||
TEST_F(Tools, random_dist_TRandomRanluxpp)
|
||||
{
|
||||
ASSERT_NO_THROW(tools.dist_range<::TRandomRanluxpp>(min, max));
|
||||
}
|
||||
|
||||
//! \brief Byte transformation fixture
|
||||
//! \since docker-finance 1.0.0
|
||||
struct ByteTransform : public ::testing::Test, public tests::ByteFixture
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(ByteTransform, byte)
|
||||
{
|
||||
ASSERT_EQ(byte.encode(uint8_t{0x01}), std::byte{0x01});
|
||||
ASSERT_EQ(byte.decode(std::byte{0x01}), uint8_t{0x01});
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, basic_string)
|
||||
{
|
||||
using t_one = std::basic_string<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::basic_string<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, vector)
|
||||
{
|
||||
using t_one = std::vector<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::vector<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, deque)
|
||||
{
|
||||
using t_one = std::deque<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::deque<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, list)
|
||||
{
|
||||
using t_one = std::list<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::list<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, forward_list)
|
||||
{
|
||||
using t_one = std::forward_list<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::forward_list<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, map)
|
||||
{
|
||||
using t_one = std::map<std::string_view, uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::map<std::string_view, std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, multimap)
|
||||
{
|
||||
using t_one = std::multimap<std::string_view, uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::multimap<std::string_view, std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, multiset)
|
||||
{
|
||||
using t_one = std::multiset<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::multiset<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, set)
|
||||
{
|
||||
using t_one = std::set<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::set<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, unordered_map)
|
||||
{
|
||||
using t_one = std::unordered_map<std::string_view, uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::unordered_map<std::string_view, std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, unordered_multimap)
|
||||
{
|
||||
using t_one = std::unordered_multimap<std::string_view, uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::unordered_multimap<std::string_view, std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, unordered_multiset)
|
||||
{
|
||||
using t_one = std::unordered_multiset<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::unordered_multiset<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
|
||||
TEST_F(ByteTransform, unordered_set)
|
||||
{
|
||||
using t_one = std::unordered_set<uint8_t>;
|
||||
t_one one{fixed_bytes<t_one>()()};
|
||||
|
||||
using t_two = std::unordered_set<std::byte>;
|
||||
t_two two{fixed_bytes<t_two>()()};
|
||||
|
||||
ASSERT_EQ(byte.encode(one), two);
|
||||
ASSERT_EQ(byte.decode(two), one);
|
||||
}
|
||||
} // namespace unit
|
||||
} // namespace tests
|
||||
} // namespace docker_finance
|
||||
|
||||
#endif // CONTAINER_SRC_ROOT_TEST_UNIT_UTILITY_HH_
|
||||
|
||||
// # vim: sw=2 sts=2 si ai et
|
||||
Reference in New Issue
Block a user