Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
x-mass committed Dec 6, 2023
1 parent 3bde2c7 commit df6c9c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion include/nil/crypto3/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#ifndef CRYPTO3_TYPE_TRAITS_HPP
#define CRYPTO3_TYPE_TRAITS_HPP

#include <iterator>
#include <type_traits>


#define GENERATE_HAS_MEMBER_TYPE(Type) \
template<class T, typename Enable = void> \
class HasMemberType_##Type { \
Expand Down Expand Up @@ -325,4 +329,4 @@ namespace nil {
} // namespace crypto3
} // namespace nil

#endif // CRYPTO3_TYPE_TRAITS_HPP
#endif // CRYPTO3_TYPE_TRAITS_HPP
19 changes: 9 additions & 10 deletions test/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@

#define BOOST_TEST_MODULE block_pack_test

#include <boost/array.hpp>
#include <boost/cstdint.hpp>

#include <nil/crypto3/detail/pack.hpp>

#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>

#include <array>
#include <cstdint>
#include <cstdio>

using namespace nil::crypto3;
Expand Down Expand Up @@ -66,7 +65,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_bubb_2) {
BOOST_AUTO_TEST_CASE(bubb_to_bulb_1) {
std::array<uint8_t, 4> in = {{0x12, 0x34, 0x56, 0x78}};
std::array<uint32_t, 1> out {};
std::array<uint32_t, 1> res = {{0x482c6a1e}};
std::array<uint32_t, 1> res = {{0x482c6a1e}};

pack<big_octet_big_bit, big_octet_little_bit, 8, 32>(in.begin(), in.end(), out.begin());

Expand All @@ -90,7 +89,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_lubb_1) {

pack<big_octet_big_bit, little_octet_big_bit, 8, 64>(in.begin(), in.end(), out.begin());

BOOST_CHECK(out == res);
BOOST_CHECK(out == res);
}

BOOST_AUTO_TEST_CASE(bubb_to_lubb_2) {
Expand Down Expand Up @@ -204,7 +203,7 @@ BOOST_AUTO_TEST_CASE(lubb_to_lulb_2) {
}

BOOST_AUTO_TEST_CASE(bulb_to_bubb_1) {
std::array<uint8_t, 16> in = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
std::array<uint8_t, 16> in = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
0x48, 0x2c, 0x6a, 0x1e, 0x09, 0xd5, 0xb3, 0xf7}};
std::array<uint64_t, 2> out {};
std::array<uint64_t, 2> res = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
Expand Down Expand Up @@ -392,7 +391,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_bubb_2) {
BOOST_AUTO_TEST_CASE(bubb_to_bulb_1) {
std::array<uint32_t, 1> in = {{0x482c6a1e}};
std::array<uint8_t, 4> out {};
std::array<uint8_t, 4> res = {{0x12, 0x34, 0x56, 0x78}};
std::array<uint8_t, 4> res = {{0x12, 0x34, 0x56, 0x78}};

pack<big_octet_big_bit, big_octet_little_bit, 32, 8>(in.begin(), in.end(), out.begin());

Expand All @@ -416,7 +415,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_lubb_1) {

pack<big_octet_big_bit, little_octet_big_bit, 64, 8>(in.begin(), in.end(), out.begin());

BOOST_CHECK(out == res);
BOOST_CHECK(out == res);
}

BOOST_AUTO_TEST_CASE(bubb_to_lubb_2) {
Expand Down Expand Up @@ -530,9 +529,9 @@ BOOST_AUTO_TEST_CASE(lubb_to_lulb_2) {
}

BOOST_AUTO_TEST_CASE(bulb_to_bubb_1) {
std::array<uint64_t, 2> in = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
std::array<uint64_t, 2> in = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
std::array<uint8_t, 16> out {};
std::array<uint8_t, 16> res = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
std::array<uint8_t, 16> res = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
0x48, 0x2c, 0x6a, 0x1e, 0x09, 0xd5, 0xb3, 0xf7}};

pack<big_octet_little_bit, big_octet_big_bit, 64, 8>(in.begin(), in.end(), out.begin());
Expand Down

0 comments on commit df6c9c6

Please sign in to comment.