diff --git a/.github/workflows/sanitize_multiple_platforms.yml b/.github/workflows/sanitize_multiple_platforms.yml new file mode 100755 index 0000000..8a7966a --- /dev/null +++ b/.github/workflows/sanitize_multiple_platforms.yml @@ -0,0 +1,53 @@ +name: Running sanitizers on multiple platforms + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu-latest] + build_type: [Release] + c_compiler: [gcc, clang, cl] + include: + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: ubuntu-latest + c_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/sanitize/unsigned/cmake_build_release" >> "$GITHUB_OUTPUT" + + - name: Configure + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }}/sanitize/unsigned + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target AesiSanitize -j 8 + + - name: Run sanitizing application + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: /${{ steps.strings.outputs.build-output-dir }}/AesiSanitize \ No newline at end of file diff --git a/Aesi-Multiprecision.h b/Aesi-Multiprecision.h deleted file mode 100644 index ccca508..0000000 --- a/Aesi-Multiprecision.h +++ /dev/null @@ -1,476 +0,0 @@ -#ifndef PRECISION_CAST_H -#define PRECISION_CAST_H - -/** - * @file Aesi-Multiprecision.h - * @brief List of operations for two or more integers with different precision - * @details The library was designed to support operations with numbers of different precision. Each function in this list - * receives two or more numbers with different precision. It performs precision cast of number with lower precision to - * greater precision and calls corresponding arithmetic operator. Please note that precision cast operator requires - * redundant copying and may be slow. Take a look at the main page to find out more. - */ - -/* ---------------------------------------- Different precision comparison ---------------------------------------- */ -/** - * @brief Multiprecision comparison operator - * @param Aesi left - * @param Aesi right - * @return Bool - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator==(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return (left == right.template precisionCast()); - } else { - return (left.template precisionCast() == right); - } -} - -/** - * @brief Multiprecision three-way comparison method - * @param Aesi left - * @param Aesi right - * @return AesiCMP - */ -template requires (bFirst != bSecond) -gpu constexpr auto compareTo(const Aesi& left, const Aesi& right) noexcept -> AesiCMP { - if constexpr (bFirst > bSecond) { - return left.compareTo(right.template precisionCast()); - } else { - return left.template precisionCast().compareTo(right); - } -} - -#if (defined(__CUDACC__) || __cplusplus < 202002L || defined (DEVICE_TESTING)) && !defined DOXYGEN_SKIP - /** - * @brief Oldstyle binary comparison operator(s). Used inside CUDA cause it does not support <=> on device - */ - template requires (bFirst != bSecond) - gpu constexpr auto operator!=(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return !left.operator==(right.template precisionCast()); - } else { - return !left.template precisionCast().operator==(right); - }; - } - template requires (bFirst != bSecond) - gpu constexpr auto operator<(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return left.compareTo(right.template precisionCast()) == AesiCMP::less; - } else { - return left.template precisionCast().compareTo(right) == AesiCMP::less; - }; - } - template requires (bFirst != bSecond) - gpu constexpr auto operator<=(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return !left.operator>(right.template precisionCast()); - } else { - return !left.template precisionCast().operator>(right); - }; - } - template requires (bFirst != bSecond) - gpu constexpr auto operator>(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return left.compareTo(right.template precisionCast()) == AesiCMP::greater; - } else { - return left.template precisionCast().compareTo(right) == AesiCMP::greater; - }; - } - template requires (bFirst != bSecond) - gpu constexpr auto operator>=(const Aesi& left, const Aesi& right) noexcept -> bool { - if constexpr (bFirst > bSecond) { - return !left.operator<(right.template precisionCast()); - } else { - return !left.template precisionCast().operator<(right); - }; - } -#else - /** - * @brief Multiprecision three-way comparison operator. - * @param Aesi left - * @param Aesi right. - * @return STD::Strong_ordering. - */ - template requires (bFirst != bSecond) - gpu constexpr auto operator<=>(const Aesi& left, const Aesi& right) noexcept -> std::strong_ordering { - if constexpr (bFirst > bSecond) { - switch(left.compareTo(right.template precisionCast())) { - case AesiCMP::less: return std::strong_ordering::less; - case AesiCMP::greater: return std::strong_ordering::greater; - case AesiCMP::equal: return std::strong_ordering::equal; - default: return std::strong_ordering::equivalent; - } - } else { - switch(left.template precisionCast().compareTo(right)) { - case AesiCMP::less: return std::strong_ordering::less; - case AesiCMP::greater: return std::strong_ordering::greater; - case AesiCMP::equal: return std::strong_ordering::equal; - default: return std::strong_ordering::equivalent; - } - } - } -#endif -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ----------------------------------------- Different precision addition ----------------------------------------- */ -/** - * @brief Multiprecision addition operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator+(const Aesi& left, const Aesi& right) noexcept --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left + right.template precisionCast(); - } else { - return left.template precisionCast() + right; - } -} - -/** - * @brief Multiprecision assignment addition operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator+=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator+=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* --------------------------------------- Different precision subtraction ---------------------------------------- */ -/** - * @brief Multiprecision subtraction operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator-(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left - right.template precisionCast(); - } else { - return left.template precisionCast() - right; - } -} - -/** - * @brief Multiprecision assignment subtraction operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator-=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator-=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* -------------------------------------- Different precision multiplication -------------------------------------- */ -/** - * @brief Multiprecision multiplication operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator*(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left * right.template precisionCast(); - } else { - return left.template precisionCast() * right; - } -} - -/** - * @brief Multiprecision assignment multiplication operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator*=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator*=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ----------------------------------------- Different precision division ----------------------------------------- */ -/** - * @brief Multiprecision division operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator/(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left / right.template precisionCast(); - } else { - return left.template precisionCast() / right; - } -} - -/** - * @brief Multiprecision assignment division operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator/=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator/=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ------------------------------------------ Different precision modulo ------------------------------------------ */ -/** - * @brief Multiprecision modulo operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator%(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left % right.template precisionCast(); - } else { - return left.template precisionCast() % right; - } -} - -/** - * @brief Multiprecision assignment modulo operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator%=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator%=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ------------------------------------------- Different precision XOR -------------------------------------------- */ -/** - * @brief Multiprecision bitwise XOR operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator^(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left ^ right.template precisionCast(); - } else { - return left.template precisionCast() ^ right; - } -} - -/** - * @brief Multiprecision assignment bitwise XOR operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator^=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator^=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* -------------------------------------------- Different precision AND ------------------------------------------- */ -/** - * @brief Multiprecision bitwise AND operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator&(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left & right.template precisionCast(); - } else { - return left.template precisionCast() & right; - } -} - -/** - * @brief Multiprecision assignment bitwise AND operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator&=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator&=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* -------------------------------------------- Different precision OR -------------------------------------------- */ -/** - * @brief Multiprecision bitwise OR operator - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ -template requires (bFirst != bSecond) -gpu constexpr auto operator|(const Aesi& left, const Aesi& right) --> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return left | right.template precisionCast(); - } else { - return left.template precisionCast() | right; - } -} - -/** - * @brief Multiprecision assignment bitwise OR operator - * @param Aesi left - * @param Aesi right - * @return Aesi - */ -template requires (bFirst > bSecond) -gpu constexpr auto operator|=(Aesi& left, const Aesi& right) -> Aesi& { - return left.operator|=(right.template precisionCast()); -} -/* ---------------------------------------------------------------------------------------------------------------- */ - - -namespace AesiMultiprecision { -/* ------------------------------------------- Greatest common divisor -------------------------------------------- */ - /** - * @brief Multiprecision greatest common divisor - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ - template - gpu constexpr auto gcd(const Aesi &left, const Aesi &right) - -> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return Aesi::gcd(left, right.template precisionCast()); - } else { - return Aesi::gcd(left.template precisionCast(), right); - } - } -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ------------------------------------------- Least common multiplier -------------------------------------------- */ -/** - * @brief Multiprecision greatest common divisor - * @param Aesi left - * @param Aesi right - * @return Aesi - * @details Returns Aesi with the highest precision between lPrecision, rPrecision - */ - template - gpu constexpr auto lcm(const Aesi &left, const Aesi &right) - -> typename std::conditional<(bFirst > bSecond), Aesi, Aesi>::type { - if constexpr (bFirst > bSecond) { - return Aesi::lcm(left, right.template precisionCast()); - } else { - return Aesi::lcm(left.template precisionCast(), right); - } - } -/* ---------------------------------------------------------------------------------------------------------------- */ - - -/* ----------------------------------------------- Power by modulo ------------------------------------------------ */ - /** - * @brief Multiprecision power by modulo helper - * @param Aesi base - * @param Aesi power - * @param Aesi modulo - * @return Aesi - * @details Returns Aesi with the highest precision between base/power and modulo. - */ - template requires (bCommon != bDiffer) - gpu constexpr auto powm(const Aesi& base, const Aesi& power, const Aesi& mod) { - if constexpr (bCommon > bDiffer) { - return Aesi::powm(base, power, mod.template precisionCast()); - } else { - return Aesi::powm(base.template precisionCast(), - power.template precisionCast(), mod); - } - } - - /** - * @brief Multiprecision power by modulo helper - * @param Aesi base - * @param Aesi power - * @param Aesi modulo - * @return Aesi - * @details Returns Aesi with the highest precision between base/power and modulo. - */ - template requires (bCommon != bDiffer) - gpu constexpr auto powm(const Aesi& base, const Aesi& power, const Aesi& mod) { - if constexpr (bCommon > bDiffer) { - return Aesi::powm(base, power.template precisionCast(), mod); - } else { - return Aesi::powm(base.template precisionCast(), - power, mod.template precisionCast()); - } - } - - /* Differ-Common-Common */ - template requires (bCommon != bDiffer) - gpu constexpr auto powm(const Aesi& base, const Aesi& power, const Aesi& mod) { - if constexpr (bCommon > bDiffer) { - return Aesi::powm(base.template precisionCast(), power, mod); - } else { - return Aesi::powm(base, power.template precisionCast(), - mod.template precisionCast()); - } - } - - /** - * @brief Multiprecision power by modulo - * @param Aesi base - * @param Aesi power - * @param Aesi modulo - * @return Aesi - * @details Returns Aesi with the highest precision between base, power and modulo. - * @note Be REALLY careful with overflow. The operation is calculated with an precision equal to the highest precision among the function parameters. - */ - template requires (bBase != bPow && bPow != bMod && bBase != bMod) - gpu constexpr auto powm(const Aesi &base, const Aesi &power, const Aesi &mod) - -> typename std::conditional<(bBase > bPow), - typename std::conditional<(bBase > bMod), Aesi, Aesi>::type, - typename std::conditional<(bPow > bMod), Aesi, Aesi>::type>::type { - if constexpr (bBase > bPow) { - return powm(base, power.template precisionCast(), mod); - } else { - return powm(base.template precisionCast(), power, mod); - } - } -/* ---------------------------------------------------------------------------------------------------------------- */ -} -#endif //PRECISION_CAST_H diff --git a/Aesi.h b/Aesi.h old mode 100644 new mode 100755 index ea0c547..b411b2f --- a/Aesi.h +++ b/Aesi.h @@ -2,1313 +2,844 @@ #define AESI_MULTIPRECISION /// @cond HIDE_INCLUDES -#include -#include - -#ifdef __CUDACC__ - #define gpu __host__ __device__ - #include - #include -#else - #define gpu - #include - #include -#endif +#include "Aeu.h" /// @endcond /** * @file Aesi.h - * @brief Long precision integer with arithmetic operations + * @brief Long precision signed integer with arithmetic operations */ namespace { - using byte = uint8_t; - using block = uint32_t; - - constexpr std::size_t bitsInByte = 8, blockBitLength = sizeof(block) * bitsInByte; - constexpr uint64_t blockBase = 1ULL << blockBitLength; - - /** - * @enum AesiCMP - * @brief Analogue of STD::Strong_ordering since CUDA does not support <=> operator - */ - enum AesiCMP { equal = 0, less = 1, greater = 2, equivalent = 3 }; + enum class Sign { Zero = 0, Positive = 1, Negative = -1 }; } /** * @class Aesi - * @brief Long precision integer with arithmetic operations + * @brief Long precision signed integer * @details May be used to represent positive and negative integers. Number precision is set in template parameter bitness. */ template requires (bitness % blockBitLength == 0) class Aesi final { - static_assert(bitness > sizeof(uint64_t), "Use built-in types for numbers 64-bit or less."); - - static constexpr std::size_t blocksNumber = bitness / blockBitLength; - -#ifdef __CUDACC__ - template - using pair = cuda::std::pair; - using blockLine = cuda::std::array; -#else - template - using pair = std::pair; - using blockLine = std::array; -#endif - /* -------------------------- @name Class members. ----------------------- */ - /** - * @brief Block line of the number - */ - blockLine blocks; + Sign sign; - /** - * @enum Aesi::Sign - * @brief Specifies sign of the number. Should be Positive, Negative or Zero - */ - enum Sign { Zero = 0, Positive = 1, Negative = 2 } sign; + using Base = Aeu; + Base base; /* ----------------------------------------------------------------------- */ - - /* ------------------------ @name Helper functions. ---------------------- */ - /** - * @brief Makes line addition - * @param BlockLine dst - * @param BlockLine src - * @return Uint64 - carry out from addition - */ - gpu static constexpr auto addLine(blockLine& dst, const blockLine& src) noexcept -> uint64_t { - uint64_t carryOut = 0; - for (std::size_t i = 0; i < blocksNumber; ++i) { - uint64_t sum = static_cast(dst[i]) + static_cast(src[i]) + carryOut; - carryOut = sum / blockBase; dst[i] = static_cast(sum % blockBase); - } - return carryOut; - } - - /** - * @brief Makes complement block line for line - * @param BlockLine line - * @return BlockLine - */ - [[nodiscard]] - gpu static constexpr auto makeComplement(const blockLine& line) noexcept -> blockLine { - blockLine result {}; - - uint64_t carryOut = 1; - for(std::size_t i = 0; i < blocksNumber; ++i) { - const uint64_t sum = blockBase - 1ULL - static_cast(line[i]) + carryOut; - carryOut = sum / blockBase; result[i] = static_cast(sum % blockBase); - } - - return result; - } - - /** - * @brief Counts the number of non-zero blocks inside block line starting from right - * @param BlockLine line - * @return Size_t - */ - gpu static constexpr auto lineLength(const blockLine& line) noexcept -> std::size_t { - for(long long i = blocksNumber - 1; i >= 0; --i) - if(line[i]) return i + 1; - return 0; - } - - /** - * @brief Checks if block line is empty - * @param BlockLine line - * @return Bool - */ - gpu static constexpr auto isLineEmpty(const blockLine& line) noexcept -> bool { - return lineLength(line) == 0; - } - /* ----------------------------------------------------------------------- */ + gpu constexpr Aesi(Sign withSign, Base withBase): sign { withSign }, base { withBase } {}; public: /* --------------------- @name Different constructors. ------------------- */ - /** - * @brief Default constructor - */ gpu constexpr Aesi() noexcept = default; - /** - * @brief Copy constructor - */ - gpu constexpr Aesi(const Aesi& copy) noexcept { - sign = copy.sign; if(copy.sign != Zero) blocks = copy.blocks; - }; + gpu constexpr Aesi(const Aesi& copy) noexcept = default; - /** - * @brief Copy assignment operator - */ - gpu constexpr Aesi& operator=(const Aesi& other) noexcept { - blocks = other.blocks; sign = other.sign; return *this; + template requires (std::is_signed_v) + gpu constexpr Aesi& operator=(Integral value) noexcept { + if(value != 0) { + if(value < 0) { + sign = Sign::Negative; + value *= -1; + } else sign = Sign::Positive; + base = static_cast(value); + } else sign = Sign::Zero; + return *this; } - /** - * @brief Integral constructor - * @param value Integral - * @details Accepts each integral built-in type signed and unsigned - */ + gpu constexpr Aesi& operator=(const Aesi& other) noexcept { base = other.base; sign = other.sign; return *this; } + template requires (std::is_integral_v) gpu constexpr Aesi(Integral value) noexcept { - if(value != 0) { - uint64_t tValue; - if (value < 0) { - sign = Negative; - tValue = static_cast(value * -1); - } else { - sign = Positive; - tValue = static_cast(value); - } - - for (std::size_t i = 0; i < blocksNumber; ++i) { - blocks[i] = static_cast(tValue % blockBase); - tValue /= blockBase; - } - } else { - blocks = {}; sign = Zero; - } + if(value < 0) { + value *= -1; + base = Base(static_cast(value)); + sign = Sign::Negative; + } else if(value > 0) { + base = Base(static_cast(value)); + sign = Sign::Positive; + } else + sign = Sign::Zero; } /** * @brief Pointer-based character constructor - * @param Char* pointer - * @param Size_t size - * @details Accepts decimal literals along with binary (starting with 0b/0B), octal (0o/0O) and hexadecimal (0x/0X) + * @param ptr Char* + * @param size Size_t + * @details Accepts decimal strings (no prefix), binary (0b/0B), octal (0o/0O) and hexadecimal (0x/0X) + * @note An odd number of dashes makes the number negative */ template requires (std::is_same_v || std::is_same_v) - gpu constexpr Aesi(const Char* ptr, std::size_t size) noexcept : Aesi {} { - if(size == 0) return; - - constexpr const Char* characters = [] { - if constexpr (std::is_same_v) { - return "-09aAfFoObBxX"; - } else { - return L"-09aAfFoObBxX"; - } - } (); - - std::size_t position = 0; - - bool negative = false; - if(ptr[position] == characters[0]) { - negative = true; ++position; - } + gpu constexpr Aesi(const Char* ptr, std::size_t size) noexcept : base(ptr, size) { + if(!base.isZero()) { + uint8_t positive = 1; - const auto base = [&ptr, &size, &position, &characters] { - if (ptr[position] == characters[1] && size > position + 1) { - switch (ptr[position + 1]) { - case characters[9]: - case characters[10]: - position += 2; return 2; - case characters[7]: - case characters[8]: - position += 2; return 8; - case characters[11]: - case characters[12]: - position += 2; return 16; - default: - return 10; + const auto dash = [] { + if constexpr (std::is_same_v) { + return '-'; + } else { + return L'-'; } - } else return 10; - } (); - for(; position < size; ++position) { - const auto digit = [&characters] (Char ch) { - if(characters[1] <= ch && ch <= characters[2]) - return static_cast(ch) - static_cast(characters[1]); - if(characters[3] <= ch && ch <= characters[5]) - return static_cast(ch) - static_cast(characters[3]) + 10; - if(characters[4] <= ch && ch <= characters[6]) - return static_cast(ch) - static_cast(characters[4]) + 10; - return 99; - } (ptr[position]); - - if(digit < base) { - this->operator*=(base); - this->operator+=(digit); - } - } + } (); + for(std::size_t i = 0; i < size; ++i) + if(ptr[i] == dash) positive ^= 1; - if(negative) sign = Negative; + sign = (positive ? Sign::Positive : Sign::Negative); + } else sign = Sign::Zero; } - /** - * @brief C-style string literal constructor - * @param Char[] literal - */ template requires (arrayLength > 1 && (std::is_same_v || std::is_same_v)) gpu constexpr Aesi(const Char (&literal)[arrayLength]) noexcept : Aesi(literal, arrayLength) {} - /** - * @brief String or string-view based constructor - * @param String/String-View sv - * @details Constructs object from STD::Basic_String or STD::Basic_String_View. Accepts objects based on char or wchar_t - */ template requires (std::is_same_v, typename std::decay::type> || std::is_same_v, typename std::decay::type>) gpu constexpr Aesi(String&& stringView) noexcept : Aesi(stringView.data(), stringView.size()) {} - /* ----------------------------------------------------------------------- */ - - - /* --------------------- @name Arithmetic operators. --------------------- */ - /** - * @brief Unary plus operator - * @return Aesi - * @note Does basically nothing - */ - gpu constexpr auto operator+() const noexcept -> Aesi { return *this; } - /** - * @brief Unary minus operator - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator-() const noexcept -> Aesi { - if(sign == Zero) return Aesi {}; - Aesi result = *this; result.inverse(); return result; + template requires (std::is_same_v, + typename std::decay::type> || std::is_same_v, typename std::decay::type>) + gpu constexpr Aesi(const String& stringView) noexcept : Aesi(stringView.data(), stringView.size()) {} + + explicit gpu constexpr Aesi(const Aeu& value) : sign(Sign::Positive), base(value) {} + +#ifdef AESI_CRYPTOPP_INTEGRATION + constexpr Aesi(const CryptoPP::Integer& value) { + if(value.IsZero()) + sign = Sign::Zero; + else { + base = value; + if(value.IsNegative()) + sign = Sign::Negative; + else sign = Sign::Positive; + } } +#endif - /** - * @brief Prefix increment - * @return Aesi& - */ - gpu constexpr auto operator++() noexcept -> Aesi& { return this->operator+=(1); } - - /** - * @brief Postfix increment - * @return Aesi - */ - gpu constexpr auto operator++(int) & noexcept -> Aesi { - Aesi old = *this; operator++(); return old; +#ifdef AESI_GMP_INTEGRATION + constexpr Aesi(const mpz_class& value) { + if(value == 0) + sign = Sign::Zero; + else { + base = value; + if(value < 0) + sign = Sign::Negative; + else sign = Sign::Positive; + } } +#endif + /* ----------------------------------------------------------------------- */ - /** - * @brief Prefix decrement - * @return Aesi& - */ - gpu constexpr auto operator--() noexcept -> Aesi& { return this->operator-=(1); } - /** - * @brief Postfix decrement - * @return Aesi - */ - gpu constexpr auto operator--(int) & noexcept -> Aesi { - Aesi old = *this; operator--(); return old; + /* --------------------- @name Arithmetic operators. --------------------- */ + /* ------------------------- @name Unary operators. -------------------------- */ + gpu constexpr auto operator+() const noexcept -> Aesi { return *this; } + + [[nodiscard]] + gpu constexpr auto operator-() const noexcept -> Aesi { Aesi copy = *this; copy.inverse(); return copy; } + + gpu constexpr auto operator++() noexcept -> Aesi& { + if(sign == Sign::Negative) { + --base; if(base.isZero()) sign = Sign::Zero; + } else if(sign == Sign::Positive) { + ++base; + } else { base = 1u; sign = Sign::Positive; } + return *this; } - /** - * @brief Addition operator - * @param Aesi addendum - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator+(const Aesi& addendum) const noexcept -> Aesi { - Aesi result = *this; result += addendum; return result; - } + gpu constexpr auto operator++(int) & noexcept -> Aesi { Aesi old = *this; operator++(); return old; } - /** - * @brief Assignment addition operator - * @param Aesi addendum - * @return Aesi& - */ - gpu constexpr auto operator+=(const Aesi& addendum) noexcept -> Aesi& { - if(sign == Zero) return this->operator=(addendum); - if(addendum.sign == Zero) return *this; - - if (sign != addendum.sign) { - if (sign == Negative) - blocks = makeComplement(blocks); - const uint64_t carryOut = (addendum.sign != Negative ? - addLine(blocks, addendum.blocks) : addLine(blocks, makeComplement(addendum.blocks))); - if (carryOut == 0) { - blocks = makeComplement(blocks); - sign = Negative; - } else sign = Positive; - } else - addLine(blocks, addendum.blocks); + gpu constexpr auto operator--() noexcept -> Aesi& { + if(sign == Sign::Negative) { + ++base; + } else if(sign == Sign::Positive) { + --base; if(base.isZero()) sign = Sign::Zero; + } else { base = 1u; sign = Sign::Negative; } + return *this; + } - if (isLineEmpty(blocks)) - sign = Zero; + gpu constexpr auto operator--(int) & noexcept -> Aesi { Aesi old = *this; operator--(); return old; } + /* --------------------------------------------------------------------------- */ - return *this; - } + /* ------------------------ @name Addition operators. ------------------------ */ + [[nodiscard]] + gpu constexpr auto operator+(const Aesi& addendum) const noexcept -> Aesi { Aesi result = *this; result += addendum; return result; } - /** - * @brief Subtraction operator - * @param Aesi subtrahend - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator-(const Aesi& subtrahend) const noexcept -> Aesi { - Aesi result = *this; result -= subtrahend; return result; - } - - /** - * @brief Assignment subtraction operator - * @param Aesi subtrahend - * @return Aesi& - */ - gpu constexpr auto operator-=(const Aesi& subtrahend) noexcept -> Aesi& { - return this->operator+=(-subtrahend); - } + gpu constexpr auto operator+=(const Aesi& addendum) noexcept -> Aesi& { + if(addendum.sign == Sign::Zero) /* Any += Zero; */ + return *this; + if(sign == Sign::Zero) /* Zero += Any; */ + return this->operator=(addendum); - /** - * @brief Multiplication operator - * @param Aesi factor - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator*(const Aesi& factor) const noexcept -> Aesi { - Aesi result = *this; result *= factor; return result; - } + if(sign == addendum.sign) { /* Positive += Positive; */ + base += addendum.base; + return *this; + } - /** - * @brief Assignment multiplication operator - * @param Aesi factor - * @return Aesi& - */ - gpu constexpr auto operator*=(const Aesi& factor) noexcept -> Aesi& { - if(sign == Zero) return *this; - if(factor.sign == Zero) return this->operator=(Aesi {}); - sign = (sign != factor.sign ? Negative : Positive); - - constexpr auto multiplyLines = [] (const blockLine& longerLine, const std::size_t longerLength, - const blockLine& smallerLine, const std::size_t smallerLength) { - blockLine buffer {}; - - for(std::size_t i = 0; i < longerLength; ++i) { - uint64_t tBlock = longerLine[i], carryOut = 0; - - for(std::size_t j = 0; j < smallerLength && i + j < buffer.size(); ++j) { - const auto product = tBlock * static_cast(smallerLine[j]) + carryOut; - const auto block = static_cast(buffer[i + j]) + (product % blockBase); - carryOut = product / blockBase + block / blockBase; - buffer[i + j] = block % blockBase; + if(sign == Sign::Positive) { /* Positive += Negative; */ + const auto ratio = base.compareTo(addendum.base); + switch(ratio) { + case Comparison::greater: { + base -= addendum.base; + return *this; + } + case Comparison::less: { + base = addendum.base - base; + sign = Sign::Negative; + return *this; + } + default: { + sign = Sign::Zero; + return *this; + } + } + } else { /* Negative += Positive; */ + const auto ratio = base.compareTo(addendum.base); + switch(ratio) { + case Comparison::greater: { + base -= addendum.base; + return *this; + } + case Comparison::less: { + base = addendum.base - base; + sign = Sign::Positive; + return *this; + } + default: { + sign = Sign::Zero; + return *this; + } } - - if(smallerLength < blocksNumber && smallerLength + i < buffer.size()) - buffer[smallerLength + i] += carryOut; + } + } + /* --------------------------------------------------------------------------- */ + + /* ----------------------- @name Subtraction operators. ---------------------- */ + [[nodiscard]] + gpu constexpr auto operator-(const Aesi& subtrahend) const noexcept -> Aesi { Aesi result = *this; result -= subtrahend; return result; } + + gpu constexpr auto operator-=(const Aesi& subtrahend) noexcept -> Aesi& { + if(subtrahend.sign == Sign::Zero) /* Any -= Zero; */ + return *this; + if(sign == Sign::Zero) { /* Zero -= Any; */ + *this = subtrahend; + this->inverse(); + return *this; } - return buffer; - }; - - const std::size_t thisLength = lineLength(blocks), valueLength = lineLength(factor.blocks); - if(thisLength > valueLength) - blocks = multiplyLines(blocks, thisLength, factor.blocks, valueLength); - else - blocks = multiplyLines(factor.blocks, valueLength, blocks, thisLength); - - return *this; - } - - /** - * @brief Division operator - * @param Aesi divisor - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator/(const Aesi& divisor) const noexcept -> Aesi { - Aesi quotient, _; - divide(*this, divisor, quotient, _); - return quotient; - } - - /** - * @brief Assignment division operator - * @param Aesi divisor - * @return Aesi& - */ - gpu constexpr auto operator/=(const Aesi& divisor) noexcept -> Aesi& { - return this->operator=(divide(*this, divisor).first); - } - - /** - * @brief Modulo operator - * @param Aesi modulo - * @return Aesi - */ - [[nodiscard]] - gpu constexpr auto operator%(const Aesi& modulo) const noexcept -> Aesi { - Aesi _, remainder; divide(*this, modulo, _, remainder); return remainder; - } - - /** - * @brief Assignment modulo operator - * @param Aesi modulo - * @return Aesi& - */ - gpu constexpr auto operator%=(const Aesi& modulo) noexcept -> Aesi& { - return this->operator=(divide(*this, modulo).second); - } - /* ----------------------------------------------------------------------- */ - - - /* ----------------------- @name Bitwise operators. ---------------------- */ - /** - * @brief Bitwise complement operator - * @return Aesi - * @note Does not affect the sign - */ - [[nodiscard]] - gpu constexpr auto operator~() const noexcept -> Aesi { - Aesi result {}; - for(std::size_t i = 0; i < blocksNumber; ++i) - result.blocks[i] = ~blocks[i]; - if(isLineEmpty(result.blocks)) - result.sign = Zero; else result.sign = sign; - return result; - } - - /** - * @brief Bitwise XOR operator - * @param Aesi other - * @return Aesi - * @note Does not affect the sign - */ - [[nodiscard]] - gpu constexpr auto operator^(const Aesi& other) const noexcept -> Aesi { - Aesi result = *this; result ^= other; return result; - } - - /** - * @brief Assignment bitwise XOR operator - * @param Aesi other - * @return Aesi& - * @note Does not affect the sign - */ - gpu constexpr auto operator^=(const Aesi& other) noexcept -> Aesi& { - for(std::size_t i = 0; i < blocksNumber; ++i) - blocks[i] ^= other.blocks[i]; - if(isLineEmpty(blocks)) sign = Zero; - return *this; - } - - /** - * @brief Bitwise AND operator - * @param Aesi other - * @return Aesi - * @note Does not affect the sign - */ - [[nodiscard]] - gpu constexpr auto operator&(const Aesi& other) const noexcept -> Aesi { - Aesi result = *this; result &= other; return result; - } - - /** - * @brief Assignment bitwise AND operator - * @param Aesi other - * @return Aesi& - * @note Does not affect the sign - */ - gpu constexpr auto operator&=(const Aesi& other) noexcept -> Aesi& { - for(std::size_t i = 0; i < blocksNumber; ++i) - blocks[i] &= other.blocks[i]; - if(isLineEmpty(blocks)) sign = Zero; - return *this; - } - - /** - * @brief Bitwise OR operator - * @param Aesi other - * @return Aesi - * @note Does not affect the sign - */ - [[nodiscard]] - gpu constexpr auto operator|(const Aesi& other) const noexcept -> Aesi { - Aesi result = *this; result |= other; return result; - } - - /** - * @brief Assignment bitwise OR operator - * @param Aesi other - * @return Aesi& - * @note Does not affect the sign - */ - gpu constexpr auto operator|=(const Aesi& other) noexcept -> Aesi& { - for(std::size_t i = 0; i < blocksNumber; ++i) - blocks[i] |= other.blocks[i]; - if(sign == Zero && !isLineEmpty(blocks)) sign = Positive; - return *this; - } - - /** - * @brief Left shift operator - * @param Integral bit_shift - * @return Aesi - * @note Does right shift (>>) for negative bit_shift value, and nothing for positive shift greater than precision - */ - template requires (std::is_integral_v) [[nodiscard]] - gpu constexpr auto operator<<(Integral bitShift) const noexcept -> Aesi { - Aesi result = *this; result.operator<<=(bitShift); return result; - } - - /** - * @brief Left shift assignment operator - * @param Integral bit_shift - * @return Aesi& - * @note Does right shift (>>=) for negative bit_shift value, and nothing for positive shift greater than precision - */ - template requires (std::is_integral_v) - gpu constexpr auto operator<<=(Integral bitShift) noexcept -> Aesi& { - if(bitShift < 0) - return this->operator>>=(-bitShift); - - if(bitShift < bitness && bitShift > 0) { - const std::size_t quotient = bitShift / blockBitLength, remainder = bitShift % blockBitLength; - const block stamp = (1UL << (blockBitLength - remainder)) - 1; - - for (long long i = blocksNumber - 1; i >= (quotient + (remainder ? 1 : 0)); --i) - blocks[i] = ((blocks[i - quotient] & stamp) << remainder) | ((blocks[i - quotient - (remainder ? 1 : 0)] & ~stamp) >> ((blockBitLength - remainder) % blockBitLength)); + if(sign == Sign::Positive) { + if(subtrahend.sign == Sign::Positive) { /* Positive -= Positive; */ + const auto ratio = base.compareTo(subtrahend.base); + switch(ratio) { + case Comparison::greater: { + base -= subtrahend.base; + return *this; + } + case Comparison::less: { + base = subtrahend.base - base; + sign = Sign::Negative; + return *this; + } + default: { + sign = Sign::Zero; + return *this; + } + } + } else { /* Positive -= Negative; */ + base += subtrahend.base; + return *this; + } + } else { + if(subtrahend.sign == Sign::Negative) { /* Negative -= Negative; */ + const auto ratio = base.compareTo(subtrahend.base); + switch(ratio) { + case Comparison::greater: { + base -= subtrahend.base; + return *this; + } + case Comparison::less: { + base = subtrahend.base - base; + sign = Sign::Positive; + return *this; + } + default: { + sign = Sign::Zero; + return *this; + } + } + } else { /* Negative -= Positive; */ + base += subtrahend.base; + return *this; + } + } + } + /* --------------------------------------------------------------------------- */ - blocks[quotient] = (blocks[0] & stamp) << remainder; + /* --------------------- @name Multiplication operators. --------------------- */ + template requires (std::is_integral_v) [[nodiscard]] + gpu constexpr auto operator*(Integral factor) const noexcept -> Aesi { Aesi result = *this; result *= factor; return result; } - for (std::size_t i = 0; i < quotient; ++i) - blocks[i] = 0; + [[nodiscard]] + gpu constexpr auto operator*(const Aesi& factor) const noexcept -> Aesi { Aesi result = *this; result *= factor; return result; } - if(isLineEmpty(blocks)) sign = Zero; + template requires (std::is_integral_v) + gpu constexpr auto operator*=(Integral factor) noexcept -> Aesi& { + if(factor == 0) { + sign = Sign::Zero; + } else { + if(factor < 0) { + this->inverse(); + factor *= -1; + } + base.operator*=(static_cast(factor)); + } + return *this; } - return *this; - } + gpu constexpr auto operator*=(const Aesi& factor) noexcept -> Aesi& { + if(factor.isZero()) { + sign = Sign::Zero; + } else { + if(factor.isNegative()) + this->inverse(); + base.operator*=(factor.base); + } + return *this; + } + /* --------------------------------------------------------------------------- */ + + /* ------------------------ @name Division operators. ------------------------ */ + /** + * @brief Division operator for built-in integral types + * @param divisor Integral + * @return Aesi + * @note Undefined behaviour for division by zero + */ + template requires (std::is_integral_v) [[nodiscard]] + gpu constexpr auto operator/(Integral divisor) const noexcept -> Aesi { Aesi result = *this; result /= divisor; return result; } + + /** + * @brief Division operator + * @param divisor Aesi + * @return Aesi + * @note Undefined behaviour for division by zero + */ + [[nodiscard]] + gpu constexpr auto operator/(const Aesi& divisor) const noexcept -> Aesi { Aesi result = *this; result /= divisor; return result; } + + /** + * @brief Assignment division operator for built-in integral types + * @param divisor Integral + * @return Aesi& + * @note Undefined behaviour for division by zero + */ + template requires (std::is_integral_v) + gpu constexpr auto operator/=(Integral divisor) noexcept -> Aesi& { + if(divisor == 0) { + sign = Sign::Zero; + } else { + if(divisor < 0) { + this->inverse(); + divisor *= -1; + } + base.operator/=(static_cast(divisor)); + if(base.isZero()) sign = Sign::Zero; + } + return *this; + } - /** - * @brief Right shift operator - * @param Integral bit_shift - * @return Aesi - * @note Does left shift (<<) for negative bit_shift value, and nothing for positive shift greater than precision - */ - template requires (std::is_integral_v) [[nodiscard]] - gpu constexpr auto operator>>(Integral bitShift) const noexcept -> Aesi { - Aesi result = *this; result >>= bitShift; return result; - } + /** + * @brief Assignment division operator + * @param divisor Aesi + * @return Aesi& + * @note Undefined behaviour for division by zero + */ + gpu constexpr auto operator/=(const Aesi& divisor) noexcept -> Aesi& { + if(divisor.isZero()) { + sign = Sign::Zero; + } else { + if(divisor.isNegative()) + this->inverse(); + base.operator/=(divisor.base); + if(base.isZero()) sign = Sign::Zero; + } + return *this; + } + /* --------------------------------------------------------------------------- */ - /** - * @brief Right shift assignment operator - * @param Integral bit_shift - * @return Aesi& - * @note Does left shift (<<=) for negative bit_shift value, and nothing for positive shift greater than precision - */ - template requires (std::is_integral_v) - gpu constexpr auto operator>>=(Integral bitShift) noexcept -> Aesi& { - if(bitShift < 0) - return this->operator<<=(-bitShift); + /* ------------------------- @name Modulo operators. ------------------------- */ + template requires (std::is_integral_v) [[nodiscard]] + gpu constexpr auto operator%(Integral modulo) const noexcept -> Aesi { Aesi result = *this; result %= modulo; return result; } - if(bitShift < bitness && bitShift > 0) { - const std::size_t quotient = bitShift / blockBitLength, remainder = bitShift % blockBitLength; - const block stamp = (1UL << remainder) - 1; + [[nodiscard]] + gpu constexpr auto operator%(const Aesi& modulo) const noexcept -> Aesi { Aesi result = *this; result %= modulo; return result; } - for(std::size_t i = 0; i < blocksNumber - (quotient + (remainder ? 1 : 0)); ++i) - blocks[i] = ((blocks[i + quotient + (remainder ? 1 : 0)] & stamp) << ((blockBitLength - remainder) % blockBitLength)) | ((blocks[i + quotient] & ~stamp) >> remainder); + template requires (std::is_integral_v) + gpu constexpr auto operator%=(Integral modulo) noexcept -> Aesi& { + if(modulo == 0) { + sign = Sign::Zero; + } else { + if(modulo < 0) { + this->inverse(); + modulo *= -1; + } + base.operator%=(static_cast(modulo)); + } + return *this; + } - blocks[blocksNumber - 1 - quotient] = (blocks[blocksNumber - 1] & ~stamp) >> remainder; + gpu constexpr auto operator%=(const Aesi& modulo) noexcept -> Aesi& { + if(modulo.isZero()) + return *this; - for(long long i = blocksNumber - quotient; i < blocksNumber; ++i) - blocks[i] = 0; + if(modulo.isNegative()) + this->inverse(); + base.operator%=(modulo.base); + if(base.isZero()) + sign = Sign::Zero; - if(isLineEmpty(blocks)) sign = Zero; + return *this; } - - return *this; - } + /* --------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */ - /* --------------------- @name Comparison operators. --------------------- */ - /** - * @brief Comparison operator - * @param Aesi other - * @return Bool - */ - gpu constexpr auto operator==(const Aesi& other) const noexcept -> bool { - if(sign != Zero || other.sign != Zero) - return (sign == other.sign && blocks == other.blocks); else return true; - }; + /* ------------------------ @name Equality operators. ------------------------ */ + template requires (std::is_integral_v) + gpu constexpr auto operator==(Integral value) const noexcept -> bool { + return compareTo(value) == Comparison::equal; + } - /** - * @brief Internal comparison operator - * @param Aesi other - * @return AesiCMP - * @note Should almost never return AesiCMP::Equivalent - */ - [[nodiscard]] - gpu constexpr auto compareTo(const Aesi& other) const noexcept -> AesiCMP { - switch (sign) { - case Zero: - switch (other.sign) { - case Zero: - return AesiCMP::equal; - case Positive: - return AesiCMP::less; - case Negative: - return AesiCMP::greater; + gpu constexpr auto operator==(const Aesi& other) const noexcept -> bool { + return sign == other.sign && base == other.base; + } + + template requires (otherBitness != bitness) + gpu constexpr auto operator==(const Aesi& other) const noexcept -> bool { + return precisionCast() == other; + } + /* --------------------------------------------------------------------------- */ + + + /* ----------------------- @name Comparison operators. ----------------------- */ + template requires (std::is_integral_v) + gpu constexpr auto compareTo(Integral value) const noexcept -> Comparison { + if(value == 0) { + switch(sign) { + case Sign::Positive: + return Comparison::greater; + case Sign::Negative: + return Comparison::less; default: - return AesiCMP::equivalent; + return Comparison::equal; } - case Positive: - switch (other.sign) { - case Positive: { - for(long long i = blocksNumber - 1; i >= 0; --i) { - const block thisBlock = blocks[i], otherBlock = other.blocks[i]; - if(thisBlock != otherBlock) - return (thisBlock > otherBlock ? AesiCMP::greater : AesiCMP::less); + } else if(value < 0) { + switch(sign) { + case Sign::Negative: + switch(base.compareTo(static_cast(value * -1))) { + case Comparison::greater: + return Comparison::less; + case Comparison::less: + return Comparison::greater; + default: + return Comparison::equal; } - return AesiCMP::equal; - } - case Zero: - case Negative: - return AesiCMP::greater; + case Sign::Positive: // + > - + default: // 0 > - + return Comparison::greater; + } + } else { + switch(sign) { + case Sign::Positive: + return base.compareTo(static_cast(value)); + case Sign::Negative: // - < + + default: // 0 < + + return Comparison::less; + } + } + } + + template [[nodiscard]] + gpu constexpr auto compareTo(const Aesi& value) const noexcept -> Comparison { + return precisionCast().compareTo(value); + } + + [[nodiscard]] + gpu constexpr auto compareTo(const Aesi& value) const noexcept -> Comparison { + if(value.isZero()) { + switch(sign) { + case Sign::Positive: + return Comparison::greater; // Positive > 0 + case Sign::Negative: + return Comparison::less; // Negative < 0 default: - return AesiCMP::equivalent; + return Comparison::equal; // 0 == 0 } - case Negative: - switch (other.sign) { - case Negative: { - for(long long i = blocksNumber - 1; i >= 0; --i) { - const block thisBlock = blocks[i], otherBlock = other.blocks[i]; - if(thisBlock != otherBlock) - return (thisBlock > otherBlock ? AesiCMP::less : AesiCMP::greater); + } else if(value.isNegative()) { + switch(sign) { + case Sign::Negative: + switch(base.compareTo(value.base)) { + case Comparison::greater: + return Comparison::less; // -100 < -20 + case Comparison::less: + return Comparison::greater; // -20 > -100 + default: + return Comparison::equal; // -30 == -30 } - return AesiCMP::equal; - } - case Zero: - case Positive: - return AesiCMP::less; - default: - return AesiCMP::equivalent; + default: // 0 > Negative + return Comparison::greater; // Positive > Negative + } + } else { + switch(sign) { + case Sign::Positive: + return base.compareTo(value.base); + default: // 0 < Positive + return Comparison::less; // Negative < Positive } - default: - return AesiCMP::equivalent; + } + } + /* --------------------------------------------------------------------------- */ + + /* ------------------------ @name Spaceship operators. ----------------------- */ +#if (defined(__CUDACC__) || __cplusplus < 202002L || defined (PRE_CPP_20)) && !defined DOXYGEN_SKIP + /** + * @brief Oldstyle comparison operator(s). Used inside CUDA cause it does not support <=> operator. + */ + gpu constexpr auto operator!=(const Aeu& value) const noexcept -> bool { + return !this->operator==(value); + } + gpu constexpr auto operator<(const Aeu& value) const noexcept -> bool { + return this->compareTo(value) == Comparison::less; + } + gpu constexpr auto operator<=(const Aeu& value) const noexcept -> bool { + return !this->operator>(value); + } + gpu constexpr auto operator>(const Aeu& value) const noexcept -> bool { + return this->compareTo(value) == Comparison::greater; + } + gpu constexpr auto operator>=(const Aeu& value) const noexcept -> bool { + return !this->operator<(value); } - }; - -#if (defined(__CUDACC__) || __cplusplus < 202002L || defined (DEVICE_TESTING)) && !defined DOXYGEN_SKIP - /** - * @brief Oldstyle comparison operator(s). Used inside CUDA cause it does not support <=> on device - */ - gpu constexpr auto operator!=(const Aesi& value) const noexcept -> bool { return !this->operator==(value); } - gpu constexpr auto operator<(const Aesi& value) const noexcept -> bool { return this->compareTo(value) == AesiCMP::less; } - gpu constexpr auto operator<=(const Aesi& value) const noexcept -> bool { return !this->operator>(value); } - gpu constexpr auto operator>(const Aesi& value) const noexcept -> bool { return this->compareTo(value) == AesiCMP::greater; } - gpu constexpr auto operator>=(const Aesi& value) const noexcept -> bool { return !this->operator<(value); } #else - /** - * @brief Three-way comparison operator - * @param Aesi other - * @return Std::Strong_ordering - * @note Should almost never return Strong_ordering::Equivalent - */ - gpu constexpr auto operator<=>(const Aesi& other) const noexcept -> std::strong_ordering { - const auto ratio = this->compareTo(other); - assert(ratio == AesiCMP::less || ratio == AesiCMP::greater || ratio == AesiCMP::equal); - - switch(ratio) { - case AesiCMP::less: - return std::strong_ordering::less; - case AesiCMP::greater: - return std::strong_ordering::greater; - case AesiCMP::equal: - return std::strong_ordering::equal; - default: - return std::strong_ordering::equivalent; + /** + * @brief Three-way comparison operator + * @param other Aesi + * @return Std::Strong_ordering + * @note Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent + */ + gpu constexpr auto operator<=>(const Aesi& other) const noexcept -> std::strong_ordering { + const auto ratio = this->compareTo(other); + switch(ratio) { + case Comparison::less: + return std::strong_ordering::less; + case Comparison::greater: + return std::strong_ordering::greater; + case Comparison::equal: + return std::strong_ordering::equal; + default: + return std::strong_ordering::equivalent; + } } - }; + + /** + * @brief Three-way comparison operator for numbers of different precision and built-in integral types + * @param other Unsigned + * @return Std::Strong_ordering + * @note Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent + */ + template + gpu constexpr auto operator<=>(const Object& other) const noexcept -> std::strong_ordering { + const auto ratio = this->compareTo(other); + switch(ratio) { + case Comparison::less: + return std::strong_ordering::less; + case Comparison::greater: + return std::strong_ordering::greater; + case Comparison::equal: + return std::strong_ordering::equal; + default: + return std::strong_ordering::equivalent; + } + }; #endif + /* --------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */ - /* ---------------------- @name Supporting methods. ---------------------- */ /** * @brief Set bit in number by index starting from the right - * @param Size_t index - * @param Bool bit - * @note Does nothing for index out of range + * @param index Size_t + * @param bit Boolean + * @note Does nothing for index out of range. Does not affect sign */ - gpu constexpr auto setBit(std::size_t index, bool bit) noexcept -> void { - if(index >= bitness) return; - const std::size_t blockNumber = index / blockBitLength, bitNumber = index % blockBitLength; - assert(blockNumber < blocksNumber && bitNumber < blockBitLength); - - if(bit) { - blocks[blockNumber] |= (1U << bitNumber); - if(sign == Zero && blocks[blockNumber] != 0) - sign = Positive; - } else { - blocks[blockNumber] &= (~(1U << bitNumber)); - if(sign != Zero && blocks[blockNumber] == 0 && isLineEmpty(blocks)) - sign = Zero; - } - } + gpu constexpr auto setBit(std::size_t index, bool bit) noexcept -> void { return base.setBit(index, bit); } /** - * @brief Get bit in number by index staring from the right - * @param Size_t index - * @return Bool - * @note Returns zero for index out of range + * @brief Get bit in number by index starting from the right + * @param index Size_t + * @return Boolean + * @note Returns zero for index out of range. Does not affect the sign */ [[nodiscard]] - gpu constexpr auto getBit(std::size_t index) const noexcept -> bool { - if(index >= bitness) return false; - const std::size_t blockNumber = index / blockBitLength, bitNumber = index % blockBitLength; - assert(blockNumber < blocksNumber && bitNumber < blockBitLength); - return blocks[blockNumber] & (1U << bitNumber); - } + gpu constexpr auto getBit(std::size_t index) const noexcept -> bool { return base.getBit(index); } /** * @brief Set byte in number by index starting from the right - * @param Size_t index - * @param Byte byte - * @note Does nothing for index out of range + * @param index Size_t + * @param byte Byte + * @note Does nothing for index out of range. Does not affect the sign */ - gpu constexpr auto setByte(std::size_t index, byte byte) noexcept -> void { - if(index > blocksNumber * sizeof(block)) return; - - const std::size_t blockNumber = index / sizeof(block), byteInBlock = index % sizeof(block), shift = byteInBlock * bitsInByte; - assert(blockNumber < blocksNumber && byteInBlock < sizeof(block)); - blocks[blockNumber] &= ~(0xffU << shift); blocks[blockNumber] |= static_cast(byte) << shift; - - if(sign == Zero && blocks[blockNumber] != 0) sign = Positive; - if(sign != Zero && blocks[blockNumber] == 0 && isLineEmpty(blocks)) sign = Zero; - } + gpu constexpr auto setByte(std::size_t index, byte byte) noexcept -> void { return base.setByte(index, byte); } /** * @brief Get byte in number by index starting from the right - * @param Size_t index + * @param index Size_t * @return Byte - * @note Returns zero for index out of range + * @note Returns zero for index out of range. Does not affect the sign */ [[nodiscard]] - gpu constexpr auto getByte(std::size_t index) const noexcept -> byte { - if(index > blocksNumber * sizeof(block)) return 0; - - const std::size_t blockNumber = index / sizeof(block), byteInBlock = index % sizeof(block), shift = byteInBlock * bitsInByte; - assert(blockNumber < blocksNumber && byteInBlock < sizeof(block)); - return (blocks[blockNumber] & (0xffU << shift)) >> shift; - } + gpu constexpr auto getByte(std::size_t index) const noexcept -> byte { return base.getByte(index); } /** * @brief Set block in number by index starting from the right - * @param Size_t index - * @param Block byte - * @note Does nothing for index out of range + * @param index Size_t + * @param block Block + * @note Does nothing for index out of range. Does not affect the sign */ - gpu constexpr auto setBlock(std::size_t index, block block) noexcept -> void { - if(index >= blocksNumber) return; blocks[index] = block; - - if(sign == Zero && block != 0) sign = Positive; - if(sign != Zero && block == 0 && isLineEmpty(blocks)) sign = Zero; - } + gpu constexpr auto setBlock(std::size_t index, block block) noexcept -> void { return base.setBlock(index, block); } /** * @brief Get block in number by index starting from the right - * @param Size_t index + * @param index Size_t * @return Block - * @note Returns zero for index out of range + * @note Returns zero for index out of range. Does not affect the sign */ [[nodiscard]] - gpu constexpr auto getBlock(std::size_t index) const noexcept -> block { - if(index >= blocksNumber) return block(); return blocks[index]; - } + gpu constexpr auto getBlock(std::size_t index) const noexcept -> block { return base.getBlock(index); } /** * @brief Get amount of non-empty bytes in number right to left * @return Size_t */ [[nodiscard]] - gpu constexpr auto byteCount() const noexcept -> std::size_t { - std::size_t lastBlock = blocksNumber - 1; - for(; lastBlock > 0 && blocks[lastBlock] == 0; --lastBlock); - - for(int8_t byteN = sizeof(block) - 1; byteN >= 0; --byteN) { - const auto byte = (blocks[lastBlock] & (0xffU << (byteN * bitsInByte))) >> (byteN * bitsInByte); - if(byte) - return lastBlock * sizeof(block) + byteN + 1; - } - return lastBlock * sizeof(block); - } + gpu constexpr auto byteCount() const noexcept -> std::size_t { return base.byteCount(); } /** * @brief Get amount of non-empty bits in number right to left * @return Size_t */ [[nodiscard]] - gpu constexpr auto bitCount() const noexcept -> std::size_t { - std::size_t lastBlock = blocksNumber - 1; - for(; lastBlock > 0 && blocks[lastBlock] == 0; --lastBlock); - - for(int8_t byteN = sizeof(block) - 1; byteN >= 0; --byteN) { - const auto byte = (blocks[lastBlock] & (0xffU << (byteN * bitsInByte))) >> (byteN * bitsInByte); - if(!byte) continue; - - for(int8_t bitN = bitsInByte - 1; bitN >= 0; --bitN) { - const auto bit = (byte & (0x1u << bitN)) >> bitN; - if(bit) - return (lastBlock * sizeof(block) + byteN) * bitsInByte + bitN + 1; - } - return ((lastBlock - 1) * sizeof(block) + byteN) * bitsInByte; - } - return lastBlock * sizeof(block); - } + gpu constexpr auto bitCount() const noexcept -> std::size_t { return base.bitCount(); } /** - * @brief Get number's absolute value - * @return Aesi + * @brief Check whether number is odd + * @return Boolean: true if the number is odd and false otherwise */ [[nodiscard]] - gpu constexpr auto abs() const noexcept -> Aesi { - if(sign == Zero) - return *this; - Aesi result = *this; result.sign = Positive; return result; - } + gpu constexpr auto isOdd() const noexcept -> bool { return base.isOdd(); } /** - * @brief Check whether number is odd - * @return Bool - true is number is odd and false otherwise + * @brief Check whether number is even + * @return Boolean: true if the number is even and false otherwise */ [[nodiscard]] - gpu constexpr auto isOdd() const noexcept -> bool { return (0x1 & blocks[0]) == 1; } + gpu constexpr auto isEven() const noexcept -> bool { return base.isEven(); } /** - * @brief Check whether number is even - * @return Bool - true is number is even and false otherwise + * @brief Check whether number is zero + * @return Boolean: true if the number is zero and false otherwise */ [[nodiscard]] - gpu constexpr auto isEven() const noexcept -> bool { return (0x1 & blocks[0]) == 0; } + gpu constexpr auto isZero() const noexcept -> bool { return sign == Sign::Zero; } /** - * @brief Check whether number is zero - * @return Bool - true is number is zero and false otherwise + * @brief Check whether number is positive + * @return Boolean: true if the number is positive and false otherwise */ [[nodiscard]] - gpu constexpr auto isZero() const noexcept -> bool { return sign == Zero; } + gpu constexpr auto isPositive() const noexcept -> bool { return sign == Sign::Positive; } /** - * @brief Get number's precision - * @return Size_t + * @brief Check whether number is negative + * @return Boolean: true if the number is negative and false otherwise */ [[nodiscard]] - gpu static constexpr auto getBitness() noexcept -> std::size_t { return bitness; } + gpu constexpr auto isNegative() const noexcept -> bool { return sign == Sign::Negative; } /** - * @brief Get number of blocks inside object + * @brief Get number of non-empty blocks inside object starting from the right * @return Size_t */ [[nodiscard]] - gpu static constexpr auto getBlocksNumber() noexcept -> std::size_t { return blocksNumber; } + gpu constexpr auto filledBlocksNumber() const noexcept -> std::size_t { return base.filledBlocksNumber(); } /** - * @brief Get square root - * @return Aesi - * @note Returns zero for negative value or zero + * @brief Get number's precision + * @return Size_t */ [[nodiscard]] - gpu constexpr auto squareRoot() const noexcept -> Aesi { - if(sign != Positive) - return Aesi {}; - - Aesi x, y = power2((bitCount() + 1) / 2); - - do { - x = y; - y = (x + this->operator/(x)) >> 1; - } while (y < x); + gpu static constexpr auto getBitness() noexcept -> std::size_t { return bitness; } - return x; - } + /** + * @brief Get the number of blocks (length of array of uint32_t integers) inside object + * @return Size_t + */ + [[nodiscard]] + gpu static constexpr auto totalBlocksNumber() noexcept -> std::size_t { return Aeu::totalBlocksNumber(); } /** * @brief Make swap between two objects - * @param Aesi other + * @param other Aesi */ gpu constexpr auto swap(Aesi& other) noexcept -> void { - Aesi t = other; other.operator=(*this); this->operator=(t); + Sign tSign = sign; sign = other.sign; other.sign = tSign; + base.swap(other.base); } /** - * @brief Inverse number's sign - * @param Aesi value + * @brief Invertes number's bitness + * @details Turns negative to positive and otherwise. Leaves zero unchanges */ - gpu constexpr auto inverse() noexcept -> void { - if(sign != Zero) - sign = (sign == Positive ? Negative : Positive); - } + gpu constexpr auto inverse() noexcept -> void { sign = (sign == Sign::Zero ? Sign::Zero : (sign == Sign::Negative ? Sign::Positive : Sign::Negative)); } /* ----------------------------------------------------------------------- */ - /* -------------- @name Public arithmetic and number theory. ------------- */ - /** - * @brief Integer division. Returns results by reference - * @param Aesi number - * @param Aesi divisor - * @param Aesi quotient OUT - * @param Aesi remainder OUT - * @return Quotient and remainder by reference - */ gpu static constexpr auto divide(const Aesi& number, const Aesi& divisor, Aesi& quotient, Aesi& remainder) noexcept -> void { - /* TODO Попробовать ускорить divide для работы со встроенными типами. */ - const Aesi divAbs = divisor.abs(); - const auto ratio = number.abs().compareTo(divAbs); - - quotient = Aesi {}; remainder = Aesi {}; - - if(ratio == AesiCMP::greater) { - const auto bitsUsed = lineLength(number.blocks) * blockBitLength; - for(long long i = bitsUsed - 1; i >= 0; --i) { - remainder <<= 1; - remainder.setBit(0, number.getBit(i)); - - if(remainder >= divAbs) { - remainder -= divAbs; - quotient.setBit(i, true); - } - } - - if(isLineEmpty(quotient.blocks)) - quotient.sign = Zero; else if(number.sign != divisor.sign) quotient = -quotient; - if(isLineEmpty(remainder.blocks)) - remainder.sign = Zero; else if(number.sign == Negative) remainder = -remainder; - } else if(ratio == AesiCMP::less) - remainder = number; else quotient = 1; - } - - /** - * @brief Extended Euclidean algorithm for greatest common divisor - * @param Aesi first - * @param Aesi second - * @param Aesi bezoutX OUT - * @param Aesi bezoutY OUT - * @return Aesi - * @details Counts Bézout coefficients along with the greatest common divisor. Returns coefficients by reference - */ - [[nodiscard]] - gpu static constexpr auto gcd(const Aesi& first, const Aesi& second, Aesi& bezoutX, Aesi& bezoutY) noexcept -> Aesi { - Aesi gcd, tGcd, quotient, remainder; - - const auto ratio = first.compareTo(second); - if(ratio == AesiCMP::greater) { - gcd = second; tGcd = first; - divide(first, second, quotient, remainder); - } else { - gcd = first; tGcd = second; - divide(second, first, quotient, remainder); - } - - bezoutX = 0; bezoutY = 1; - for(Aesi tX = 1, tY = 0; remainder != 0; ) { - tGcd = gcd; gcd = remainder; - - Aesi t = bezoutX; bezoutX = tX - quotient * bezoutX; tX = t; - t = bezoutY; bezoutY = tY - quotient * bezoutY; tY = t; - - divide(tGcd, gcd, quotient, remainder); + if(number.sign == Sign::Zero || divisor.sign == Sign::Zero) { + quotient.sign = Sign::Zero; + remainder.sign = Sign::Zero; + return; } - if(ratio != AesiCMP::greater) - bezoutX.swap(bezoutY); - - return gcd; - } - - /** - * @brief Least common multiplier - * @param Aesi first - * @param Aesi second - * @return Aesi - */ - [[nodiscard]] - gpu static constexpr auto lcm(const Aesi& first, const Aesi& second) noexcept -> Aesi { - Aesi bezoutX, bezoutY; return first / gcd(first, second, bezoutX, bezoutY) * second; - } - - /** - * @brief Exponentiation by modulo - * @param Aesi base - * @param Aesi power - * @param Aesi modulo - * @return - * Aesi - * @note Be aware of overflow - */ - [[nodiscard]] - gpu static constexpr auto powm(const Aesi& base, const Aesi& power, const Aesi& mod) noexcept -> Aesi { - constexpr auto remainingBlocksEmpty = [] (const Aesi& value, std::size_t offset) { - for(std::size_t i = offset / blockBitLength; i < value.blocksNumber; ++i) { - /* TODO Отказаться от деления в счетчике */ - if (value.blocks[i] != 0) return false; + Base::divide(number.base, divisor.base, quotient.base, remainder.base); + if(number.sign == Sign::Positive) { + if(divisor.sign == Sign::Positive) { + // (+; +) -> (+; +) + quotient.sign = Sign::Positive; + remainder.sign = Sign::Positive; + } else { + // (+; -) -> (-; +) + quotient.sign = Sign::Negative; + remainder.sign = Sign::Positive; } - return true; - }; - - /* Base - точно Aesi, power - можно числом, mod - точно Aesi. - * */ - - Aesi result = 1; - auto [_, b] = divide(base, mod); - - /* TODO Странная штука remainingBlocksEmpty(power). Привести power к встроенному типу. */ - for(unsigned iteration = 0; !remainingBlocksEmpty(power, iteration); iteration++) { - if(power.getBit(iteration)) { - const auto [quotient, remainder] = divide(result * b, mod); - result = remainder; + } else { + if(divisor.sign == Sign::Positive) { + // (-; +) -> (-; -) + quotient.sign = Sign::Negative; + remainder.sign = Sign::Negative; + } else { + // (-; -) -> (+; -) + quotient.sign = Sign::Positive; + remainder.sign = Sign::Negative; } - - const auto [quotient, remainder] = divide(b * b, mod); - b = remainder; } - return result; - } - - /** - * @brief Fast exponentiation for powers of 2 - * @param Size_t power - * @return Aesi - * @details Returns zero for power greater than current bitness - */ - [[nodiscard]] - gpu static constexpr auto power2(std::size_t e) noexcept -> Aesi { - Aesi result {}; result.setBit(e, true); return result; + if(quotient.base.isZero()) + quotient.sign = Sign::Zero; + if(remainder.base.isZero()) + remainder.sign = Sign::Zero; } - /* ----------------------------------------------------------------------- */ - /* ------------ @name Arithmetic and number theory overrides. ------------ */ - /** - * @brief Greatest common divisor - * @param Aesi first - * @param Aesi second - * @return Aesi - */ [[nodiscard]] - gpu static constexpr auto gcd(const Aesi& first, const Aesi& second) noexcept -> Aesi { - Aesi bezoutX, bezoutY; return gcd(first, second, bezoutX, bezoutY); + gpu constexpr auto squareRoot() const noexcept -> Aesi { + if(sign == Sign::Positive) + return Aesi { Sign::Positive, base.squareRoot() }; + Aesi result; result.sign = Sign::Zero; return result; } - /** - * @brief Integer division. Returns results by value in pair - * @param Aesi number - * @param Aesi divisor - * @return Pair(Quotient, Remainder) - */ [[nodiscard]] - gpu static constexpr auto divide(const Aesi& number, const Aesi& divisor) noexcept -> pair { - pair results; divide(number, divisor, results.first, results.second); return results; + gpu static constexpr auto power2(std::size_t power) noexcept -> Aesi { + Aesi result { Sign::Positive, Aeu::power2(power) }; + if(result.base.isZero()) + result.sign = Sign::Zero; + return result; } /* ----------------------------------------------------------------------- */ - /** - * @brief Built-in integral type cast operator - * @param Type integral_type TEMPLATE - * @return Integral - * @details Takes the lowes part of Aesi for conversion. Accepts signed and unsigned types - */ template requires (std::is_integral_v) [[nodiscard]] gpu constexpr auto integralCast() const noexcept -> Integral { - const uint64_t value = (static_cast(blocks[1]) << blockBitLength) | static_cast(blocks[0]); - if constexpr (std::is_signed_v) - return static_cast(value) * (sign == Negative ? -1 : 1); else return static_cast(value); + if(sign == Sign::Zero) + return Integral(0); + + if constexpr (std::is_signed_v) { + if(sign == Sign::Negative) + return base.template integralCast() * -1; + } + + return base.template integralCast(); } - /** - * @brief Precision cast operator - * @param Size_t new_bitness TEMPLATE - * @return Aesi - * @details If required precision greater than current precision, remaining blocks are filled with zeros. - * Otherwise - number is cropped inside smaller blocks array - * @note This method is used in all manipulations between numbers of different precision. Using this method is not recommended, - * cause it leads to redundant copying and may be slow - */ template requires (newBitness != bitness) [[nodiscard]] gpu constexpr auto precisionCast() const noexcept -> Aesi { - Aesi result {}; + if(sign != Sign::Zero) { + Aesi result = 1; - const std::size_t blockBoarder = (newBitness > bitness ? Aesi::blocksNumber : Aesi::getBlocksNumber()); - for(std::size_t blockIdx = 0; blockIdx < blockBoarder; ++blockIdx) - result.setBlock(blockIdx, blocks[blockIdx]); + const std::size_t blockBoarder = (newBitness > bitness ? Aesi::totalBlocksNumber() : Aesi::totalBlocksNumber()); + for(std::size_t blockIdx = 0; blockIdx < blockBoarder; ++blockIdx) + result.setBlock(blockIdx, getBlock(blockIdx)); - if(sign == Negative) result.inverse(); return result; - } + if(sign == Sign::Negative) + result.inverse(); - /* ----------------- @name Public input-output operators. ---------------- */ - /** - * @brief Character buffer output operator - * @param Byte base TEMPLATE - * @param Char* buffer - * @param Size_t buffer_size - * @param Bool show_number_base - * @param Bool use_hexadecimal_uppercase - * @return Size_t - amount of symbols written - * @details Places the maximum possible amount of number's characters in buffer. Base parameter should be 2, 8, 10, or 16 - * @note Works significantly faster for hexadecimal notation - */ - template requires (std::is_same_v || std::is_same_v && - (base == 2 || base == 8 || base == 10 || base == 16)) - gpu constexpr auto getString(Char* const buffer, std::size_t bufferSize, bool showBase = false, bool hexUppercase = false) const noexcept -> std::size_t { - if(bufferSize < 2) return 0; + return result; + } else return Aesi {}; + } - std::size_t position = 0; + gpu constexpr auto unsignedCast() const noexcept -> Aeu { return base; } - if (showBase && bufferSize > 3) { - if constexpr (base == 2) { - if constexpr (std::is_same_v) { - memcpy(buffer, "0b", 2 * sizeof(Char)); - } else { - memcpy(buffer, L"0b", 2 * sizeof(Char)); - } - position += 2; - } else if constexpr (base == 8) { - if constexpr (std::is_same_v) { - memcpy(buffer, "0o", 2 * sizeof(Char)); - } else { - memcpy(buffer, L"0o", 2 * sizeof(Char)); - } - position += 2; - } else if constexpr (base == 16) { - if constexpr (std::is_same_v) { - memcpy(buffer, "0x", 2 * sizeof(Char)); - } else { - memcpy(buffer, L"0x", 2 * sizeof(Char)); - } - position += 2; + /* ----------------- @name Public input-output operators. ---------------- */ + template requires (std::is_same_v || std::is_same_v && (notation == 2 || notation == 8 || notation == 10 || notation == 16)) + gpu constexpr auto getString(Char* buffer, std::size_t bufferSize, bool showBase = false, bool hexUppercase = false) const noexcept -> std::size_t { + if(sign != Sign::Zero) { + if(sign == Sign::Negative && bufferSize > 0) { + *buffer++ = [] { if constexpr (std::is_same_v) { return '-'; } else { return L'-'; } } (); + --bufferSize; } + return base.template getString(buffer, bufferSize, showBase, hexUppercase); } - - if(sign != Zero) { - if constexpr (base == 16) { - long long iter = blocks.size() - 1; - for (; blocks[iter] == 0 && iter >= 0; --iter); - - if constexpr (std::is_same_v) { - position += snprintf(buffer + position, bufferSize - position, (hexUppercase ? "%X" : "%x"), blocks[iter--]); - for (; iter >= 0; --iter) - position += snprintf(buffer + position, bufferSize - position, (hexUppercase ? "%08X" : "%08x"), blocks[iter]); - } else { - position += swprintf(buffer + position, bufferSize - position, (hexUppercase ? L"%X" : L"%x"), blocks[iter--]); - for (; iter >= 0; --iter) - position += swprintf(buffer + position, bufferSize - position, (hexUppercase ? L"%08X" : L"%08x"), blocks[iter]); + if(showBase) { + switch(notation) { + case 2: { + if(bufferSize < 3) return 0; + buffer[0] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } (); + buffer[1] = [] { if constexpr (std::is_same_v) { return 'b'; } else { return L'b'; } } (); + buffer[2] = buffer[0]; + return 3; } - } else { - const auto startPosition = position; - - Aesi copy = *this; - while (copy != 0 && position < bufferSize) { - auto [quotient, remainder] = divide(copy, base); - if constexpr (std::is_same_v) { - buffer[position++] = '0' + remainder.template integralCast(); - } else { - buffer[position++] = L'0' + remainder.template integralCast(); - } - copy = quotient; + case 8: { + if(bufferSize < 3) return 0; + buffer[0] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } (); + buffer[1] = [] { if constexpr (std::is_same_v) { return 'o'; } else { return L'o'; } } (); + buffer[2] = buffer[0]; + return 3; } - - for (std::size_t i = startPosition; i * 2 < position; ++i) { - Char t = buffer[i]; buffer[i] = buffer[position - 1 - i]; buffer[position - 1 - i] = t; - } - } - } else - if constexpr (std::is_same_v) { - buffer[position++] = '0'; - } else { - buffer[position++] = L'0'; - } - buffer[position++] = Char {}; - return position; - } - - /** - * @brief STD stream output operator - * @param Ostream stream - * @param Aesi number - * @return Ostream - * @details Writes number in stream. Accepts STD streams based on char or wchar_t. Supports stream manipulators: - * - Number's notation (std::hex, std::dec, std::oct); - * - Number's base (std::showbase); - * - Hexadecimal letters case (std::uppercase, std::lowercase) - * @note Works significantly faster for hexadecimal notation - */ - template requires (std::is_same_v || std::is_same_v) - friend constexpr auto operator<<(std::basic_ostream& ss, const Aesi& value) -> std::basic_ostream& { - auto flags = ss.flags(); - - if(value.sign != Zero) { - if (value.sign == Negative) ss.write([] { if constexpr (std::is_same_v) { return "-"; } else { return L"-"; } } (), 1); - - const auto base = [] (long baseField, std::basic_ostream& ss, bool showbase) { - auto base = (baseField == std::ios::hex ? 16 : (baseField == std::ios::oct ? 8 : 10)); - if(showbase && base != 10) - ss << [&base] { if constexpr (std::is_same_v) { return base == 8 ? "0o" : "0x"; } else { return base == 8 ? L"0o" : L"0x"; }} () << std::noshowbase ; - return base; - } (flags & std::ios::basefield, ss, flags & std::ios::showbase); - - if(base == 16) { - long long iter = value.blocks.size() - 1; - for(; value.blocks[iter] == 0 && iter >= 0; --iter); - - ss << value.blocks[iter--]; - for (; iter >= 0; --iter) { - ss.fill([] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } ()); - ss.width(8); ss << std::right << value.blocks[iter]; + case 16: { + if(bufferSize < 3) return 0; + buffer[0] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } (); + buffer[1] = [] { if constexpr (std::is_same_v) { return 'x'; } else { return L'x'; } } (); + buffer[2] = buffer[0]; + return 3; } - } else { - /* Well, here we use a pre-calculated magic number to ratio the length of numbers in decimal or octal notation according to bitness. - * * It is 2.95-98 for octal and 3.2 for decimal. */ - constexpr auto bufferSize = static_cast(static_cast(bitness) / 2.95); - Char buffer [bufferSize] {}; std::size_t filled = 0; - - Aesi copy = value; - while(copy != 0 && filled < bufferSize) { - const auto [quotient, remainder] = divide(copy, base); - buffer[filled++] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } () + remainder.template integralCast(); - copy = quotient; + default: { + if(bufferSize < 1) return 0; + buffer[0] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } (); + return 1; } - - for(; filled > 0; --filled) - ss << buffer[filled - 1]; } - } else ss.write([] { if constexpr (std::is_same_v) { return "0"; } else { return L"0"; } } (), 1); - - return ss; - } - - - /** - * @brief STD stream binary reading operator - * @param Istream stream - * @param Boolean big_endian - * @return Aesi - * @details Reads number from stream using .read method. Accepts STD streams based on char or wchar_t. - * @note Fills empty bits with 0s on EOF of the stream - */ - template requires (std::is_same_v || std::is_same_v) - constexpr auto readBinary(std::basic_istream& istream, bool bigEndian = true) -> void { - blocks = {}; sign = Positive; - if(bigEndian) { - for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) - if(!istream.read(reinterpret_cast(&*it), sizeof(block))) break; - } else { - for(auto& tBlock: blocks) - if(!istream.read(reinterpret_cast(&tBlock), sizeof(block))) break; } - } + buffer[0] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } (); + return 1; + } - /** - * @brief STD stream binary writing operator - * @param Ostream stream - * @param Boolean big_endian - * @details Writes number in stream using .write method. Accepts STD streams based on char or wchar_t. - */ template requires (std::is_same_v || std::is_same_v) - constexpr auto writeBinary(std::basic_ostream& ostream, bool bigEndian = true) const noexcept -> void { - if(bigEndian) { - for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) - if(!ostream.write(reinterpret_cast(&*it), sizeof(block))) break; - } else { - for(auto& block: blocks) - if(!ostream.write(reinterpret_cast(&block), sizeof(block))) break; + friend constexpr auto operator<<(std::basic_ostream& ss, const Aesi& value) -> std::basic_ostream& { + if(value.sign != Sign::Zero) { + if(value.sign == Sign::Negative) + ss << [] { if constexpr (std::is_same_v) { return '-'; } else { return L'-'; } } (); + return ss << value.base; } + return ss << '0'; } /* ----------------------------------------------------------------------- */ @@ -1319,11 +850,7 @@ class Aesi final { * @note Method itself is not atomic. There may be race conditions between two consecutive atomic calls on number blocks. * This method is an interface for assigning encapsulated class members atomically one by one */ - __device__ constexpr auto tryAtomicSet(const Aesi& value) noexcept -> void { - sign = value.sign; - for(std::size_t i = 0; i < blocksNumber; ++i) - atomicExch(&blocks[i], value.blocks[i]); - } + __device__ constexpr auto tryAtomicSet(const Aesi& value) noexcept -> void {} /** * @brief Atomicity-oriented object exchangement operator @@ -1331,11 +858,7 @@ class Aesi final { * @note Method itself is not atomic. There may be race conditions between two consecutive atomic calls on number blocks. * This method is an interface for exchanging encapsulated class members atomically one by one */ - __device__ constexpr auto tryAtomicExchange(const Aesi& value) noexcept -> void { - Sign tSign = sign; sign = value.sign; value.sign = tSign; - for(std::size_t i = 0; i < blocksNumber; ++i) - atomicExch(&value.blocks[i], atomicExch(&blocks[i], value.blocks[i])); - } + __device__ constexpr auto tryAtomicExchange(const Aesi& value) noexcept -> void {} #endif }; @@ -1396,95 +919,78 @@ using Aesi6144 = Aesi<6144>; using Aesi8192 = Aesi<8192>; /* ---------------------------------------------------------------------------------------------------------------- */ - /* ------------------------------------------ @name Integral conversions ----------------------------------------- */ /** * @brief Integral conversion addition operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator+(Integral number, const Aesi& value) noexcept { - return Aesi(number) + value; -} +gpu constexpr auto operator+(Integral number, const Aesi& value) noexcept { return Aesi(number) + value; } /** * @brief Integral conversion subtraction operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator-(Integral number, const Aesi& value) noexcept { - return Aesi(number) - value; -} +gpu constexpr auto operator-(Integral number, const Aesi& value) noexcept { return Aesi(number) - value; } /** * @brief Integral conversion multiplication operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator*(Integral number, const Aesi& value) noexcept { - return Aesi(number) * value; -} +gpu constexpr auto operator*(Integral number, const Aesi& value) noexcept { return Aesi(number) * value; } /** * @brief Integral conversion division operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator/(Integral number, const Aesi& value) noexcept { - return Aesi(number) / value; -} +gpu constexpr auto operator/(Integral number, const Aesi& value) noexcept { return Aesi(number) / value; } /** * @brief Integral conversion modulo operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator%(Integral number, const Aesi& value) noexcept { - return Aesi(number) % value; -} +gpu constexpr auto operator%(Integral number, const Aesi& value) noexcept { return Aesi(number) % value; } /** * @brief Integral conversion bitwise XOR operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator^(Integral number, const Aesi& value) noexcept { - return Aesi(number) ^ value; -} +gpu constexpr auto operator^(Integral number, const Aesi& value) noexcept { return Aesi(number) ^ value; } /** * @brief Integral conversion bitwise AND operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator&(Integral number, const Aesi& value) noexcept { - return Aesi(number) & value; -} +gpu constexpr auto operator&(Integral number, const Aesi& value) noexcept { return Aesi(number) & value; } /** * @brief Integral conversion bitwise OR operator - * @param Integral number - * @param Aesi value + * @param number Integral + * @param value Aesi * @return Aesi */ template requires (std::is_integral_v) -gpu constexpr auto operator|(Integral number, const Aesi& value) noexcept { - return Aesi(number) | value; -} +gpu constexpr auto operator|(Integral number, const Aesi& value) noexcept { return Aesi(number) | value; } /* ---------------------------------------------------------------------------------------------------------------- */ #endif //AESI_MULTIPRECISION diff --git a/Aeu.h b/Aeu.h new file mode 100755 index 0000000..2b3aac7 --- /dev/null +++ b/Aeu.h @@ -0,0 +1,1585 @@ +#ifndef AEU_MULTIPRECISION +#define AEU_MULTIPRECISION + +/// @cond HIDE_INCLUDES +#include +#include +#include + +#ifdef __CUDACC__ +#define gpu __host__ __device__ + #include + #include +#else +#define gpu + #include + #include +#endif +/// @endcond + +#if defined AESI_UNSAFE + #warning Enabled nightly mode for the library. Functions and methods input arguments are not checked for validity. Be really gentle +#endif + +#ifdef AESI_CRYPTOPP_INTEGRATION +#include +#endif + +#ifdef AESI_GMP_INTEGRATION +#include +#endif + +/** + * @file Aeu.h + * @brief Long precision unsigned integer with arithmetic operations + */ + +namespace { + using byte = uint8_t; + using block = uint32_t; + + constexpr inline std::size_t bitsInByte = 8, blockBitLength = sizeof(block) * bitsInByte; + constexpr inline uint64_t blockBase = 1ULL << blockBitLength; + constexpr inline block blockMax = 0xff'ff'ff'ffu; + + /** + * @enum Comparison + * @brief Analogue of STD::Strong_ordering since CUDA does not support <=> operator + */ + enum Comparison { equal = 0, less = 1, greater = 2, equivalent = 3 }; +} + +/** + * @class Aeu + * @brief Long precision unsigned integer + * @details May be used to represent only positive integers. For negative use Aesi. Number precision is set in template parameter bitness. + */ +template requires (bitness % blockBitLength == 0) +class Aeu final { + static_assert(bitness > sizeof(uint64_t), "Use built-in types for numbers 64-bit or less."); + + static constexpr std::size_t blocksNumber = bitness / blockBitLength; + +#ifdef __CUDACC__ + template + using pair = cuda::std::pair; + using blockLine = cuda::std::array; +#else + template + using pair = std::pair; + using blockLine = std::array; +#endif + + /* -------------------------- @name Class members. ----------------------- */ + /** + * @brief Block line of the number + */ + blockLine blocks; + /* ----------------------------------------------------------------------- */ + + /* ------------------------ @name Helper functions. ---------------------- */ + /** + * @brief Makes line addition + * @param dst BlockLine + * @param src BlockLine + * @return Uint64 - carry out from addition + */ + gpu static constexpr auto addLine(blockLine& dst, const blockLine& src) noexcept -> uint64_t { + uint64_t carryOut = 0; + for (std::size_t i = 0; i < blocksNumber; ++i) { + uint64_t sum = static_cast(dst[i]) + static_cast(src[i]) + carryOut; + carryOut = sum / blockBase; dst[i] = static_cast(sum % blockBase); + } + return carryOut; + } + + /** + * @brief Makes complement block line for line + * @param line BlockLine + * @return BlockLine + */ + gpu static constexpr auto makeComplement(blockLine& line) noexcept -> uint64_t { + uint64_t carryOut = 1; + for(std::size_t i = 0; i < blocksNumber; ++i) { + const uint64_t sum = blockBase - 1ULL - static_cast(line[i]) + carryOut; + carryOut = sum / blockBase; line[i] = static_cast(sum % blockBase); + } + return carryOut; + } + /* ----------------------------------------------------------------------- */ + +public: + /* --------------------- @name Different constructors. ------------------- */ + /** + * @brief Default constructor + */ + gpu constexpr Aeu() noexcept = default; + + /** + * @brief Copy constructor + */ + gpu constexpr Aeu(const Aeu& copy) noexcept = default; + + /** + * @brief Copy assignment operator + * @param other Aeu + */ + gpu constexpr Aeu& operator=(const Aeu& other) noexcept { blocks = other.blocks; return *this; } + + /** + * @brief Integral constructor + * @param value Integral + * @details Accepts both signed and unsigned built-in integral types. When calling this constructor on negative value, final blocks would be inverted. + * @note Be aware of calling this constructor explicitly + */ + template requires (std::is_unsigned_v) + gpu constexpr Aeu(Integral value) noexcept { + if(value != 0) { + uint64_t tValue = (value < 0 ? static_cast(value * -1) : static_cast(value)); + for (std::size_t i = 0; i < blocksNumber; ++i) { + blocks[i] = static_cast(tValue % blockBase); + tValue /= blockBase; + } + if(value < 0) + makeComplement(blocks); + } else + blocks = {}; + } + + /** + * @brief Pointer-based character constructor + * @param data Char* + * @param size Size_t + * @details Accepts decimal strings (no prefix), binary (0b/0B), octal (0o/0O) and hexadecimal (0x/0X) + */ + template requires (std::is_same_v || std::is_same_v) + gpu constexpr Aeu(const Char* data, std::size_t size) noexcept : Aeu {} { + if(size == 0) return; + + constexpr const Char* characters = [] { + if constexpr (std::is_same_v) { + return "09aAfFoObBxX"; + } else { + return L"09aAfFoObBxX"; + } + } (); + std::size_t position = 0; + + if constexpr (std::is_same_v) { + for(; !std::isalnum(data[position]) && position < size; ++position) ; + } else { + for(; !std::iswalnum(data[position]) && position < size; ++position) ; + } + + const auto base = [&data, &size, &position, &characters] { + if (data[position] == characters[0] && size > position + 1) { + switch (data[position + 1]) { + case characters[8]: + case characters[9]: + position += 2; return 2u; + case characters[6]: + case characters[7]: + position += 2; return 8u; + case characters[10]: + case characters[11]: + position += 2; return 16u; + default: + return 10u; + } + } return 10u; + } (); + for(; position < size; ++position) { + const auto digit = [&characters] (Char ch) { + if(characters[0] <= ch && ch <= characters[1]) + return static_cast(ch) - static_cast(characters[0]); + if(characters[2] <= ch && ch <= characters[4]) + return static_cast(ch) - static_cast(characters[2]) + 10u; + if(characters[3] <= ch && ch <= characters[5]) + return static_cast(ch) - static_cast(characters[3]) + 10u; + return 99u; + } (data[position]); + + if(digit < base) { + this->operator*=(base); + this->operator+=(digit); + } + } + } + + /** + * @brief C-style string literal constructor + * @param literal Char[] + * @details Accepts decimal literals along with binary (starting with 0b/0B), octal (0o/0O) and hexadecimal (0x/0X) + */ + template requires (arrayLength > 1 && (std::is_same_v || std::is_same_v)) + gpu constexpr Aeu(const Char (&literal)[arrayLength]) noexcept : Aeu(literal, arrayLength) {} + + /** + * @brief String or string-view based constructor + * @param stringView String/String-View + * @details Constructs object from STD::Basic_String or STD::Basic_String_View. Accepts objects based on char or wchar_t + */ + template requires (std::is_same_v, + typename std::decay::type> || std::is_same_v, typename std::decay::type>) + gpu constexpr Aeu(String&& stringView) noexcept : Aeu(stringView.data(), stringView.size()) {} + + template requires (std::is_same_v, + typename std::decay::type> || std::is_same_v, typename std::decay::type>) + gpu constexpr Aeu(const String& stringView) noexcept : Aeu(stringView.data(), stringView.size()) {} + +#ifdef AESI_CRYPTOPP_INTEGRATION + /** + * @brief Constructor from the CryptoPP library integer value + * @param value CryptoPP::Integer + */ + constexpr Aeu(const CryptoPP::Integer& value): Aeu {} { + const auto byteCount = value.ByteCount(); + if(byteCount * 8 > bitness) + throw std::invalid_argument("Accessed overflow on construction object from CryptoPP::Integer"); + for(std::size_t i = 0; i < byteCount; ++i) + setByte(i, value.GetByte(i)); + } +#endif + +#ifdef AESI_GMP_INTEGRATION + /** + * @brief Constructor from the GMP library integer value + * @param value mpz_class + */ + constexpr Aeu(const mpz_class& value) : Aeu {} { + const auto bitLength = mpz_sizeinbase(value.get_mpz_t(), 2); + auto tBlocksNumber = static_cast(1 + ((bitLength - 1) / sizeof(block) * 8)); + + std::basic_string buffer (tBlocksNumber, 0u); + mpz_export(buffer.data(), &tBlocksNumber, -1, sizeof(block), -1, 0, value.get_mpz_t()); + + for (std::size_t i = 0; i < tBlocksNumber; ++i) + setBlock(i, buffer[i]); + } +#endif + /* ----------------------------------------------------------------------- */ + + + /* --------------------- @name Arithmetic operators. --------------------- */ + /* ------------------------- @name Unary operators. -------------------------- */ + /** + * @brief Unary plus operator + * @return Aeu + * @note Does basically nothing + */ + [[nodiscard]] + gpu constexpr auto operator+() const noexcept -> Aeu { return *this; } + + /** + * @brief Unary minus operator + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator-() const noexcept -> Aeu { + Aeu result = *this; makeComplement(result.blocks); return result; + } + + /** + * @brief Prefix increment + * @return Aeu& + */ + gpu constexpr auto operator++() noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) { + if(blocks[i] < blockMax) { + ++blocks[i]; + break; + } else blocks[i] = 0u; + } + return *this; + } + + /** + * @brief Postfix increment + * @return Aeu + */ + gpu constexpr auto operator++(int) & noexcept -> Aeu { Aeu old = *this; operator++(); return old; } + + /** + * @brief Prefix decrement + * @return Aeu& + */ + gpu constexpr auto operator--() noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) { + if(blocks[i] > 0u) { + --blocks[i]; + break; + } else blocks[i] = blockMax; + } + return *this; + } + + /** + * @brief Postfix decrement + * @return Aeu + */ + gpu constexpr auto operator--(int) & noexcept -> Aeu { Aeu old = *this; operator--(); return old; } + /* --------------------------------------------------------------------------- */ + + + /* ------------------------ @name Addition operators. ------------------------ */ + /** + * @brief Addition operator for built-in integral types + * @param addendum Unsigned + * @return Aeu + */ + template requires (std::is_unsigned_v) [[nodiscard]] + gpu constexpr auto operator+(Unsigned addendum) const noexcept -> Aeu { + Aeu result = *this; result.operator+=(addendum); return result; + } + + /** + * @brief Addition operator + * @param addendum Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator+(const Aeu& addendum) const noexcept -> Aeu { + Aeu result = *this; result += addendum; return result; + } + + /** + * @brief Assignment addition operator for built-in integral types + * @param addendum Unsigned + * @return Aeu& + */ + template requires (std::is_unsigned_v) + gpu constexpr auto operator+=(Unsigned addendum) noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) { + const auto currentSum = static_cast(blocks[i]) + static_cast(addendum); + addendum = currentSum / blockBase; blocks[i] = currentSum % blockBase; + } + return *this; + } + + /** + * @brief Assignment addition operator + * @param addendum Aeu + * @return Aeu& + */ + gpu constexpr auto operator+=(const Aeu& addendum) noexcept -> Aeu& { + addLine(blocks, addendum.blocks); return *this; + } + /* --------------------------------------------------------------------------- */ + + + /* ----------------------- @name Subtraction operators. ---------------------- */ + /** + * @brief Subtraction operator + * @param subtrahend Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator-(const Aeu& subtrahend) const noexcept -> Aeu { + Aeu result = *this; result -= subtrahend; return result; + } + + /** + * @brief Assignment subtraction operator + * @param subtrahend Aeu + * @return Aeu& + */ + gpu constexpr auto operator-=(const Aeu& subtrahend) noexcept -> Aeu& { + return this->operator+=(-subtrahend); + } + /* --------------------------------------------------------------------------- */ + + + /* --------------------- @name Multiplication operators. --------------------- */ + /** + * @brief Multiplication operator for built-in integral types + * @param factor Unsigned + * @return Aeu + */ + template requires (std::is_unsigned_v) [[nodiscard]] + gpu constexpr auto operator*(Unsigned factor) const noexcept -> Aeu { + Aeu result = *this; result.operator*=(factor); return result; + } + + /** + * @brief Multiplication operator + * @param factor Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator*(const Aeu& factor) const noexcept -> Aeu { + Aeu result = *this; result *= factor; return result; + } + + /** + * @brief Assignment multiplication operator for built-in integral types + * @param factor Unsigned + * @return Aeu& + * @details Works with the greatest performance with types smaller than uint64_t + */ + template requires (std::is_unsigned_v) + gpu constexpr auto operator*=(Unsigned factor) noexcept -> Aeu& { + if constexpr (std::is_same_v) { + const auto longerLength = filledBlocksNumber(), smallerLength = (factor > blockMax ? 2UL : 1UL); + blockLine buffer {}; + + for(std::size_t i = 0; i < longerLength; ++i) { + uint64_t tBlock = blocks[i], carryOut = 0; + + for(std::size_t j = 0; j < smallerLength && i + j < buffer.size(); ++j) { + const auto product = tBlock * ((factor >> blockBitLength * j) & 0x00'00'00'00'ff'ff'ff'ff) + carryOut; + const auto block = static_cast(buffer[i + j]) + (product % blockBase); + carryOut = product / blockBase + block / blockBase; + buffer[i + j] = block % blockBase; + } + + if(smallerLength + i < buffer.size()) + buffer[smallerLength + i] += carryOut; + } + + blocks = buffer; + return *this; + } else { + uint64_t carryOut = 0; + for (std::size_t i = 0; i < blocksNumber; ++i) { + const auto product = static_cast(factor) * static_cast(blocks[i]) + carryOut; + blocks[i] = product % blockBase; carryOut = product / blockBase; + } + return *this; + } + }; + + /** + * @brief Assignment multiplication operator + * @param factor Aeu + * @return Aeu& + */ + gpu constexpr auto operator*=(const Aeu& factor) noexcept -> Aeu& { + constexpr auto multiplyLines = [] (const blockLine& longerLine, const std::size_t longerLength, + const blockLine& smallerLine, const std::size_t smallerLength) { + blockLine buffer {}; + + for(std::size_t i = 0; i < longerLength; ++i) { + uint64_t tBlock = longerLine[i], carryOut = 0; + + for(std::size_t j = 0; j < smallerLength && i + j < buffer.size(); ++j) { + const auto product = tBlock * static_cast(smallerLine[j]) + carryOut; + const auto block = static_cast(buffer[i + j]) + (product % blockBase); + carryOut = product / blockBase + block / blockBase; + buffer[i + j] = block % blockBase; + } + + if(smallerLength < blocksNumber && smallerLength + i < buffer.size()) + buffer[smallerLength + i] += carryOut; + } + + return buffer; + }; + + const std::size_t thisLength = this->filledBlocksNumber(), valueLength = factor.filledBlocksNumber(); + if(thisLength > valueLength) + blocks = multiplyLines(blocks, thisLength, factor.blocks, valueLength); + else + blocks = multiplyLines(factor.blocks, valueLength, blocks, thisLength); + + return *this; + } + /* --------------------------------------------------------------------------- */ + + + /* ------------------------ @name Division operators. ------------------------ */ + /** + * @brief Division operator + * @param divisor Aeu + * @return Aeu + * @note Undefined behaviour for division by zero + */ + [[nodiscard]] + gpu constexpr auto operator/(const Aeu& divisor) const noexcept -> Aeu { + Aeu quotient, _; divide(*this, divisor, quotient, _); return quotient; + } + + /** + * @brief Assignment division operator + * @param divisor Aeu + * @return Aeu& + * @note Undefined behaviour for division by zero + */ + gpu constexpr auto operator/=(const Aeu& divisor) noexcept -> Aeu& { + return this->operator=(this->operator/(divisor)); + } + /* --------------------------------------------------------------------------- */ + + + /* ------------------------- @name Modulo operators. ------------------------- */ + /** + * @brief Modulo operator + * @param modulo Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator%(const Aeu& modulo) const noexcept -> Aeu { + Aeu _, remainder; divide(*this, modulo, _, remainder); return remainder; + } + + /** + * @brief Assignment modulo operator + * @param modulo Aeu + * @return Aeu& + */ + gpu constexpr auto operator%=(const Aeu& modulo) noexcept -> Aeu& { + return this->operator=(this->operator%(modulo)); + } + /* --------------------------------------------------------------------------- */ + /* ----------------------------------------------------------------------- */ + + + /* ----------------------- @name Bitwise operators. ---------------------- */ + /** + * @brief Bitwise complement operator + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator~() const noexcept -> Aeu { + Aeu result; + for(std::size_t i = 0; i < blocksNumber; ++i) + result.blocks[i] = ~blocks[i]; + return result; + } + + /** + * @brief Bitwise XOR operator + * @param other Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator^(const Aeu& other) const noexcept -> Aeu { + Aeu result = *this; result ^= other; return result; + } + + /** + * @brief Assignment bitwise XOR operator + * @param other Aeu + * @return Aeu& + */ + gpu constexpr auto operator^=(const Aeu& other) noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) + blocks[i] ^= other.blocks[i]; + return *this; + } + + /** + * @brief Bitwise AND operator + * @param other Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator&(const Aeu& other) const noexcept -> Aeu { + Aeu result = *this; result &= other; return result; + } + + /** + * @brief Assignment bitwise AND operator + * @param other Aeu + * @return Aeu& + */ + gpu constexpr auto operator&=(const Aeu& other) noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) + blocks[i] &= other.blocks[i]; + return *this; + } + + /** + * @brief Bitwise OR operator + * @param other Aeu + * @return Aeu + */ + [[nodiscard]] + gpu constexpr auto operator|(const Aeu& other) const noexcept -> Aeu { + Aeu result = *this; result |= other; return result; + } + + /** + * @brief Assignment bitwise OR operator + * @param other Aeu + * @return Aeu& + */ + gpu constexpr auto operator|=(const Aeu& other) noexcept -> Aeu& { + for(std::size_t i = 0; i < blocksNumber; ++i) + blocks[i] |= other.blocks[i]; + return *this; + } + + /** + * @brief Left shift operator + * @param bitShift Unsigned + * @return Aeu + * @note Does nothing for shift greater than precision + */ + template requires (std::is_integral_v && std::is_unsigned_v) [[nodiscard]] + gpu constexpr auto operator<<(Unsigned bitShift) const noexcept -> Aeu { + Aeu result = *this; result.operator<<=(bitShift); return result; + } + + /** + * @brief Left shift assignment operator + * @param bitShift Unsigned + * @return Aeu& + * @note Does nothing for shift greater than precision + */ + template requires (std::is_integral_v && std::is_unsigned_v) + gpu constexpr auto operator<<=(Unsigned bitShift) noexcept -> Aeu& { + if(bitShift >= bitness || bitShift == 0) return *this; + + const std::size_t quotient = bitShift / blockBitLength, remainder = bitShift % blockBitLength; + const block stamp = (1UL << (blockBitLength - remainder)) - 1; + + for (long long i = blocksNumber - 1; i >= (quotient + (remainder ? 1 : 0)); --i) + blocks[i] = ((blocks[i - quotient] & stamp) << remainder) | ((blocks[i - quotient - (remainder ? 1 : 0)] & ~stamp) >> ((blockBitLength - remainder) % blockBitLength)); + + blocks[quotient] = (blocks[0] & stamp) << remainder; + + for (std::size_t i = 0; i < quotient; ++i) + blocks[i] = 0; + return *this; + } + + /** + * @brief Right shift operator + * @param bitShift Unsigned + * @return Aeu + * @note Does nothing for shift greater than precision + */ + template requires (std::is_integral_v && std::is_unsigned_v) [[nodiscard]] + gpu constexpr auto operator>>(Unsigned bitShift) const noexcept -> Aeu { + Aeu result = *this; result >>= bitShift; return result; + } + + /** + * @brief Right shift assignment operator + * @param bitShift Unsigned + * @return Aeu& + * @note Does nothing for shift greater than precision + */ + template requires (std::is_integral_v && std::is_unsigned_v) + gpu constexpr auto operator>>=(Unsigned bitShift) noexcept -> Aeu& { + if(bitShift >= bitness || bitShift == 0) return *this; + + const std::size_t quotient = bitShift / blockBitLength, remainder = bitShift % blockBitLength; + const block stamp = (1UL << remainder) - 1; + + for(std::size_t i = 0; i < blocksNumber - (quotient + (remainder ? 1 : 0)); ++i) + blocks[i] = ((blocks[i + quotient + (remainder ? 1 : 0)] & stamp) << ((blockBitLength - remainder) % blockBitLength)) | ((blocks[i + quotient] & ~stamp) >> remainder); + + blocks[blocksNumber - 1 - quotient] = (blocks[blocksNumber - 1] & ~stamp) >> remainder; + + for(long long i = blocksNumber - quotient; i < blocksNumber; ++i) + blocks[i] = 0; + return *this; + } + /* ----------------------------------------------------------------------- */ + + + /* --------------------- @name Comparison operators. --------------------- */ + /* ------------------------ @name Equality operators. ------------------------ */ + /** + * @brief Equality check operator for built-in types uint8_t, uint16_t, uint32_t + * @param other Unsigned + * @return Boolean + */ + template requires (std::is_unsigned_v && sizeof(Unsigned) < 8) + gpu constexpr auto operator==(Unsigned other) const noexcept -> bool { + return filledBlocksNumber() <= 1 && static_cast(other) == blocks[0]; + } + gpu constexpr auto operator==(uint64_t other) const noexcept -> bool { + return filledBlocksNumber() <= 2 && ((static_cast(blocks[1]) << blockBitLength) | static_cast(blocks[0])) == other; + } + + /** + * @brief Equality check operator for numbers of the same precision + * @param other Aeu + * @return Boolean + */ + gpu constexpr auto operator==(const Aeu& other) const noexcept -> bool { return blocks == other.blocks; }; + + /** + * @brief Templated Equality check operator for numbers of different precision + * @param other Aeu + * @return Boolean + */ + template requires (otherBitness != bitness) + gpu constexpr auto operator==(const Aeu& other) const noexcept -> bool { return compareTo(other) == Comparison::equal; }; + /* --------------------------------------------------------------------------- */ + + + /* ----------------------- @name Comparison operators. ----------------------- */ + /** + * @brief Internal comparison operator for built-in integral types uint8_t, uint16_t, uint32_t + * @param other Unsigned + * @return Comparison + * @note Should almost never return Comparison::Equivalent + */ + template requires (std::is_unsigned_v && sizeof(Unsigned) < 8) [[nodiscard]] + gpu constexpr auto compareTo(Unsigned other) const noexcept -> Comparison { + if(filledBlocksNumber() > 1) return Comparison::greater; + const auto cmp = static_cast(other); + if(blocks[0] > cmp) + return Comparison::greater; + else if(blocks[0] < cmp) + return Comparison::less; else return Comparison::equal; + } + + /** + * @brief Internal comparison operator for type uint64_t + * @param other uint64_t + * @return Comparison + * @note Should almost never return Comparison::Equivalent + */ + [[nodiscard]] + gpu constexpr auto compareTo(uint64_t other) const noexcept -> Comparison { + if(filledBlocksNumber() > 2) return Comparison::greater; + const auto base = (static_cast(blocks[1]) << blockBitLength) | static_cast(blocks[0]); + if(base > other) + return Comparison::greater; else if(base < other) return Comparison::less; else return Comparison::equal; + } + + /** + * @brief Internal comparison operator + * @param other Aeu + * @return Comparison + * @note Should almost never return Comparison::Equivalent + */ + template /*requires (otherBitness != bitness)*/ [[nodiscard]] + gpu constexpr auto compareTo(const Aeu& other) const noexcept -> Comparison { + /* First compare in common precision. */ + const auto lowerBlockBorder = (blocksNumber < other.totalBlocksNumber() ? blocksNumber : other.totalBlocksNumber()); + for(long long i = lowerBlockBorder - 1; i >= 0; --i) { + const block thisBlock = blocks[i], otherBlock = other.getBlock(i); + if(thisBlock != otherBlock) + return (thisBlock > otherBlock ? Comparison::greater : Comparison::less); + } + + if constexpr (otherBitness != blocksNumber * blockBitLength) { + /* If larger number contains data out of lower number's range, it's greater. */ + if (other.totalBlocksNumber() > blocksNumber) { + for (long long i = other.totalBlocksNumber() - 1; i > lowerBlockBorder - 1; --i) + if (other.getBlock(i) != 0) + return Comparison::less; + } else if (blocksNumber > other.totalBlocksNumber()) { + for (long long i = blocksNumber - 1; i > lowerBlockBorder - 1; --i) + if (blocks[i] != 0) + return Comparison::greater; + } + } + + return Comparison::equal; + } + /* --------------------------------------------------------------------------- */ + + + /* ------------------------ @name Spaceship operators. ----------------------- */ +#if (defined(__CUDACC__) || __cplusplus < 202002L || defined (PRE_CPP_20)) && !defined DOXYGEN_SKIP + /** + * @brief Oldstyle comparison operator(s). Used inside CUDA cause it does not support <=> on preCpp20 + */ + gpu constexpr auto operator!=(const Aeu& value) const noexcept -> bool { return !this->operator==(value); } + gpu constexpr auto operator<(const Aeu& value) const noexcept -> bool { return this->compareTo(value) == Comparison::less; } + gpu constexpr auto operator<=(const Aeu& value) const noexcept -> bool { return !this->operator>(value); } + gpu constexpr auto operator>(const Aeu& value) const noexcept -> bool { return this->compareTo(value) == Comparison::greater; } + gpu constexpr auto operator>=(const Aeu& value) const noexcept -> bool { return !this->operator<(value); } +#else + /** + * @brief Three-way comparison operator + * @param other Aeu + * @return Std::Strong_ordering + * @note Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent + */ + gpu constexpr auto operator<=>(const Aeu& other) const noexcept -> std::strong_ordering { + const auto ratio = this->compareTo(other); + switch(ratio) { + case Comparison::less: + return std::strong_ordering::less; + case Comparison::greater: + return std::strong_ordering::greater; + case Comparison::equal: + return std::strong_ordering::equal; + default: + return std::strong_ordering::equivalent; + } + }; + + /** + * @brief Three-way comparison operator for numbers of different precision and built-in integral types + * @param other Integral + * @return Std::Strong_ordering + * @note Available from C++20 standard and further. Should almost never return Strong_ordering::Equivalent + */ + template + gpu constexpr auto operator<=>(const Unsigned& other) const noexcept -> std::strong_ordering { + const auto ratio = this->compareTo(other); + switch(ratio) { + case Comparison::less: + return std::strong_ordering::less; + case Comparison::greater: + return std::strong_ordering::greater; + case Comparison::equal: + return std::strong_ordering::equal; + default: + return std::strong_ordering::equivalent; + } + }; +#endif + /* --------------------------------------------------------------------------- */ + /* ----------------------------------------------------------------------- */ + + + /* ---------------------- @name Supporting methods. ---------------------- */ + /** + * @brief Set bit in number by index starting from the right + * @param index Size_t + * @param bit Boolean + * @note Does nothing for index out of range + */ + gpu constexpr auto setBit(std::size_t index, bool bit) noexcept -> void { +#ifndef AESI_UNSAFE + if(index >= bitness) return; +#endif + const std::size_t blockNumber = index / blockBitLength, bitNumber = index % blockBitLength; + assert(blockNumber < blocksNumber && bitNumber < blockBitLength); + if(bit) + blocks[blockNumber] |= (1U << bitNumber); + else + blocks[blockNumber] &= (~(1U << bitNumber)); + } + + /** + * @brief Get bit in number by index staring from the right + * @param index Size_t + * @return Boolean + * @note Returns zero for index out of range + */ + [[nodiscard]] + gpu constexpr auto getBit(std::size_t index) const noexcept -> bool { +#ifndef AESI_UNSAFE + if(index >= bitness) return false; +#endif + const std::size_t blockNumber = index / blockBitLength, bitNumber = index % blockBitLength; + assert(blockNumber < blocksNumber && bitNumber < blockBitLength); + return blocks[blockNumber] & (1U << bitNumber); + } + + /** + * @brief Set byte in number by index starting from the right + * @param index Size_t + * @param byte Byte + * @note Does nothing for index out of range + */ + gpu constexpr auto setByte(std::size_t index, byte byte) noexcept -> void { +#ifndef AESI_UNSAFE + if(index > blocksNumber * sizeof(block)) return; +#endif + const std::size_t blockNumber = index / sizeof(block), byteInBlock = index % sizeof(block), shift = byteInBlock * bitsInByte; + assert(blockNumber < blocksNumber && byteInBlock < sizeof(block)); + blocks[blockNumber] &= ~(0xffU << shift); blocks[blockNumber] |= static_cast(byte) << shift; + } + + /** + * @brief Get byte in number by index starting from the right + * @param index Size_t + * @return Byte + * @note Returns zero for index out of range + */ + [[nodiscard]] + gpu constexpr auto getByte(std::size_t index) const noexcept -> byte { +#ifndef AESI_UNSAFE + if(index > blocksNumber * sizeof(block)) return 0; +#endif + const std::size_t blockNumber = index / sizeof(block), byteInBlock = index % sizeof(block), shift = byteInBlock * bitsInByte; + assert(blockNumber < blocksNumber && byteInBlock < sizeof(block)); + return (blocks[blockNumber] & (0xffU << shift)) >> shift; + } + + /** + * @brief Set block in number by index starting from the right + * @param index Size_t + * @param block Block + * @note Does nothing for index out of range. Index check is disabled in unsafe mode. + */ + gpu constexpr auto setBlock(std::size_t index, block block) noexcept -> void { +#ifndef AESI_UNSAFE + if(index >= blocksNumber) return; +#endif + blocks[index] = block; + } + + /** + * @brief Get block in number by index starting from the right + * @param index Size_t + * @return Block + * @note Returns zero for index out of range. Index check is disabled in unsafe mode. + */ + [[nodiscard]] + gpu constexpr auto getBlock(std::size_t index) const noexcept -> block { +#ifndef AESI_UNSAFE + if(index >= blocksNumber) return block(); +#endif + return blocks[index]; + } + + /** + * @brief Get amount of non-empty bytes in number right to left + * @return Size_t + */ + [[nodiscard]] + gpu constexpr auto byteCount() const noexcept -> std::size_t { + std::size_t lastBlock = blocksNumber - 1; + for(; lastBlock > 0 && blocks[lastBlock] == 0; --lastBlock) ; + + for(int8_t byteN = sizeof(block) - 1; byteN >= 0; --byteN) { + const auto byte = (blocks[lastBlock] & (0xffU << (byteN * bitsInByte))) >> (byteN * bitsInByte); + if(byte) + return lastBlock * sizeof(block) + byteN + 1; + } + return lastBlock * sizeof(block); + } + + /** + * @brief Get amount of non-empty bits in number right to left + * @return Size_t + */ + [[nodiscard]] + gpu constexpr auto bitCount() const noexcept -> std::size_t { + std::size_t lastBlock = blocksNumber - 1; + for(; lastBlock > 0 && blocks[lastBlock] == 0; --lastBlock); + + for(int8_t byteN = sizeof(block) - 1; byteN >= 0; --byteN) { + const auto byte = (blocks[lastBlock] & (0xffU << (byteN * bitsInByte))) >> (byteN * bitsInByte); + if(!byte) continue; + + for(int8_t bitN = bitsInByte - 1; bitN >= 0; --bitN) { + const auto bit = (byte & (0x1u << bitN)) >> bitN; + if(bit) + return (lastBlock * sizeof(block) + byteN) * bitsInByte + bitN + 1; + } + return ((lastBlock - 1) * sizeof(block) + byteN) * bitsInByte; + } + return lastBlock * sizeof(block); + } + + /** + * @brief Check whether number is odd + * @return Boolean: true is number is odd and false otherwise + */ + [[nodiscard]] + gpu constexpr auto isOdd() const noexcept -> bool { return (0x1 & blocks[0]) == 1; } + + /** + * @brief Check whether number is even + * @return Boolean: true if the number is even and false otherwise + */ + [[nodiscard]] + gpu constexpr auto isEven() const noexcept -> bool { return (0x1 & blocks[0]) == 0; } + + /** + * @brief Check whether number is zero + * @return Boolean: true if the number is zero and false otherwise + */ + [[nodiscard]] + gpu constexpr auto isZero() const noexcept -> bool { return filledBlocksNumber() == 0; } + + /** + * @brief Get number of non-empty blocks inside object starting from the right + * @return Size_t + */ + [[nodiscard]] + gpu constexpr auto filledBlocksNumber() const noexcept -> std::size_t { + for(long long i = blocksNumber - 1; i >= 0; --i) + if(blocks[i]) return i + 1; + return 0; + } + + /** + * @brief Get number's precision + * @return Size_t + */ + [[nodiscard]] + gpu static constexpr auto getBitness() noexcept -> std::size_t { return bitness; } + + /** + * @brief Get the number of blocks (length of array of uint32_t integers) inside object + * @return Size_t + */ + [[nodiscard]] + gpu static constexpr auto totalBlocksNumber() noexcept -> std::size_t { return blocksNumber; } + + /** + * @brief Make swap between two objects + * @param other Aeu + */ + gpu constexpr auto swap(Aeu& other) noexcept -> void { + Aeu t = other; other.operator=(*this); this->operator=(t); + } + /* ----------------------------------------------------------------------- */ + + + /* -------------- @name Public arithmetic and number theory. ------------- */ + /** + * @brief Integer division. Returns results by reference + * @param number Aeu + * @param divisor Aeu + * @param quotient Aeu OUT + * @param remainder Aeu OUT + * @return Quotient and remainder by reference + */ + gpu static constexpr auto divide(const Aeu& number, const Aeu& divisor, Aeu& quotient, Aeu& remainder) noexcept -> void { + const auto ratio = number.compareTo(divisor); + + quotient = Aeu {}; remainder = Aeu {}; + + if(ratio == Comparison::greater) { + const auto bitsUsed = number.filledBlocksNumber() * blockBitLength; + for(long long i = bitsUsed - 1; i >= 0; --i) { + remainder <<= 1u; + remainder.setBit(0, number.getBit(i)); + + if(remainder >= divisor) { + remainder -= divisor; + quotient.setBit(i, true); + } + } + } else if(ratio == Comparison::less) + remainder = number; else quotient = 1u; + } + + /** + * @brief Integer division. Returns results by value + * @param number Aeu + * @param divisor Aeu + * @return Pair(Quotient, Remainder) + */ + [[nodiscard]] + gpu static constexpr auto divide(const Aeu& number, const Aeu& divisor) noexcept -> pair { + pair results; divide(number, divisor, results.first, results.second); return results; + } + + /** + * @brief Extended Euclidean algorithm for greatest common divisor + * @param first Aeu + * @param second Aeu + * @param bezoutX Aeu OUT + * @param bezoutY Aeu OUT + * @return Aeu + * @details Counts Bézout coefficients along with the greatest common divisor. Returns coefficients by reference + */ + gpu static constexpr auto gcd(const Aeu& first, const Aeu& second, Aeu& bezoutX, Aeu& bezoutY) noexcept -> Aeu { + Aeu gcd, tGcd, quotient, remainder; + + const auto ratio = first.compareTo(second); + if(ratio == Comparison::greater) { + gcd = second; + divide(first, second, quotient, remainder); + } else { + gcd = first; + divide(second, first, quotient, remainder); + } + + bezoutX = 0u; bezoutY = 1u; + for(Aeu tX = 1u, tY = 0u; remainder != 0u; ) { + tGcd = gcd; gcd = remainder; + + Aeu t = bezoutX; bezoutX = tX - quotient * bezoutX; tX = t; + t = bezoutY; bezoutY = tY - quotient * bezoutY; tY = t; + + divide(tGcd, gcd, quotient, remainder); + } + + if(ratio != Comparison::greater) + bezoutX.swap(bezoutY); + + return gcd; + } + + /** + * @brief Greatest common divisor + * @param first Aeu + * @param second Aeu + * @return Aeu + * @details Faster version, ignoring bezout coefficients + */ + gpu static constexpr auto gcd(const Aeu& first, const Aeu& second) noexcept -> Aeu { + Aeu gcd, tGcd, quotient, remainder; + + const auto ratio = first.compareTo(second); + if(ratio == Comparison::greater) { + gcd = second; + divide(first, second, quotient, remainder); + } else { + gcd = first; + divide(second, first, quotient, remainder); + } + + for(Aeu tX = 1u, tY = 0u; remainder != 0u; ) { + tGcd = gcd; gcd = remainder; + divide(tGcd, gcd, quotient, remainder); + } + + return gcd; + } + + /** + * @brief Least common multiplier + * @param first Aeu + * @param second Aeu + * @return Aeu + */ + [[nodiscard]] + gpu static constexpr auto lcm(const Aeu& first, const Aeu& second) noexcept -> Aeu { return first / gcd(first, second) * second; } + + /** + * @brief Exponentiation by modulo + * @param base Aeu + * @param power Aeu + * @param modulo Aeu + * @return Aeu + * @note Be aware of overflow + * @details Accepts power of different precision rather than base and modulo + */ + template [[nodiscard]] + gpu static constexpr auto powm(const Aeu& base, const Aeu& power, const Aeu& modulo) noexcept -> Aeu { + if(base == 1u) + return base; + if(base == 0u) + return { 1u }; + + Aeu output = 1u; + auto [_, b] = divide(base, modulo); + + for(unsigned iteration = 0; power.filledBlocksNumber() * blockBitLength != iteration; iteration++) { + if(power.getBit(iteration)) { + const auto [quotient, remainder] = divide(output * b, modulo); + output = remainder; + } + + const auto [quotient, remainder] = divide(b * b, modulo); + b = remainder; + } + + return output; + } + + [[nodiscard]] + gpu static constexpr auto powm(const Aeu& base, const Aeu& power, const Aeu& mod) noexcept -> Aeu { + Aeu output = 1u; + auto [_, b] = divide(base, mod); + + for(std::size_t iteration = 0; power.filledBlocksNumber() * blockBitLength != iteration; iteration++) { + if(power.getBit(iteration)) { + const auto [quotient, remainder] = divide(output * b, mod); + output = remainder; + } + + const auto [quotient, remainder] = divide(b * b, mod); + b = remainder; + } + + return output; + } + + /** + * @brief Fast exponentiation for powers of 2 + * @param power Size_t + * @return Aeu + * @details Returns zero for power greater than current bitness + */ + [[nodiscard]] + gpu static constexpr auto power2(std::size_t power) noexcept -> Aeu { Aeu result {}; result.setBit(power, true); return result; } + + /** + * @brief Get square root + * @return Aeu + * @note Returns zero for negative value or zero + */ + [[nodiscard]] + gpu constexpr auto squareRoot() const noexcept -> Aeu { + Aeu x, y = power2((bitCount() + 1) / 2); + + do { + x = y; + y = (x + this->operator/(x)) >> 1u; + } while (y < x); + + return x; + } + /* ----------------------------------------------------------------------- */ + + + /* ----------------- @name Public input-output operators. ---------------- */ + /** + * @brief Character buffer output operator + * @param buffer Char* + * @param bufferSize Size_t + * @param showBase Boolean + * @param hexUppercase Boolean + * @return Size_t - amount of symbols written + * @details Places the maximum possible amount of number's characters in buffer. Base parameter should be 2, 8, 10, or 16 + * @note Works significantly faster for hexadecimal notation + */ + template requires (std::is_same_v || std::is_same_v && (base == 2 || base == 8 || base == 10 || base == 16)) + gpu constexpr auto getString(Char* const buffer, std::size_t bufferSize, bool showBase = false, bool hexUppercase = false) const noexcept -> std::size_t { + if(bufferSize < 2) return 0; + + std::size_t position = 0; + + if (showBase && bufferSize > 3) { + if constexpr (base == 2) { + if constexpr (std::is_same_v) { + memcpy(buffer, "0b", 2 * sizeof(Char)); + } else { + memcpy(buffer, L"0b", 2 * sizeof(Char)); + } + position += 2; + } else if constexpr (base == 8) { + if constexpr (std::is_same_v) { + memcpy(buffer, "0o", 2 * sizeof(Char)); + } else { + memcpy(buffer, L"0o", 2 * sizeof(Char)); + } + position += 2; + } else if constexpr (base == 16) { + if constexpr (std::is_same_v) { + memcpy(buffer, "0x", 2 * sizeof(Char)); + } else { + memcpy(buffer, L"0x", 2 * sizeof(Char)); + } + position += 2; + } + } + + if(isZero()) { + buffer[position++] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; }}(); + return position; + } + + if constexpr (base == 16) { + long long iter = blocks.size() - 1; + for (; blocks[iter] == 0 && iter >= 0; --iter); + + if constexpr (std::is_same_v) { + position += snprintf(buffer + position, bufferSize - position, (hexUppercase ? "%X" : "%x"), blocks[iter--]); + for (; iter >= 0; --iter) + position += snprintf(buffer + position, bufferSize - position, (hexUppercase ? "%08X" : "%08x"), blocks[iter]); + } else { + position += swprintf(buffer + position, bufferSize - position, (hexUppercase ? L"%X" : L"%x"), blocks[iter--]); + for (; iter >= 0; --iter) + position += swprintf(buffer + position, bufferSize - position, (hexUppercase ? L"%08X" : L"%08x"), blocks[iter]); + } + } else { + const auto startPosition = position; + + Aeu copy = *this; + while (!copy.isZero() && position < bufferSize) { + auto [quotient, remainder] = divide(copy, base); + if constexpr (std::is_same_v) { + buffer[position++] = '0' + remainder.template integralCast(); + } else { + buffer[position++] = L'0' + remainder.template integralCast(); + } + copy = quotient; + } + const auto digitsTotal = position - startPosition; + for (std::size_t i = 0; i * 2 < digitsTotal; ++i) { + Char t = buffer[startPosition + i]; + buffer[startPosition + i] = buffer[startPosition + digitsTotal - 1 - i]; + buffer[startPosition + digitsTotal - 1 - i] = t; + } + } + buffer[position++] = Char {}; + return position; + } + + /** + * @brief STD stream output operator + * @param os Ostream + * @param number Aeu + * @return Ostream + * @details Writes number in stream. Accepts STD streams based on char or wchar_t. Supports stream manipulators: + * - Number's notation (std::hex, std::dec, std::oct); + * - Number's base (std::showbase); + * - Hexadecimal letters case (std::uppercase, std::lowercase) + * @note Works significantly faster for hexadecimal notation + */ + template requires (std::is_same_v || std::is_same_v) + friend constexpr auto operator<<(std::basic_ostream& os, const Aeu& number) -> std::basic_ostream& { + auto flags = os.flags(); + + const auto base = [] (long baseField, std::basic_ostream& ss, bool showbase) { + auto base = (baseField == std::ios::hex ? 16u : (baseField == std::ios::oct ? 8u : 10u)); + if(showbase && base != 10) + ss << [&base] { if constexpr (std::is_same_v) { return base == 8 ? "0o" : "0x"; } else { return base == 8 ? L"0o" : L"0x"; }} () << std::noshowbase ; + return base; + } (flags & std::ios::basefield, os, flags & std::ios::showbase); + + if(number.isZero()) + return os << '0'; + + if(base == 16) { + long long iter = number.blocks.size() - 1; + for(; number.blocks[iter] == 0 && iter >= 0; --iter) ; + + os << number.blocks[iter--]; + for (; iter >= 0; --iter) { + os.fill([] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } ()); + os.width(8); os << std::right << number.blocks[iter]; + } + } else { + /* Well, here we use a pre-calculated magic number to ratio the length of numbers in decimal or octal notation according to bitness. + * * It is 2.95-98 for octal and 3.2 for decimal. */ + constexpr auto bufferSize = static_cast(static_cast(bitness) / 2.95); + Char buffer [bufferSize] {}; std::size_t filled = 0; + + Aeu copy = number; + while(!copy.isZero() && filled < bufferSize) { + const auto [quotient, remainder] = divide(copy, base); + buffer[filled++] = [] { if constexpr (std::is_same_v) { return '0'; } else { return L'0'; } } () + remainder.template integralCast(); + copy = quotient; + } + + for(; filled > 0; --filled) + os << buffer[filled - 1]; + } + + return os; + } + + + /** + * @brief STD stream binary reading operator + * @param is Istream + * @param bigEndian Boolean + * @return Aeu + * @details Reads number from stream using .read method. Accepts STD streams based on char or wchar_t. + * @note Fills empty bits with 0s on EOF of the stream + */ + template requires (std::is_same_v || std::is_same_v) + constexpr auto readBinary(std::basic_istream& is, bool bigEndian = true) -> void { + blocks = {}; + if(bigEndian) { + for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) + if(!is.read(reinterpret_cast(&*it), sizeof(block))) break; + } else { + for(auto& tBlock: blocks) + if(!is.read(reinterpret_cast(&tBlock), sizeof(block))) break; + } + } + + + /** + * @brief STD stream binary writing operator + * @param os Ostream + * @param bigEndian Boolean + * @details Writes number in stream using .write method. Accepts STD streams based on char or wchar_t. + */ + template requires (std::is_same_v || std::is_same_v) + constexpr auto writeBinary(std::basic_ostream& os, bool bigEndian = true) const noexcept -> void { + if(bigEndian) { + for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) + if(!os.write(reinterpret_cast(&*it), sizeof(block))) break; + } else { + for(auto& block: blocks) + if(!os.write(reinterpret_cast(&block), sizeof(block))) break; + } + } + /* ----------------------------------------------------------------------- */ + + + /* -------------------- @name Public casting operators. ------------------ */ + /** + * @brief Integral type cast operator for built-in types + * @return Integral + * @details Takes the lowest part of Aeu for conversion. Accepts signed and unsigned types + */ + template requires (std::is_integral_v) [[nodiscard]] + gpu constexpr auto integralCast() const noexcept -> Integral { + const uint64_t value = (static_cast(blocks[1]) << blockBitLength) | static_cast(blocks[0]); + return static_cast(value); + } + + /** + * @brief Precision cast operator + * @return Aeu + * @details If required precision greater than current precision, remaining blocks are filled with zeros. + * Otherwise - number is cropped inside smaller blocks array + * @note Using this method directly is not recommended, + * cause it leads to redundant copying and may be slow + */ + template requires (newBitness != bitness) [[nodiscard]] + gpu constexpr auto precisionCast() const noexcept -> Aeu { + Aeu result {}; + + const std::size_t blockBoarder = (newBitness > bitness ? Aeu::totalBlocksNumber() : Aeu::totalBlocksNumber()); + for(std::size_t blockIdx = 0; blockIdx < blockBoarder; ++blockIdx) + result.setBlock(blockIdx, getBlock(blockIdx)); + + return result; + } + /* ----------------------------------------------------------------------- */ + + +#if defined __CUDACC__ + /* ------------------- @name Atomic-like CUDA operators. ----------------- */ + /** + * @brief Atomicity-oriented object assignment operator + * @param assigning Aeu + * @note Method itself is not atomic. There may be race conditions between two consecutive atomic calls on number blocks. + * This method is an interface for assigning encapsulated class members atomically one by one + */ + __device__ constexpr auto tryAtomicSet(const Aeu& value) noexcept -> void { + for(std::size_t i = 0; i < blocksNumber; ++i) + atomicExch(&blocks[i], value.blocks[i]); + } + + /** + * @brief Atomicity-oriented object exchangement operator + * @param exchangeable Aeu + * @note Method itself is not atomic. There may be race conditions between two consecutive atomic calls on number blocks. + * This method is an interface for exchanging encapsulated class members atomically one by one + */ + __device__ constexpr auto tryAtomicExchange(const Aeu& value) noexcept -> void { + for(std::size_t i = 0; i < blocksNumber; ++i) + atomicExch(&value.blocks[i], atomicExch(&blocks[i], value.blocks[i])); + } + /* ----------------------------------------------------------------------- */ +#endif +}; + +/* -------------------------------------------- @name Type-definitions ------------------------------------------- */ +/** + * @typedef Aeu128 + * @brief Number with precision 128-bit. */ +using Aeu128 = Aeu<128>; + +/** + * @typedef Aeu256 + * @brief Number with precision 128-bit. */ +using Aeu256 = Aeu<256>; + +/** + * @typedef Aeu512 + * @brief Number with precision 512-bit. */ +using Aeu512 = Aeu<512>; + +/** + * @typedef Aeu768 + * @brief Number with precision 768-bit. */ +using Aeu768 = Aeu<768>; + +/** + * @typedef Aeu1024 + * @brief Number with precision 1024-bit. */ +using Aeu1024 = Aeu<1024>; + +/** + * @typedef Aeu1536 + * @brief Number with precision 1536-bit. */ +using Aeu1536 = Aeu<1536>; + +/** + * @typedef Aeu2048 + * @brief Number with precision 2048-bit. */ +using Aeu2048 = Aeu<2048>; + +/** + * @typedef Aeu3072 + * @brief Number with precision 3072-bit. */ +using Aeu3072 = Aeu<3072>; + +/** + * @typedef Aeu4096 + * @brief Number with precision 4096-bit. */ +using Aeu4096 = Aeu<4096>; + +/** + * @typedef Aeu6144 + * @brief Number with precision 6144-bit. */ +using Aeu6144 = Aeu<6144>; + +/** + * @typedef Aeu8192 + * @brief Number with precision 8192-bit. */ +using Aeu8192 = Aeu<8192>; +/* ---------------------------------------------------------------------------------------------------------------- */ + +/* ------------------------------------------ @name Integral conversions ----------------------------------------- */ +/** + * @brief Integral conversion addition operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator+(Integral number, const Aeu& value) noexcept { return Aeu(number) + value; } + +/** + * @brief Integral conversion subtraction operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator-(Integral number, const Aeu& value) noexcept { return Aeu(number) - value; } + +/** + * @brief Integral conversion multiplication operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator*(Integral number, const Aeu& value) noexcept { return Aeu(number) * value; } + +/** + * @brief Integral conversion division operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator/(Integral number, const Aeu& value) noexcept { return Aeu(number) / value; } + +/** + * @brief Integral conversion modulo operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator%(Integral number, const Aeu& value) noexcept { return Aeu(number) % value; } + +/** + * @brief Integral conversion bitwise XOR operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator^(Integral number, const Aeu& value) noexcept { return Aeu(number) ^ value; } + +/** + * @brief Integral conversion bitwise AND operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator&(Integral number, const Aeu& value) noexcept { return Aeu(number) & value; } + +/** + * @brief Integral conversion bitwise OR operator + * @param number Integral + * @param value Aeu + * @return Aeu + */ +template requires (std::is_integral_v) +gpu constexpr auto operator|(Integral number, const Aeu& value) noexcept { return Aeu(number) | value; } +/* ---------------------------------------------------------------------------------------------------------------- */ + +#endif //AEU_MULTIPRECISION diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Doxyfile b/Doxyfile old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index f1de30f..2dbf152 --- a/README.md +++ b/README.md @@ -18,18 +18,32 @@ Aesi Multiprecision The goal of this project is to develop a fast and handy multi-precision library that can be used with GPU parallelization frameworks such as CUDA, OpenCL, and Metal. The library should correspond to modern C++ standards, support constexpr expressions, and move semantics. -## Project status -__Project is currently in the testing and development stage to support the *Cuda* framework. Please be aware that errors and problems may occur.__ OpenCL support is next in line for development. Metal support is scheduled after some time, due to the presence of significant differences in the framework from Cuda and OpenCL. +> [!IMPORTANT] +> Project is currently in the testing and development stage to support the *Cuda* framework. Please be aware that errors and problems may occur.__ OpenCL support is next in line for development. Metal support is scheduled after some time, due to the presence of significant differences in the framework from Cuda and OpenCL. +> ## Functionality Library supports each arithmetic (binary and unary), bitwise, and boolean operations. Various functions from number theory are being added to the library, among which the greatest common divisor, the least common multiplier, and exponentiation by modulo have already been implemented. +## Installation: +Package could be downloaded to project's directory, or accessed directly through CMake: +```include(FetchContent) +FetchContent_Declare(AesiMultiprecision + GIT_REPOSITORY https://github.com/Alvov1/Aesi-Multiprecision.git + GIT_TAG main) +FetchContent_MakeAvailable(AesiMultiprecision) +... +target_include_directories(Target PRIVATE ${AesiMultiprecision_SOURCE_DIR}) +``` +Further library could be included in project with standard preprocessor command: +> #include + ## Usage: The library is a header only to avoid difficulties while building. In this case, it can be used simultaneously in C++ and CUDA projects without changing the file extension from .cu to .cpp and backwards. Library supports an object-oriented style of data management. Class operators are overloaded for use in expressions. The number's bitness is passed to the class object as a template parameter and has a default value of __*512 bits*__. It should be a multiple of 32. -__1. Initialization.__ Number initialization could be done with numbers, strings, string-views, string literals, or library objects with different precision. User-defined string literals are planned to be released in the future. +Number's initialization could be done with numbers, strings, string-views, string literals, or library objects with different precision. User-defined string literals are planned to be released in the future. -__2. Display.__ Library supports STD streams (char and wchar_t based only), along with stream modifications (std::showbase, std::uppercase, std::hex, std::dec, std::oct). std::format support is planned to be released in the future. +Library supports display operations with STD streams (char and wchar_t based only), along with stream modifications (std::showbase, std::uppercase, std::hex, std::dec, std::oct). std::format support is planned to be released in the future. ### Host: ```cpp @@ -44,12 +58,12 @@ Aesi<1024> factorial(unsigned n) { } int main() { - Aesi<1024> f100 = factorial(100); - std::cout << std::hex << f100 << std::endl; + Aesi<1024> f50 = factorial(50); + std::cout << std::hex << f50 << std::endl; return 0; } ``` -> 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000 +> 0x49eebc961ed279b02b1ef4f28d19a84f5973a1d2c7800000000000 ### Cuda kernel: ```cpp diff --git a/sanitize/primes.bin b/sanitize/primes.bin new file mode 100755 index 0000000..68dff68 Binary files /dev/null and b/sanitize/primes.bin differ diff --git a/sanitize/signed/CMakeLists.txt b/sanitize/signed/CMakeLists.txt new file mode 100755 index 0000000..f931325 --- /dev/null +++ b/sanitize/signed/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.28) +project(AesiSanitize) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(AesiSanitize main.cpp) + +target_compile_options(AesiSanitize PRIVATE -fsanitize=undefined + -fsanitize=unsigned-integer-overflow) +target_link_options(AesiSanitize PRIVATE -fsanitize=undefined + -fsanitize=unsigned-integer-overflow) diff --git a/sanitize/signed/main.cpp b/sanitize/signed/main.cpp new file mode 100755 index 0000000..d4418e5 --- /dev/null +++ b/sanitize/signed/main.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include +#include "../../Aesi.h" + +/* Creator: Alexander Lvov + * Details: Unimplemented + * Uses: . */ + +int main() { + return 0; +} \ No newline at end of file diff --git a/sanitize/unsigned/CMakeLists.txt b/sanitize/unsigned/CMakeLists.txt new file mode 100755 index 0000000..6bf1418 --- /dev/null +++ b/sanitize/unsigned/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.28) +project(AesiSanitize) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(AesiSanitize main.cpp) + +target_compile_options(AesiSanitize PRIVATE -fsanitize=undefined + -fsanitize=address + -fsanitize-address-use-after-scope) +target_link_options(AesiSanitize PRIVATE -fsanitize=undefined + -fsanitize=address + -fsanitize-address-use-after-scope) diff --git a/sanitize/unsigned/main.cpp b/sanitize/unsigned/main.cpp new file mode 100755 index 0000000..f980335 --- /dev/null +++ b/sanitize/unsigned/main.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include "../../Aeu.h" + +/* Creator: Alexander Lvov + * Details: Pollard's (P-1) algorithm for integral factoring. + * Uses: Unsigned multiplication, division, modular exponentiation and GCD. */ + +using primeType = unsigned short; +std::vector loadPrimes(const std::filesystem::path& fromLocation) { + if(!std::filesystem::is_regular_file(fromLocation)) + throw std::invalid_argument("Prime table is not found"); + + std::ifstream input(fromLocation, std::ios::binary); + if(input.fail()) + throw std::runtime_error("Failed to open prime table"); + + const std::size_t primesAmount = 2000; //std::filesystem::file_size(fromLocation) / sizeof(primeType); + std::vector primes (primesAmount); + for (auto& prime: primes) + input.read(reinterpret_cast(&prime), sizeof(primeType)); + + return primes; +} + +int main() { + const Aeu<512> n = "0x4c6f0a38f6c296d07052b794a02317ce9758855"; + std::cout << "N = " << std::showbase << std::hex << n << std::endl; + + const std::filesystem::path primesLocation = "../../primes.bin"; + const auto primes = loadPrimes(primesLocation); + + Aeu<512> base = 2u; + Aeu<2048> power = 1u; + + for(unsigned short prime : primes) { + const auto primeF = static_cast(prime), + boarder = static_cast(std::numeric_limits::max()); + const auto primePower = static_cast(static_cast(std::log(boarder) / std::log(primeF)) - 1); + + power *= static_cast(std::pow(primeF, primePower)); + if(power.bitCount() > 1536) { + base = Aeu<512>::powm<2048>(base, power, n); + power = 1u; + + const auto candidate = Aeu<512>::gcd(base - 1u, n); + if(candidate > 1u) { + std::cout << "Completed: " << std::showbase << std::hex << candidate << std::endl; + return 0; + } + } + } + + return 1; +} \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt old mode 100644 new mode 100755 index 604771c..b71d543 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,33 +7,43 @@ FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/refs/heads/main.zip ) - FetchContent_MakeAvailable(googletest) +FetchContent_Declare( + CryptoPPLib + GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git + GIT_TAG master +) +FetchContent_Populate(CryptoPPLib) -find_package (SQLite3) +find_package(PkgConfig) +pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp) enable_testing() file(GLOB Tests *.cpp) -add_executable(AesiMultiprecision ${Tests} ../Aesi.h) +add_executable(AesiMultiprecision ${Tests}) add_subdirectory(arithmetic) add_subdirectory(operations) add_subdirectory(bitwise) -add_subdirectory(number-theory) -add_subdirectory(gpu) add_subdirectory(boolean) -add_subdirectory(benchmarks) -option(CRYPTOPP_CMP "Enable CryptoPP comparison" OFF) -if (CRYPTOPP_CMP) - add_subdirectory(cryptopp-cmake-master) - set(CryptoppLibraryCall cryptopp) -endif() +add_compile_definitions(CRYPTOPP_USE_STD_SHOWBASE) +add_compile_definitions(AESI_CRYPTOPP_INTEGRATION) +add_compile_definitions(AESI_GMP_INTEGRATION) +add_subdirectory(${cryptopplib_SOURCE_DIR} ${cryptopplib_BINARY_DIR}) + +if (PREPROCESSOR_UNSAFE) + add_definitions(-DAESI_UNSAFE=1) +endif (PREPROCESSOR_UNSAFE) + +if (PREPROCESSOR_PRE_CPP_20) + add_definitions(-DPRE_CPP_20=1) +endif (PREPROCESSOR_PRE_CPP_20) -include_directories(${SQLite3_INCLUDE_DIRS}) -target_link_libraries(AesiMultiprecision GTest::gtest_main ${SQLite3_LIBRARIES} ${CryptoppLibraryCall}) +target_link_libraries(AesiMultiprecision PUBLIC GTest::gtest_main cryptopp PkgConfig::GMP) +target_include_directories(AesiMultiprecision PUBLIC PkgConfig::GMP) include(GoogleTest) -gtest_discover_tests(AesiMultiprecision) +gtest_discover_tests(AesiMultiprecision XML_OUTPUT_DIR ${CMAKE_BINARY_DIR}) diff --git a/test/arithmetic/CMakeLists.txt b/test/arithmetic/CMakeLists.txt old mode 100644 new mode 100755 index 56a9fa8..ba82bd7 --- a/test/arithmetic/CMakeLists.txt +++ b/test/arithmetic/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB ArithmeticTests *.cpp) +file(GLOB ArithmeticTests *.cpp addition/*.cpp subtraction/*.cpp division/*.cpp modulo/*.cpp multiplication/*.cpp) target_sources(AesiMultiprecision PRIVATE ${ArithmeticTests}) \ No newline at end of file diff --git a/test/arithmetic/addition.cpp b/test/arithmetic/addition.cpp deleted file mode 100644 index 4f0e8bf..0000000 --- a/test/arithmetic/addition.cpp +++ /dev/null @@ -1,601 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Addition, Zero) { - Aesi512 zero = 0; - Aesi512 m0 = -26359343; - EXPECT_EQ(m0 + 0, -26359343); - EXPECT_EQ(0 + m0, -26359343); - EXPECT_EQ(m0 - 0, -26359343); - EXPECT_EQ(m0 + zero, -26359343); - EXPECT_EQ(m0 - zero, -26359343); - - EXPECT_EQ(m0 + -zero, -26359343); - EXPECT_EQ(m0 + +zero, -26359343); - EXPECT_EQ(m0 - +zero, -26359343); - EXPECT_EQ(m0 - -zero, -26359343); - - EXPECT_EQ(zero + m0, -26359343); - EXPECT_EQ(+zero + m0, -26359343); - EXPECT_EQ(-zero + m0, -26359343); - - m0 += 0; EXPECT_EQ(m0, -26359343); - m0 += zero; EXPECT_EQ(m0, -26359343); - m0 += -zero; EXPECT_EQ(m0, -26359343); - m0 += +zero; EXPECT_EQ(m0, -26359343); - - Aesi512 m1 = 14670384; - EXPECT_EQ(m1 + 0, 14670384); - EXPECT_EQ(0 + m1, 14670384); - EXPECT_EQ(m1 - 0, 14670384); - EXPECT_EQ(m1 + zero, 14670384); - EXPECT_EQ(m1 - zero, 14670384); - EXPECT_EQ(m1 + -zero, 14670384); - EXPECT_EQ(m1 + +zero, 14670384); - EXPECT_EQ(m1 - +zero, 14670384); - EXPECT_EQ(m1 + +zero, 14670384); - EXPECT_EQ(zero + m1, 14670384); - EXPECT_EQ(+zero + m1, 14670384); - EXPECT_EQ(-zero + m1, 14670384); - m1 += 0; EXPECT_EQ(m1, 14670384); - m1 += zero; EXPECT_EQ(m1, 14670384); - m1 += -zero; EXPECT_EQ(m1, 14670384); - m1 += +zero; EXPECT_EQ(m1, 14670384); - - Aesi512 m2 = 55908622; - EXPECT_EQ(m2 + 0, 55908622); - EXPECT_EQ(0 + m2, 55908622); - EXPECT_EQ(m2 - 0, 55908622); - EXPECT_EQ(m2 + zero, 55908622); - EXPECT_EQ(m2 - zero, 55908622); - EXPECT_EQ(m2 + -zero, 55908622); - EXPECT_EQ(m2 + +zero, 55908622); - EXPECT_EQ(m2 - +zero, 55908622); - EXPECT_EQ(m2 + +zero, 55908622); - EXPECT_EQ(zero + m2, 55908622); - EXPECT_EQ(+zero + m2, 55908622); - EXPECT_EQ(-zero + m2, 55908622); - m2 += 0; EXPECT_EQ(m2, 55908622); - m2 += zero; EXPECT_EQ(m2, 55908622); - m2 += -zero; EXPECT_EQ(m2, 55908622); - m2 += +zero; EXPECT_EQ(m2, 55908622); -} - -TEST(Addition, SmallPositive) { - Aesi512 s1 = 0x24DFBE889, s2 = 0x193E161C, s3 = 0x51CDFC6, s4 = 0x1706808355; - EXPECT_EQ(s1 + s1, 0x49BF7D112); - EXPECT_EQ(s1 + s2, 0x26739fea5); - EXPECT_EQ(s1 + s3, 0x25318c84f); - EXPECT_EQ(s1 + s4, 0x19547c6bde); - - EXPECT_EQ(s2 + s1, 0x26739fea5); - EXPECT_EQ(s2 + s2, 0x327c2c38); - EXPECT_EQ(s2 + s3, 0x1e5af5e2); - EXPECT_EQ(s2 + s4, 0x171fbe9971); - - EXPECT_EQ(s3 + s1, 0x25318c84f); - EXPECT_EQ(s3 + s2, 0x1e5af5e2); - EXPECT_EQ(s3 + s3, 0xa39bf8c); - EXPECT_EQ(s3 + s4, 0x170b9d631b); - - EXPECT_EQ(s4 + s1, 0x19547c6bde); - EXPECT_EQ(s4 + s2, 0x171fbe9971); - EXPECT_EQ(s4 + s3, 0x170b9d631b); - EXPECT_EQ(s4 + s4, 0x2e0d0106aa); -} - -TEST(Addition, SmallNegative) { - Aesi512 s1 = -0x24DFBE889, s2 = -0x193E161C, s3 = -0x51CDFC6, s4 = -0x1706808355; - EXPECT_EQ(s1 + s1, -0x49BF7D112); - EXPECT_EQ(s1 + s2, -0x26739fea5); - EXPECT_EQ(s1 + s3, -0x25318c84f); - EXPECT_EQ(s1 + s4, -0x19547c6bde); - - EXPECT_EQ(s2 + s1, -0x26739fea5); - EXPECT_EQ(s2 + s2, -0x327c2c38); - EXPECT_EQ(s2 + s3, -0x1e5af5e2); - EXPECT_EQ(s2 + s4, -0x171fbe9971); - - EXPECT_EQ(s3 + s1, -0x25318c84f); - EXPECT_EQ(s3 + s2, -0x1e5af5e2); - EXPECT_EQ(s3 + s3, -0xa39bf8c); - EXPECT_EQ(s3 + s4, -0x170b9d631b); - - EXPECT_EQ(s4 + s1, -0x19547c6bde); - EXPECT_EQ(s4 + s2, -0x171fbe9971); - EXPECT_EQ(s4 + s3, -0x170b9d631b); - EXPECT_EQ(s4 + s4, -0x2e0d0106aa); -} - -TEST(Addition, Increment) { - Aesi512 m0 = 62492992; - ++m0; ++m0; m0++; ++m0; m0++; ++m0; m0++; ++m0; m0++; ++m0; - EXPECT_EQ(m0, 62493002); - Aesi512 t0 = m0++, u0 = ++m0; - EXPECT_EQ(t0, 62493002); EXPECT_EQ(u0, 62493004); EXPECT_EQ(m0, 62493004); - - Aesi512 m1 = -10775863; - m1++; ++m1; m1++; ++m1; m1++; ++m1; m1++; ++m1; ++m1; ++m1; m1++; ++m1; ++m1; - EXPECT_EQ(m1, -10775850); - Aesi512 t1 = m1++, u1 = ++m1; - EXPECT_EQ(t1, -10775850); EXPECT_EQ(u1, -10775848); EXPECT_EQ(m1, -10775848); - - Aesi512 m2 = 77428594; - m2++; m2++; ++m2; m2++; m2++; m2++; ++m2; m2++; m2++; m2++; ++m2; m2++; ++m2; ++m2; - EXPECT_EQ(m2, 77428608); - Aesi512 t2 = m2++, u2 = ++m2; - EXPECT_EQ(t2, 77428608); EXPECT_EQ(u2, 77428610); EXPECT_EQ(m2, 77428610); - - Aesi512 m3 = 77677795; - ++m3; ++m3; ++m3; m3++; ++m3; m3++; ++m3; ++m3; m3++; ++m3; m3++; ++m3; m3++; m3++; m3++; m3++; m3++; ++m3; - EXPECT_EQ(m3, 77677813); - Aesi512 t3 = m3++, u3 = ++m3; - EXPECT_EQ(t3, 77677813); EXPECT_EQ(u3, 77677815); EXPECT_EQ(m3, 77677815); - - Aesi512 m4 = -11780979; - m4++; ++m4; m4++; ++m4; m4++; ++m4; m4++; ++m4; m4++; ++m4; ++m4; ++m4; m4++; ++m4; m4++; ++m4; ++m4; ++m4; ++m4; - EXPECT_EQ(m4, -11780960); - Aesi512 t4 = m4++, u4 = ++m4; - EXPECT_EQ(t4, -11780960); EXPECT_EQ(u4, -11780958); EXPECT_EQ(m4, -11780958); - - Aesi512 m5 = -1; - auto t5 = m5++; - EXPECT_EQ(t5, -1); - EXPECT_EQ(m5, 0); - - Aesi512 m6 = -1; - auto t6 = ++m6; - EXPECT_EQ(t6, 0); - EXPECT_EQ(m6, 0); -} - -TEST(Addition, MixedAddition) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678; - EXPECT_EQ(small2 + small3, 0xDED); - EXPECT_EQ(small3 + small2, 0xDED); - EXPECT_EQ(small2 + small1, -0x1099); - EXPECT_EQ(small1 + small2, -0x1099); - - Aesi512 m0 = -899842982222, m1 = 54545454545, m2 = -4243242222222; - EXPECT_EQ(m0 + m0, -0x1A305A4829C); - EXPECT_EQ(m0 + m1, -0xC4CFA8AB7D); - EXPECT_EQ(m0 + m2, -0x4AD77C443DC); - - EXPECT_EQ(m1 + m0, -0xC4CFA8AB7D); - EXPECT_EQ(m1 + m1, 0x1966532BA2); - EXPECT_EQ(m1 + m2, -0x3CF41C86CBD); - - EXPECT_EQ(m2 + m0, -0x4AD77C443DC); - EXPECT_EQ(m2 + m1, -0x3CF41C86CBD); - EXPECT_EQ(m2 + m2, -0x7B7E9E4051C); - - Aesi512 m5 = 44623815129875066, m6 = -67333380797917951; - EXPECT_EQ(m5 + m6, -22709565668042885); - Aesi512 m7 = -48014444995445931, m8 = -22286330479143061; - EXPECT_EQ(m7 + m8, -70300775474588992); - Aesi512 m9 = -46710497537103336, m10 = 38078385918803582; - EXPECT_EQ(m9 + m10, -8632111618299754); - Aesi512 m11 = -85692280903283784, m12 = 67173988903321278; - EXPECT_EQ(m11 + m12, -18518291999962506); - Aesi512 m13 = -44612227547418401, m14 = 59491349319431825; - EXPECT_EQ(m13 + m14, 14879121772013424); - Aesi512 m15 = 31078689473344356, m16 = -68742297725853412; - EXPECT_EQ(m15 + m16, -37663608252509056); - Aesi512 m17 = -45387158811706062, m18 = 79147083749576689; - EXPECT_EQ(m17 + m18, 33759924937870627); - Aesi512 m19 = -89958219458984593, m20 = -81023467713372341; - EXPECT_EQ(m19 + m20, -170981687172356934); - Aesi512 m21 = -26784201699120505, m22 = -80123928943714897; - EXPECT_EQ(m21 + m22, -106908130642835402); - Aesi512 m23 = -45649812857009124, m24 = 83244178464937860; - EXPECT_EQ(m23 + m24, 37594365607928736); - Aesi512 m25 = 28170049468723627, m26 = 32541822036943371; - EXPECT_EQ(m25 + m26, 60711871505666998); - Aesi512 m27 = -22623135028103130, m28 = 21786244319546654; - EXPECT_EQ(m27 + m28, -836890708556476); - Aesi512 m29 = -86015218297363345, m30 = 42612600999881113; - EXPECT_EQ(m29 + m30, -43402617297482232); - Aesi512 m31 = -24053032061086904, m32 = 72114036549128840; - EXPECT_EQ(m31 + m32, 48061004488041936); - Aesi512 m33 = 36822510221127512, m34 = 94178979038637199; - EXPECT_EQ(m33 + m34, 131001489259764711); - Aesi512 m35 = 97484155294477787, m36 = -75334454513432056; - EXPECT_EQ(m35 + m36, 22149700781045731); - Aesi512 m37 = -95934355055619379, m38 = 39209954770039503; - EXPECT_EQ(m37 + m38, -56724400285579876); - Aesi512 m39 = 49370459189897803, m40 = 75902539607732364; - EXPECT_EQ(m39 + m40, 125272998797630167); - Aesi512 m41 = -56291529889007273, m42 = -39790172022000660; - EXPECT_EQ(m41 + m42, -96081701911007933); - Aesi512 m43 = -25166174113513561, m44 = -49119563632507651; - EXPECT_EQ(m43 + m44, -74285737746021212); - - Aesi512 o0 = 5068274318734760134, o1 = -5068274318734760134; EXPECT_EQ(o0 + o1, 0); - Aesi512 o2 = -3860683394265126228, o3 = 3860683394265126228; EXPECT_EQ(o2 + o3, 0); - Aesi512 o4 = -1775716310845094339, o5 = 1775716310845094339; EXPECT_EQ(o4 + o5, 0); - Aesi512 o6 = -4982809897449757117, o7 = 4982809897449757117; EXPECT_EQ(o6 + o7, 0); - Aesi512 o8 = 5786807723690651934, o9 = -5786807723690651934; EXPECT_EQ(o8 + o9, 0); - Aesi512 o10 = -2423589849356590748, o11 = 2423589849356590748; EXPECT_EQ(o10 + o11, 0); - Aesi512 o12 = -6490736897042759090, o13 = 6490736897042759090; EXPECT_EQ(o12 + o13, 0); - Aesi512 o14 = -3414195480796898634, o15 = 3414195480796898634; EXPECT_EQ(o14 + o15, 0); - Aesi512 o16 = 8996002553308629092, o17 = -8996002553308629092; EXPECT_EQ(o16 + o17, 0); - Aesi512 o18 = -7652928859641311027, o19 = 7652928859641311027; EXPECT_EQ(o18 + o19, 0); - Aesi512 o20 = -6331258568347508790, o21 = 6331258568347508790; EXPECT_EQ(o20 + o21, 0); - Aesi512 o22 = 2036733078178028339, o23 = -2036733078178028339; EXPECT_EQ(o22 + o23, 0); - Aesi512 o24 = -8364295954223116051, o25 = 8364295954223116051; EXPECT_EQ(o24 + o25, 0); - Aesi512 o26 = -1514676730082915013, o27 = 1514676730082915013; EXPECT_EQ(o26 + o27, 0); - Aesi512 o28 = 2618812830420948321, o29 = -2618812830420948321; EXPECT_EQ(o28 + o29, 0); - Aesi512 o30 = 3651599756288877851, o31 = -3651599756288877851; EXPECT_EQ(o30 + o31, 0); - Aesi512 o32 = 1246073238795717323, o33 = -1246073238795717323; EXPECT_EQ(o32 + o33, 0); - Aesi512 o34 = 4742152169521293046, o35 = -4742152169521293046; EXPECT_EQ(o34 + o35, 0); - Aesi512 o36 = 1159606334061242319, o37 = -1159606334061242319; EXPECT_EQ(o36 + o37, 0); - Aesi512 o38 = -3281861806216241830, o39 = 3281861806216241830; EXPECT_EQ(o38 + o39, 0); -} - -TEST(Addition, MixedAdditionAssignment) { - Aesi512 m5 = -75372316459883297, m6 = -75066966863039062; - m5 += m6; EXPECT_EQ(m5, -150439283322922359); - Aesi512 m7 = -36248118596253972, m8 = 69183337187190772; - m7 += m8; EXPECT_EQ(m7, 32935218590936800); - Aesi512 m9 = 66104089310021402, m10 = -20950498422421752; - m9 += m10; EXPECT_EQ(m9, 45153590887599650); - Aesi512 m11 = -43281760133359907, m12 = 60779712756644022; - m11 += m12; EXPECT_EQ(m11, 17497952623284115); - Aesi512 m13 = -33624789583363843, m14 = 69106216072981817; - m13 += m14; EXPECT_EQ(m13, 35481426489617974); - Aesi512 m15 = 25897371791224934, m16 = -70058626665729639; - m15 += m16; EXPECT_EQ(m15, -44161254874504705); - Aesi512 m17 = 59354316783597997, m18 = -94991973626467623; - m17 += m18; EXPECT_EQ(m17, -35637656842869626); - Aesi512 m19 = -31274863735638183, m20 = -67383584399340340; - m19 += m20; EXPECT_EQ(m19, -98658448134978523); - Aesi512 m21 = 73598557579492490, m22 = -22951646015761999; - m21 += m22; EXPECT_EQ(m21, 50646911563730491); - Aesi512 m23 = -87022493315496912, m24 = -79800965327847517; - m23 += m24; EXPECT_EQ(m23, -166823458643344429); - Aesi512 m25 = 42148846916246179, m26 = -38317537486308969; - m25 += m26; EXPECT_EQ(m25, 3831309429937210); - Aesi512 m27 = -58591164247623666, m28 = 31866245567030322; - m27 += m28; EXPECT_EQ(m27, -26724918680593344); - Aesi512 m29 = 94024469360178215, m30 = 33354213359861956; - m29 += m30; EXPECT_EQ(m29, 127378682720040171); - Aesi512 m31 = -75956148969625915, m32 = 66500479174544316; - m31 += m32; EXPECT_EQ(m31, -9455669795081599); - Aesi512 m33 = 67953678177925403, m34 = -51458681742174591; - m33 += m34; EXPECT_EQ(m33, 16494996435750812); - Aesi512 m35 = -82561950395978471, m36 = 20736472398654635; - m35 += m36; EXPECT_EQ(m35, -61825477997323836); - Aesi512 m37 = -40406458757268920, m38 = -26529568190778018; - m37 += m38; EXPECT_EQ(m37, -66936026948046938); - Aesi512 m39 = -72742681232649893, m40 = 30117909419217961; - m39 += m40; EXPECT_EQ(m39, -42624771813431932); - Aesi512 m41 = 89568459482648576, m42 = -89327726642310274; - m41 += m42; EXPECT_EQ(m41, 240732840338302); - Aesi512 m43 = 26333862958113887, m44 = 82645320527096753; - m43 += m44; EXPECT_EQ(m43, 108979183485210640); - - Aesi512 o40 = 2719722860000239488, o41 = -2719722860000239488; o40 += o41; EXPECT_EQ(o40, 0); - Aesi512 o42 = -3275008911763694912, o43 = 3275008911763694912; o42 += o43; EXPECT_EQ(o42, 0); - Aesi512 o44 = 2107424241416820028, o45 = -2107424241416820028; o44 += o45; EXPECT_EQ(o44, 0); - Aesi512 o46 = 2775976926759368155, o47 = -2775976926759368155; o46 += o47; EXPECT_EQ(o46, 0); - Aesi512 o48 = 3993932728110075147, o49 = -3993932728110075147; o48 += o49; EXPECT_EQ(o48, 0); - Aesi512 o50 = -8644533734055915054, o51 = 8644533734055915054; o50 += o51; EXPECT_EQ(o50, 0); - Aesi512 o52 = -4978112828172976490, o53 = 4978112828172976490; o52 += o53; EXPECT_EQ(o52, 0); - Aesi512 o54 = -312547397236479662, o55 = 312547397236479662; o54 += o55; EXPECT_EQ(o54, 0); - Aesi512 o56 = -8528514005835341207, o57 = 8528514005835341207; o56 += o57; EXPECT_EQ(o56, 0); - Aesi512 o58 = -2832889987412276273, o59 = 2832889987412276273; o58 += o59; EXPECT_EQ(o58, 0); - Aesi512 o60 = 5648990727367217780, o61 = -5648990727367217780; o60 += o61; EXPECT_EQ(o60, 0); - Aesi512 o62 = -8764799311832407266, o63 = 8764799311832407266; o62 += o63; EXPECT_EQ(o62, 0); - Aesi512 o64 = 2031775844853743051, o65 = -2031775844853743051; o64 += o65; EXPECT_EQ(o64, 0); - Aesi512 o66 = -6242904225104119604, o67 = 6242904225104119604; o66 += o67; EXPECT_EQ(o66, 0); - Aesi512 o68 = 2456898013867158703, o69 = -2456898013867158703; o68 += o69; EXPECT_EQ(o68, 0); - Aesi512 o70 = 4384206323270322229, o71 = -4384206323270322229; o70 += o71; EXPECT_EQ(o70, 0); - Aesi512 o72 = 6212294120722039546, o73 = -6212294120722039546; o72 += o73; EXPECT_EQ(o72, 0); - Aesi512 o74 = -8689007442224992905, o75 = 8689007442224992905; o74 += o75; EXPECT_EQ(o74, 0); - Aesi512 o76 = 4001610624541277038, o77 = -4001610624541277038; o76 += o77; EXPECT_EQ(o76, 0); - Aesi512 o78 = -8814676547385974926, o79 = 8814676547385974926; o78 += o79; EXPECT_EQ(o78, 0); -} - -TEST(Addition, DifferentPrecision) { - { - Aesi < 480 > first = -23929412326908601; // Aesi<15 blocks> - Aesi < 288 > second = 23663609923469824; // Aesi<9 blocks> - EXPECT_EQ(first + second, -265802403438777); - - Aesi < 256 > third = 95362148199314213; // Aesi<8 blocks> - Aesi < 480 > forth = 10676274833885487; // Aesi<15 blocks> - forth += third; EXPECT_EQ(forth, 106038423033199700); - } - { - Aesi < 416 > first = 56401005283971309; // Aesi<13 blocks> - Aesi < 224 > second = 98854388331887188; // Aesi<7 blocks> - EXPECT_EQ(first + second, 155255393615858497); - - Aesi < 256 > third = -64101286967077361; // Aesi<8 blocks> - Aesi < 352 > forth = 82812991105896938; // Aesi<11 blocks> - forth += third; EXPECT_EQ(forth, 18711704138819577); - } - { - Aesi < 480 > first = 19289473785919116; // Aesi<15 blocks> - Aesi < 352 > second = 88606354971145352; // Aesi<11 blocks> - EXPECT_EQ(first + second, 107895828757064468); - - Aesi < 320 > third = -33576333235155486; // Aesi<10 blocks> - Aesi < 448 > forth = 9691621099679918; // Aesi<14 blocks> - forth += third; EXPECT_EQ(forth, -23884712135475568); - } - { - Aesi < 320 > first = -70855796405707722; // Aesi<10 blocks> - Aesi < 320 > second = -63148117042169488; // Aesi<10 blocks> - EXPECT_EQ(first + second, -134003913447877210); - - Aesi < 224 > third = 59468727606522938; // Aesi<7 blocks> - Aesi < 352 > forth = -22251957457924020; // Aesi<11 blocks> - forth += third; EXPECT_EQ(forth, 37216770148598918); - } - { - Aesi < 224 > first = -14400024956935781; // Aesi<7 blocks> - Aesi < 224 > second = 47261225548047463; // Aesi<7 blocks> - EXPECT_EQ(first + second, 32861200591111682); - - Aesi < 320 > third = -46320698585836942; // Aesi<10 blocks> - Aesi < 352 > forth = 74308513987943052; // Aesi<11 blocks> - forth += third; EXPECT_EQ(forth, 27987815402106110); - } - { - Aesi < 288 > first = -36746047384322768; // Aesi<9 blocks> - Aesi < 448 > second = 8912025064804399; // Aesi<14 blocks> - EXPECT_EQ(first + second, -27834022319518369); - - Aesi < 288 > third = 40875922588278201; // Aesi<9 blocks> - Aesi < 448 > forth = -12295777138935876; // Aesi<14 blocks> - forth += third; EXPECT_EQ(forth, 28580145449342325); - } - { - Aesi < 352 > first = 95436749490787210; // Aesi<11 blocks> - Aesi < 192 > second = 92713709861975215; // Aesi<6 blocks> - EXPECT_EQ(first + second, 188150459352762425); - - Aesi < 256 > third = 20843439894600469; // Aesi<8 blocks> - Aesi < 352 > forth = 86003846354786140; // Aesi<11 blocks> - forth += third; EXPECT_EQ(forth, 106847286249386609); - } - { - Aesi < 448 > first = -17143274618699834; // Aesi<14 blocks> - Aesi < 192 > second = 50875672361696629; // Aesi<6 blocks> - EXPECT_EQ(first + second, 33732397742996795); - - Aesi < 256 > third = 85083128565169538; // Aesi<8 blocks> - Aesi < 384 > forth = -85598363854112295; // Aesi<12 blocks> - forth += third; EXPECT_EQ(forth, -515235288942757); - } - { - Aesi < 320 > first = 98923931870480728; // Aesi<10 blocks> - Aesi < 448 > second = -38271056516262020; // Aesi<14 blocks> - EXPECT_EQ(first + second, 60652875354218708); - - Aesi < 224 > third = 34102493724613230; // Aesi<7 blocks> - Aesi < 480 > forth = -29854977705540280; // Aesi<15 blocks> - forth += third; EXPECT_EQ(forth, 4247516019072950); - } - { - Aesi < 480 > first = -32420396791982926; // Aesi<15 blocks> - Aesi < 256 > second = 77560072073673480; // Aesi<8 blocks> - EXPECT_EQ(first + second, 45139675281690554); - - Aesi < 320 > third = -17681540872331455; // Aesi<10 blocks> - Aesi < 384 > forth = 65208663927888378; // Aesi<12 blocks> - forth += third; EXPECT_EQ(forth, 47527123055556923); - } - - Aesi < 896 > o80 = "17292147568265658425844408652755664697460486923116625870821819187630159128784."; Aesi < 480 > o81 = "-17292147568265658425844408652755664697460486923116625870821819187630159128784."; - - - EXPECT_EQ(o80 + o81, 0); - - o80 += o81; - - EXPECT_EQ(o80, 0); - - - Aesi < 672 > o82 = "-108061019286849638655029535257968975797663395642147022239632106962984479563206."; Aesi < 448 > o83 = "108061019286849638655029535257968975797663395642147022239632106962984479563206."; EXPECT_EQ(o82 + o83, 0); o82 += o83; EXPECT_EQ(o82, 0); - Aesi < 736 > o84 = "77748811227776744435662058191512947714726889969030251065532648326311582698283."; Aesi < 288 > o85 = "-77748811227776744435662058191512947714726889969030251065532648326311582698283."; EXPECT_EQ(o84 + o85, 0); o84 += o85; EXPECT_EQ(o84, 0); - Aesi < 736 > o86 = "-106637819751665371158899901257784389227736624678255492123669333457622888524918."; Aesi < 512 > o87 = "106637819751665371158899901257784389227736624678255492123669333457622888524918."; EXPECT_EQ(o86 + o87, 0); o86 += o87; EXPECT_EQ(o86, 0); - Aesi < 832 > o88 = "-40341179032042003744864534600326119703882934982329092555774606413192508052765."; Aesi < 416 > o89 = "40341179032042003744864534600326119703882934982329092555774606413192508052765."; EXPECT_EQ(o88 + o89, 0); o88 += o89; EXPECT_EQ(o88, 0); - Aesi < 896 > o90 = "-102827963671700903763850115983417276613016493292996866439473021287633483397884."; Aesi < 640 > o91 = "102827963671700903763850115983417276613016493292996866439473021287633483397884."; EXPECT_EQ(o90 + o91, 0); o90 += o91; EXPECT_EQ(o90, 0); - Aesi < 672 > o92 = "26955445322337296223307915127944903479061793041602314203846487091137369497479."; Aesi < 512 > o93 = "-26955445322337296223307915127944903479061793041602314203846487091137369497479."; EXPECT_EQ(o92 + o93, 0); o92 += o93; EXPECT_EQ(o92, 0); - Aesi < 928 > o94 = "-36353500651868188680726291305307280001172960071221983657450843003901249034853."; Aesi < 512 > o95 = "36353500651868188680726291305307280001172960071221983657450843003901249034853."; EXPECT_EQ(o94 + o95, 0); o94 += o95; EXPECT_EQ(o94, 0); - Aesi < 736 > o96 = "11464294216835214688221305331411118506766233835674324003727958300317768873981."; Aesi < 544 > o97 = "-11464294216835214688221305331411118506766233835674324003727958300317768873981."; EXPECT_EQ(o96 + o97, 0); o96 += o97; EXPECT_EQ(o96, 0); - Aesi < 928 > o98 = "-47911213277676276894448423380600908799314598022142315040928113361300177985102."; Aesi < 512 > o99 = "47911213277676276894448423380600908799314598022142315040928113361300177985102."; EXPECT_EQ(o98 + o99, 0); o98 += o99; EXPECT_EQ(o98, 0); - Aesi < 960 > o100 = "-96532502528349950502736125847299913629129456337155784222025475888895625021897."; Aesi < 288 > o101 = "96532502528349950502736125847299913629129456337155784222025475888895625021897."; EXPECT_EQ(o100 + o101, 0); o100 += o101; EXPECT_EQ(o100, 0); - Aesi < 640 > o102 = "78483537815517766394025744682570560303705452006099161112083707011373417475290."; Aesi < 640 > o103 = "-78483537815517766394025744682570560303705452006099161112083707011373417475290."; EXPECT_EQ(o102 + o103, 0); o102 += o103; EXPECT_EQ(o102, 0); - Aesi < 736 > o104 = "10879948899670307562738643758228136232568481432903327411834373450886206247883."; Aesi < 576 > o105 = "-10879948899670307562738643758228136232568481432903327411834373450886206247883."; EXPECT_EQ(o104 + o105, 0); o104 += o105; EXPECT_EQ(o104, 0); - Aesi < 864 > o106 = "-67478104707714154952867977619175452406926359168201460380431445723221048633209."; Aesi < 640 > o107 = "67478104707714154952867977619175452406926359168201460380431445723221048633209."; EXPECT_EQ(o106 + o107, 0); o106 += o107; EXPECT_EQ(o106, 0); - Aesi < 928 > o108 = "-38031900644287471090427281306142268272810370471921622678349157583523239183227."; Aesi < 512 > o109 = "38031900644287471090427281306142268272810370471921622678349157583523239183227."; EXPECT_EQ(o108 + o109, 0); o108 += o109; EXPECT_EQ(o108, 0); - Aesi < 928 > o110 = "-11639252013669192875245645508458347731690567616514752769554650583743163991590."; Aesi < 416 > o111 = "11639252013669192875245645508458347731690567616514752769554650583743163991590."; EXPECT_EQ(o110 + o111, 0); o110 += o111; EXPECT_EQ(o110, 0); - Aesi < 832 > o112 = "-88554222376874415418407573354918865831249358858752268573723642718789184490695."; Aesi < 512 > o113 = "88554222376874415418407573354918865831249358858752268573723642718789184490695."; EXPECT_EQ(o112 + o113, 0); o112 += o113; EXPECT_EQ(o112, 0); - Aesi < 704 > o114 = "-21720615367057163938967078017508752482055117771537754413686324879560679633195."; Aesi < 480 > o115 = "21720615367057163938967078017508752482055117771537754413686324879560679633195."; EXPECT_EQ(o114 + o115, 0); o114 += o115; EXPECT_EQ(o114, 0); - Aesi < 832 > o116 = "25899986204477430144665483913625807784670997724225711698361369030436473371085."; Aesi < 576 > o117 = "-25899986204477430144665483913625807784670997724225711698361369030436473371085."; EXPECT_EQ(o116 + o117, 0); o116 += o117; EXPECT_EQ(o116, 0); - Aesi < 736 > o118 = "59378099093235851344254056111650177400407073457120200459746382211927643984559."; Aesi < 576 > o119 = "-59378099093235851344254056111650177400407073457120200459746382211927643984559."; EXPECT_EQ(o118 + o119, 0); o118 += o119; EXPECT_EQ(o118, 0); - -} - -TEST(Addition, Huge) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = "-13549100103414600886156427120715483591666461038296077723884089446412786946231.", m1 = "115451175357567112722490233754097263367144597544359232729156293188915530617010."; - EXPECT_EQ(m0 + m1, "101902075254152511836333806633381779775478136506063155005272203742502743670779."); - Aesi512 m2 = "45281454230333805331966584134840857672649001676512774554893533437862292349265.", m3 = "25027826577808296379081603226927215361809755856252010853764269313683522042751."; - EXPECT_EQ(m2 + m3, "70309280808142101711048187361768073034458757532764785408657802751545814392016."); - Aesi512 m4 = "108891431454131351459085142433407956199093000320605280354621498739611833771995.", m5 = "69013419324895669689028348524966060264807735269158065338846901517581001170083."; - EXPECT_EQ(m4 + m5, "177904850779027021148113490958374016463900735589763345693468400257192834942078."); - Aesi512 m6 = "-58806804454898455394110825019828609301715824137214443965349731397705112665752.", m7 = "-97854055908042957933809585137934174257981697828906008125646648556772593566884."; - EXPECT_EQ(m6 + m7, "-156660860362941413327920410157762783559697521966120452090996379954477706232636."); - Aesi512 m8 = "58369260169160573615590761847678647933374142690964081747241899349153103261734.", m9 = "-33279828650117343093207588101966130863147988141469309780163588502500646322891."; - EXPECT_EQ(m8 + m9, "25089431519043230522383173745712517070226154549494771967078310846652456938843."); - Aesi512 m10 = "49474620319638566755701800607380156807913615641793736644995582580671963666519.", m11 = "115284251381554184153368332862180771289032038101267755391283381001882650557503."; - EXPECT_EQ(m10 + m11, "164758871701192750909070133469560928096945653743061492036278963582554614224022."); - Aesi512 m12 = "-7066390131997900282067972469506547600417583521668975724691810486663734799709.", m13 = "5448775035445236520380527730839479087632825672789326911403815850857006561450."; - EXPECT_EQ(m12 + m13, "-1617615096552663761687444738667068512784757848879648813287994635806728238259."); - Aesi512 m14 = "69557093914428585451897708672550681309973984240087268956569974302246720365035.", m15 = "38766870883917651084070900303446928227130534106297718785413299990649318565550."; - EXPECT_EQ(m14 + m15, "108323964798346236535968608975997609537104518346384987741983274292896038930585."); - Aesi512 m16 = "38318846778821340095976987900830023980292969335169982922615314994034086474455.", m17 = "94302163512967722980447058416491539978983995734528040255205640925452383840477."; - EXPECT_EQ(m16 + m17, "132621010291789063076424046317321563959276965069698023177820955919486470314932."); - Aesi512 m18 = "77015431695962030598186409553917232320578143875952887062686261817148769094353.", m19 = "18964046245546723859309619450247112464299763862338618066786651400053025260709."; - EXPECT_EQ(m18 + m19, "95979477941508754457496029004164344784877907738291505129472913217201794355062."); - Aesi512 m20 = "4332241825087723079063654775597410732774251740817020258920210297073561833214.", m21 = "-96309256561952725064807504298071866816610658193107865797387872784435417314922."; - EXPECT_EQ(m20 + m21, "-91977014736865001985743849522474456083836406452290845538467662487361855481708."); - Aesi512 m22 = "-12826761563349560609970348956427349345020386542869329390873317574740095116669.", m23 = "-99428342087137917139725486051284223686086887322514034693315445402686229258454."; - EXPECT_EQ(m22 + m23, "-112255103650487477749695835007711573031107273865383364084188762977426324375123."); - Aesi512 m24 = "54706233749167203667715393468986924983158946105900902800773520578258475062339.", m25 = "98107400877196521137704271785518131463553711216717546360108151732280167993633."; - EXPECT_EQ(m24 + m25, "152813634626363724805419665254505056446712657322618449160881672310538643055972."); - Aesi512 m26 = "-4343287337787698224905936913274065541388905078764458574662762584515057703444.", m27 = "110184671520568065642354194955715464687222276970637573285346294446263431764892."; - EXPECT_EQ(m26 + m27, "105841384182780367417448258042441399145833371891873114710683531861748374061448."); - Aesi512 m28 = "24252453601461698240806051353669185787255099680882256683055919729196134983841.", m29 = "27420489240356756513950854945814364521868348066302132509290227695236863208369."; - EXPECT_EQ(m28 + m29, "51672942841818454754756906299483550309123447747184389192346147424432998192210."); - Aesi512 m30 = "66333630859549433359205493340526297495430812608365868849317427120376938684292.", m31 = "-59559884181476156820429252242944423664072316219720426969624487294468992005633."; - EXPECT_EQ(m30 + m31, "6773746678073276538776241097581873831358496388645441879692939825907946678659."); - Aesi512 m32 = "-9904506978110120109149714700751410365398463565610493658398449454988849890175.", m33 = "-57120816515342090449288554272507588186025952925804084822155399957050613162903."; - EXPECT_EQ(m32 + m33, "-67025323493452210558438268973258998551424416491414578480553849412039463053078."); - Aesi512 m34 = "719306043256300033001341655459448096773809580640832171332059514996278356074.", m35 = "-71903463092322171405928832619371828438100604500690760178767494049147062660300."; - EXPECT_EQ(m34 + m35, "-71184157049065871372927490963912380341326794920049928007435434534150784304226."); - Aesi512 m36 = "75759045642488410862631479514318580035336836902252755029780344294238731783691.", m37 = "-70144469127600513418049228129550067988688107369517201666120588150501901779810."; - EXPECT_EQ(m36 + m37, "5614576514887897444582251384768512046648729532735553363659756143736830003881."); - Aesi512 m38 = "90416173590342494968635859909946588082955613608957178686659580958639023391117.", m39 = "3245925798687795614843830341443626833421578161022499869432395578235200803122."; - EXPECT_EQ(m38 + m39, "93662099389030290583479690251390214916377191769979678556091976536874224194239."); - Aesi512 m40 = "58300370200746311303420912484442909549792380091542305390726976530848805993020.", m41 = "-3450885716111942423524523803243850959578283040883945779213440362587704045205."; - EXPECT_EQ(m40 + m41, "54849484484634368879896388681199058590214097050658359611513536168261101947815."); - Aesi512 m42 = "-22698633675896925840654438036124459646553299679576852116559920866466789888346.", m43 = "79150248343020428316159313781271879509419269844836285719761750445632641603114."; - EXPECT_EQ(m42 + m43, "56451614667123502475504875745147419862865970165259433603201829579165851714768."); - Aesi512 m44 = "103813514568315595635101173174330242842597945568169576686766482694588046567696.", m45 = "82336343702092581321684141842506431884953869764077424742898886683988486541262."; - EXPECT_EQ(m44 + m45, "186149858270408176956785315016836674727551815332247001429665369378576533108958."); - Aesi512 m46 = "-92999636886297838985828756225406117928546078141926201331723973703208514675321.", m47 = "2884844455497174877707318424046576850785737693713799457829594139288399697415."; - EXPECT_EQ(m46 + m47, "-90114792430800664108121437801359541077760340448212401873894379563920114977906."); - Aesi512 m48 = "-96343425608826423800819883155095379484897370354064419689516645259193330665760.", m49 = "173492763590154296101144448064144643151650855321925953703211266201326590084."; - EXPECT_EQ(m48 + m49, "-96169932845236269504718738707031234841745719498742493735813433992992004075676."); - Aesi512 m50 = "-3234606044134955825625562220528803011773392296482025816573272531827396805435.", m51 = "50585178919290036623349431979279635441594173410689267296458352732363477062806."; - EXPECT_EQ(m50 + m51, "47350572875155080797723869758750832429820781114207241479885080200536080257371."); - Aesi512 m52 = "66766495191569294972893699395432867494959679893469790984787377732016917873457.", m53 = "-108630875772997548729523271893675160565029468119000655010353926115533223896757."; - EXPECT_EQ(m52 + m53, "-41864380581428253756629572498242293070069788225530864025566548383516306023300."); - Aesi512 m54 = "-55726050086780286592929041475388604515752260185649233196116785823387423278526.", m55 = "81752691527890594372989548737352855192145958989042223493302071740982499249831."; - EXPECT_EQ(m54 + m55, "26026641441110307780060507261964250676393698803392990297185285917595075971305."); - Aesi512 m56 = "-3091178052747191538924501602274100619018394289463534938582228512580812343548.", m57 = "-94499161452113406230081000558657078517880876774727764624124620570723157391091."; - EXPECT_EQ(m56 + m57, "-97590339504860597769005502160931179136899271064191299562706849083303969734639."); - Aesi512 m58 = "2033511484700820566303448027763315065398568301054031583643444117633629860212.", m59 = "-52458649239972902983695674151421428572215873323387844402669647453855579174927."; - EXPECT_EQ(m58 + m59, "-50425137755272082417392226123658113506817305022333812819026203336221949314715."); - Aesi512 m60 = "-98016249251728077416008250726613835268015936744425906303756145172910176924543.", m61 = "-86242671771430950151556883286127732183717443120380532307550501883550327105441."; - EXPECT_EQ(m60 + m61, "-184258921023159027567565134012741567451733379864806438611306647056460504029984."); - Aesi512 m62 = "-99667512487788082717516311860828123551698072398150446307151324055133196250566.", m63 = "42905396970694822709328048421876184882994511422734990303858786206466970677171."; - EXPECT_EQ(m62 + m63, "-56762115517093260008188263438951938668703560975415456003292537848666225573395."); - Aesi512 m64 = "-23122442257530588137654265210865313622854531067016495708037578189022255746398.", m65 = "18533582122157717454276798053327186949758273453827022342566832249095649803399."; - EXPECT_EQ(m64 + m65, "-4588860135372870683377467157538126673096257613189473365470745939926605942999."); - Aesi512 m66 = "110935946622862457797705685662973836346054807207931177312457473768659466477740.", m67 = "-32836755534781818529205471374107102320135541309651922726904518667557206713343."; - EXPECT_EQ(m66 + m67, "78099191088080639268500214288866734025919265898279254585552955101102259764397."); - Aesi512 m68 = "-95653406031339427299536907611732014995681606666761328354797167286641532449111.", m69 = "-41276983529395255431365317307957830560098122806054519901792869994430983318997."; - EXPECT_EQ(m68 + m69, "-136930389560734682730902224919689845555779729472815848256590037281072515768108."); - Aesi512 m70 = "74342598690219307176311028796074656964360863009620613633853759481595220323531.", m71 = "11337427150260260457719835491637528874523484557029820967285558000423076453005."; - EXPECT_EQ(m70 + m71, "85680025840479567634030864287712185838884347566650434601139317482018296776536."); - Aesi512 m72 = "81297381108347581531313998871206471003525348361740936394671594990055518372016.", m73 = "71685650121512812785948993736084367022622666175412243813503530723241573507452."; - EXPECT_EQ(m72 + m73, "152983031229860394317262992607290838026148014537153180208175125713297091879468."); - Aesi512 m74 = "64382646372466014041142925975848483187586128283013953879326148172665103978926.", m75 = "-50605759750397184102830269103414075624218967518440198530430444581279753862140."; - EXPECT_EQ(m74 + m75, "13776886622068829938312656872434407563367160764573755348895703591385350116786."); - Aesi512 m76 = "29705329217773187189273085751565239599481037098073658491326480569309984135584.", m77 = "-87403165070224286166818743311549446679742222247181361455479050687980165075443."; - EXPECT_EQ(m76 + m77, "-57697835852451098977545657559984207080261185149107702964152570118670180939859."); - Aesi512 m78 = "67824248013177802097397937140001654482400020166872619182813946509566153393272.", m79 = "-77223507462154260090454129169668278804288507713253020067034159485154224143650."; - EXPECT_EQ(m78 + m79, "-9399259448976457993056192029666624321888487546380400884220212975588070750378."); - - -#ifdef NDEBUG - Logging::addRecord("Addition", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ - -} - -TEST(Addition, HugeAssignment) { - Aesi512 m0 = "-62961704833218970386168642302340008437573979849817564903391337110353485370773.", m1 = "-106918339802733400530167239089041376679512190271636652920670519621454804126945."; - m0 += m1; EXPECT_EQ(m0, "-169880044635952370916335881391381385117086170121454217824061856731808289497718."); - Aesi512 m2 = "25965935528246179387925598447248937400577350605844797281568362679050867257767.", m3 = "-10666810050029595936073827132627908816825277877501030116750226039559938571818."; - m2 += m3; EXPECT_EQ(m2, "15299125478216583451851771314621028583752072728343767164818136639490928685949."); - Aesi512 m4 = "63637942565867904577519456060863075992185272202525472653188140347529549358637.", m5 = "-92094447069524586405097401771645864538321907152435534743762178170206941457077."; - m4 += m5; EXPECT_EQ(m4, "-28456504503656681827577945710782788546136634949910062090574037822677392098440."); - Aesi512 m6 = "-69861541491828635376167784973817464735880479861812141274422719988132997488579.", m7 = "-71766241763662647251626949812087604519177151589960351233858638770518097517257."; - m6 += m7; EXPECT_EQ(m6, "-141627783255491282627794734785905069255057631451772492508281358758651095005836."); - Aesi512 m8 = "-66278528516852251761654018714426943811561291386613768635812653942523694324190.", m9 = "53711434523307851814878014700593969601197206078072358549598270479245932967731."; - m8 += m9; EXPECT_EQ(m8, "-12567093993544399946776004013832974210364085308541410086214383463277761356459."); - Aesi512 m10 = "-110785931196167214737169956442130735139603414894464509518238315137081188044661.", m11 = "74196511339815680466236351082876384570023503428305365345894350575296809946032."; - m10 += m11; EXPECT_EQ(m10, "-36589419856351534270933605359254350569579911466159144172343964561784378098629."); - Aesi512 m12 = "86583291289047514337524097943127851160498349278574758096348216713561464076365.", m13 = "-108810143340051441642238578890576372955411584997931808097815383786171720552812."; - m12 += m13; EXPECT_EQ(m12, "-22226852051003927304714480947448521794913235719357050001467167072610256476447."); - Aesi512 m14 = "-115133325067751782394089913860336364838818522547070711890927479403253703623763.", m15 = "42864233293261413438800070407432536883096033875274593271964987271421613813844."; - m14 += m15; EXPECT_EQ(m14, "-72269091774490368955289843452903827955722488671796118618962492131832089809919."); - Aesi512 m16 = "80980722601940102356182469978560135619688683132932780793002526784487470723505.", m17 = "30234814170261705754011369719817997818921215061313888691620993651198974121773."; - m16 += m17; EXPECT_EQ(m16, "111215536772201808110193839698378133438609898194246669484623520435686444845278."); - Aesi512 m18 = "67662737113256933325612733449039933299746479116980386338203426037858033604659.", m19 = "-60790364484156247712714693514625531898366847703776048389522262785797875037071."; - m18 += m19; EXPECT_EQ(m18, "6872372629100685612898039934414401401379631413204337948681163252060158567588."); - Aesi512 m20 = "36462390938887473575403963548213245906822295420933922825681240412425134028937.", m21 = "-9349271571542294345424738039916963170728443439782099416791550428074712507364."; - m20 += m21; EXPECT_EQ(m20, "27113119367345179229979225508296282736093851981151823408889689984350421521573."); - Aesi512 m22 = "-41301979906106891313272229779071799054504399494265006127591986609270403313991.", m23 = "27659877162483088964147787899907476485719671218330017506197805703305240804521."; - m22 += m23; EXPECT_EQ(m22, "-13642102743623802349124441879164322568784728275934988621394180905965162509470."); - Aesi512 m24 = "-17056841624301591904838893295564143281653472407589147564441540779296044903936.", m25 = "36548864462241466936115101158890462241523414624207808670568005428061397411169."; - m24 += m25; EXPECT_EQ(m24, "19492022837939875031276207863326318959869942216618661106126464648765352507233."); - Aesi512 m26 = "-87081402838302760847052183698108314696248364816737354826839214583233409167012.", m27 = "91365673609665905430730891535681316044953717085285067072837220088027214780752."; - m26 += m27; EXPECT_EQ(m26, "4284270771363144583678707837573001348705352268547712245998005504793805613740."); - Aesi512 m28 = "94715125107675386136642380450216059925882313942517887599805660895428444015182.", m29 = "53318909404499727705733261777479846847055471547556217402531636571878844028454."; - m28 += m29; EXPECT_EQ(m28, "148034034512175113842375642227695906772937785490074105002337297467307288043636."); - Aesi512 m30 = "-60602236195107260061480259842491008440547793921908540253428714397581339368828.", m31 = "-74992718777611407387842988689644751122999115694787251760834521230938245256574."; - m30 += m31; EXPECT_EQ(m30, "-135594954972718667449323248532135759563546909616695792014263235628519584625402."); - Aesi512 m32 = "-82167829843260906029959923317865370476823977820644591647403426710644427374117.", m33 = "-3682965217668944726008819153502687850991242183719779781898479024034008714052."; - m32 += m33; EXPECT_EQ(m32, "-85850795060929850755968742471368058327815220004364371429301905734678436088169."); - Aesi512 m34 = "109427592772827737458529613095493314844456460573070639639843167541781204268543.", m35 = "-1260357510291106885383018347050955201041430069322149681412943996774874548559."; - m34 += m35; EXPECT_EQ(m34, "108167235262536630573146594748442359643415030503748489958430223545006329719984."); - Aesi512 m36 = "100004086463172424534705179795314115324020939402271785452743505137318598348017.", m37 = "50237559641833864893429901202702599610914737567234117650901273813267456761933."; - m36 += m37; EXPECT_EQ(m36, "150241646105006289428135080998016714934935676969505903103644778950586055109950."); - Aesi512 m38 = "76198442652849782899012560966830619596880670302758332671559725160447866261520.", m39 = "26409746155164300150268177112509811925896542182285923184176592114665712507133."; - m38 += m39; EXPECT_EQ(m38, "102608188808014083049280738079340431522777212485044255855736317275113578768653."); - Aesi512 m40 = "51554281408191630258273209778161658355190547065196773468584717589051965714332.", m41 = "-73039367703575172360738702273478980869028286863576037793733637530403881418682."; - m40 += m41; EXPECT_EQ(m40, "-21485086295383542102465492495317322513837739798379264325148919941351915704350."); - Aesi512 m42 = "57010534776559176195067917206389836855382600099432291885463305409045228964958.", m43 = "-6761042612366454763771486045370366668016186222563807206424353993302506349730."; - m42 += m43; EXPECT_EQ(m42, "50249492164192721431296431161019470187366413876868484679038951415742722615228."); - Aesi512 m44 = "-101980096529672236208044167125383332606072998373802700015935563954688574498345.", m45 = "-61779531137153871352235374008684432748014071309440476553233823389778052954200."; - m44 += m45; EXPECT_EQ(m44, "-163759627666826107560279541134067765354087069683243176569169387344466627452545."); - Aesi512 m46 = "-38871027068831474063464141260873790766279964489331565550239270048814935850096.", m47 = "-19669464189471714804263171557794730525328667103637541205660399027957506021438."; - m46 += m47; EXPECT_EQ(m46, "-58540491258303188867727312818668521291608631592969106755899669076772441871534."); - Aesi512 m48 = "-41572190224960413993818891806200137971314324405730989898901904245384644117907.", m49 = "-31762947139680490327950796726801716007745014499128868385057240252884519248705."; - m48 += m49; EXPECT_EQ(m48, "-73335137364640904321769688533001853979059338904859858283959144498269163366612."); - Aesi512 m50 = "25941597338086517117556825450811278986974703579033056963420423421976809252009.", m51 = "-91627016175872106873401619166388578574529630344875603893605308864402212988318."; - m50 += m51; EXPECT_EQ(m50, "-65685418837785589755844793715577299587554926765842546930184885442425403736309."); - Aesi512 m52 = "-60524882961575719842107061247292927559345726806844926899312143532870691069646.", m53 = "-14713675077732624426552634720066940777997816150114870045851233364231484759925."; - m52 += m53; EXPECT_EQ(m52, "-75238558039308344268659695967359868337343542956959796945163376897102175829571."); - Aesi512 m54 = "-11849043754633931961433544564960850411147707778330943832250093979958826198739.", m55 = "-70635853325168997265498359296360360905156191778147675204107401910793599938666."; - m54 += m55; EXPECT_EQ(m54, "-82484897079802929226931903861321211316303899556478619036357495890752426137405."); - Aesi512 m56 = "-9354853919334238691305470386858753989141421399012574857145428767763943825766.", m57 = "-31021133563054328331495009598898147797194915626631067349692717214189772506081."; - m56 += m57; EXPECT_EQ(m56, "-40375987482388567022800479985756901786336337025643642206838145981953716331847."); - Aesi512 m58 = "13865942676492651648473259372433057281870266920359609505322230121311244832101.", m59 = "56066096831692160460204849812265780147112331448434934570830098787151499837315."; - m58 += m59; EXPECT_EQ(m58, "69932039508184812108678109184698837428982598368794544076152328908462744669416."); - Aesi512 m60 = "-92934622518151297449534256683338258419920301101703184996797369893157258706960.", m61 = "-39796335875172271746057303092867947664556830064536794556122414945344855455898."; - m60 += m61; EXPECT_EQ(m60, "-132730958393323569195591559776206206084477131166239979552919784838502114162858."); - Aesi512 m62 = "14005859803031340485583705988307773923359900722578961988902316205557162677662.", m63 = "4305335628157870457579798533498638561887981156817697082105600515947128023987."; - m62 += m63; EXPECT_EQ(m62, "18311195431189210943163504521806412485247881879396659071007916721504290701649."); - Aesi512 m64 = "51803049387560631079076544315054401650825149904103387821354214050674371780602.", m65 = "97526896257282632138813513383013442363600533664579118286794692040879987902624."; - m64 += m65; EXPECT_EQ(m64, "149329945644843263217890057698067844014425683568682506108148906091554359683226."); - Aesi512 m66 = "-17745141046065455868507231804162392840813332360978326054942775219446085521711.", m67 = "-105189720918008914591085922024513750890697193815975776531441382592821092962669."; - m66 += m67; EXPECT_EQ(m66, "-122934861964074370459593153828676143731510526176954102586384157812267178484380."); - Aesi512 m68 = "-70836307461099080344865636724644638547717308488634539066572130043807166566522.", m69 = "26948936239666757461124034774152678147508986261964773716317080053602148930199."; - m68 += m69; EXPECT_EQ(m68, "-43887371221432322883741601950491960400208322226669765350255049990205017636323."); - Aesi512 m70 = "-91013603442917682205021770751559963473181302945075004992180352377615890306630.", m71 = "114680193009776739984012867946066499661447743735190787057446949139230388764773."; - m70 += m71; EXPECT_EQ(m70, "23666589566859057778991097194506536188266440790115782065266596761614498458143."); - Aesi512 m72 = "-53476777566304624168748953308016475904454100530708947304210595936819000588130.", m73 = "89553041041709053420625784400479580580847169302857364042250998928921122621369."; - m72 += m73; EXPECT_EQ(m72, "36076263475404429251876831092463104676393068772148416738040402992102122033239."); - Aesi512 m74 = "-88876307149560369041863358290259484524111849079894242571699687955665707757785.", m75 = "-86300944650194690236450476763877556408244275616204709712142739221725249027391."; - m74 += m75; EXPECT_EQ(m74, "-175177251799755059278313835054137040932356124696098952283842427177390956785176."); - Aesi512 m76 = "-28345432503898631775708275229488078408490807783438428033441827759732415341531.", m77 = "-74361775938205303422259546365932203482801452187477871271800020842392506921292."; - m76 += m77; EXPECT_EQ(m76, "-102707208442103935197967821595420281891292259970916299305241848602124922262823."); - Aesi512 m78 = "39880641938009694976009529818544307417131645902512435395059693987685794500867.", m79 = "27585158911098535146934795821583081219257548326620321405934828412423626340166."; - m78 += m79; EXPECT_EQ(m78, "67465800849108230122944325640127388636389194229132756800994522400109420841033."); -} \ No newline at end of file diff --git a/test/arithmetic/addition/signed.cpp b/test/arithmetic/addition/signed.cpp new file mode 100755 index 0000000..3a65dd4 --- /dev/null +++ b/test/arithmetic/addition/signed.cpp @@ -0,0 +1,120 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Addition, Basic) { + { + Aesi128 zero = 0u, m0 = 26359343u; + EXPECT_EQ(zero + m0, 26359343u); + EXPECT_EQ(m0 + zero, 26359343u); + EXPECT_EQ(zero + +m0, 26359343u); + EXPECT_EQ(m0 + +zero, 26359343u); + EXPECT_EQ(+zero + m0, 26359343u); + EXPECT_EQ(+m0 + zero, 26359343u); + EXPECT_EQ(+zero + +m0, 26359343u); + EXPECT_EQ(+m0 + +zero, 26359343u); + m0 += zero; EXPECT_EQ(m0, 26359343u); m0 += +zero; EXPECT_EQ(m0, 26359343u); +m0 += zero; EXPECT_EQ(m0, 26359343u); +m0 += +zero; EXPECT_EQ(m0, 26359343u); + } + { + Aesi128 zero = 0u, m1 = 14670384u, m2 = 55908622u; + EXPECT_EQ(m1 + 0u, 14670384u); EXPECT_EQ(0u + m1, 14670384u); EXPECT_EQ(m1 + zero, 14670384u); EXPECT_EQ(m1 + +zero, 14670384u); + EXPECT_EQ(m1 + +zero, 14670384u); EXPECT_EQ(zero + m1, 14670384u); EXPECT_EQ(+zero + m1, 14670384u); m1 += 0u; EXPECT_EQ(m1, 14670384u); + m1 += zero; EXPECT_EQ(m1, 14670384u); m1 += +zero; EXPECT_EQ(m1, 14670384u); + + EXPECT_EQ(m2 + 0u, 55908622u); EXPECT_EQ(0u + m2, 55908622u); EXPECT_EQ(m2 + zero, 55908622u); EXPECT_EQ(m2 + +zero, 55908622u); + EXPECT_EQ(m2 + +zero, 55908622u); EXPECT_EQ(zero + m2, 55908622u); EXPECT_EQ(+zero + m2, 55908622u); m2 += 0u; EXPECT_EQ(m2, 55908622u); + m2 += zero; EXPECT_EQ(m2, 55908622u); m2 += +zero; EXPECT_EQ(m2, 55908622u); + } + { + Aesi128 s1 = 0x24DFBE889u, s2 = 0x193E161Cu, s3 = 0x51CDFC6u, s4 = 0x1706808355u; + EXPECT_EQ(s1 + s1, 0x49BF7D112u); + EXPECT_EQ(s1 + s2, 0x26739fea5u); + EXPECT_EQ(s1 + s3, 0x25318c84fu); + EXPECT_EQ(s1 + s4, 0x19547c6bdeu); + EXPECT_EQ(s2 + s1, 0x26739fea5u); + EXPECT_EQ(s2 + s2, 0x327c2c38u); + EXPECT_EQ(s2 + s3, 0x1e5af5e2u); + EXPECT_EQ(s2 + s4, 0x171fbe9971u); + EXPECT_EQ(s3 + s1, 0x25318c84fu); + EXPECT_EQ(s3 + s2, 0x1e5af5e2u); + EXPECT_EQ(s3 + s3, 0xa39bf8cu); + EXPECT_EQ(s3 + s4, 0x170b9d631bu); + EXPECT_EQ(s4 + s1, 0x19547c6bdeu); + EXPECT_EQ(s4 + s2, 0x171fbe9971u); + EXPECT_EQ(s4 + s3, 0x170b9d631bu); + EXPECT_EQ(s4 + s4, 0x2e0d0106aau); + } +} + +TEST(Signed_Addition, Huge) { + constexpr auto testsAmount = 2, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + int first = 0, second = 0; + switch(i % 4) { + case 0: + first = 1, second = 1; break; + case 1: + first = -1, second = -1; break; + case 2: + first = -1, second = 1; break; + default: + first = 1, second = -1; + } + const auto l = first * Generation::getRandomWithBits(blocksNumber * 16 - 110), + r = second * Generation::getRandomWithBits(blocksNumber * 16 - 110); + + Aesi lA = l, rA = r; + EXPECT_EQ(lA + rA, l + r); + + lA += rA; + EXPECT_EQ(lA, l + r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto mod = Generation::getRandom(); + + Aesi aeu = value; + EXPECT_EQ(aeu + mod, value + mod); + + aeu += mod; + EXPECT_EQ(aeu, value + mod); + } +} + +TEST(Signed_Addition, Increment) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 110); + Aesi value = l; + + const std::size_t increments = rand() % 100; + for (std::size_t j = 0; j < increments * 2; j += 2) { + EXPECT_EQ(value++, l + j); + EXPECT_EQ(++value, l + j + 2); + } + EXPECT_EQ(value, l + increments * 2); + } + + Aesi test = 0; ++test; + EXPECT_EQ(test, 1); + EXPECT_FALSE(test.isZero()); + EXPECT_GT(test, 0); + + test = 0; test++; + EXPECT_EQ(test, 1); + EXPECT_FALSE(test.isZero()); + EXPECT_GT(test, 0); + + test = -1; ++test; + EXPECT_EQ(test, 0); + EXPECT_TRUE(test.isZero()); + EXPECT_GT(test, -1); + + test = -1; test++; + EXPECT_EQ(test, 0); + EXPECT_TRUE(test.isZero()); + EXPECT_GT(test, -1); +} \ No newline at end of file diff --git a/test/arithmetic/addition/unsigned.cpp b/test/arithmetic/addition/unsigned.cpp new file mode 100755 index 0000000..1a51bcf --- /dev/null +++ b/test/arithmetic/addition/unsigned.cpp @@ -0,0 +1,103 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Addition, Basic) { + { + Aeu128 zero = 0u, m0 = 26359343u; + EXPECT_EQ(zero + m0, 26359343u); + EXPECT_EQ(m0 + zero, 26359343u); + EXPECT_EQ(zero + +m0, 26359343u); + EXPECT_EQ(m0 + +zero, 26359343u); + EXPECT_EQ(+zero + m0, 26359343u); + EXPECT_EQ(+m0 + zero, 26359343u); + EXPECT_EQ(+zero + +m0, 26359343u); + EXPECT_EQ(+m0 + +zero, 26359343u); + m0 += zero; EXPECT_EQ(m0, 26359343u); m0 += +zero; EXPECT_EQ(m0, 26359343u); +m0 += zero; EXPECT_EQ(m0, 26359343u); +m0 += +zero; EXPECT_EQ(m0, 26359343u); + } + { + Aeu128 zero = 0u, m1 = 14670384u, m2 = 55908622u; + EXPECT_EQ(m1 + 0u, 14670384u); EXPECT_EQ(0u + m1, 14670384u); EXPECT_EQ(m1 + zero, 14670384u); EXPECT_EQ(m1 + +zero, 14670384u); + EXPECT_EQ(m1 + +zero, 14670384u); EXPECT_EQ(zero + m1, 14670384u); EXPECT_EQ(+zero + m1, 14670384u); m1 += 0u; EXPECT_EQ(m1, 14670384u); + m1 += zero; EXPECT_EQ(m1, 14670384u); m1 += +zero; EXPECT_EQ(m1, 14670384u); + + EXPECT_EQ(m2 + 0u, 55908622u); EXPECT_EQ(0u + m2, 55908622u); EXPECT_EQ(m2 + zero, 55908622u); EXPECT_EQ(m2 + +zero, 55908622u); + EXPECT_EQ(m2 + +zero, 55908622u); EXPECT_EQ(zero + m2, 55908622u); EXPECT_EQ(+zero + m2, 55908622u); m2 += 0u; EXPECT_EQ(m2, 55908622u); + m2 += zero; EXPECT_EQ(m2, 55908622u); m2 += +zero; EXPECT_EQ(m2, 55908622u); + } + { + Aeu128 s1 = 0x24DFBE889u, s2 = 0x193E161Cu, s3 = 0x51CDFC6u, s4 = 0x1706808355u; + EXPECT_EQ(s1 + s1, 0x49BF7D112u); + EXPECT_EQ(s1 + s2, 0x26739fea5u); + EXPECT_EQ(s1 + s3, 0x25318c84fu); + EXPECT_EQ(s1 + s4, 0x19547c6bdeu); + EXPECT_EQ(s2 + s1, 0x26739fea5u); + EXPECT_EQ(s2 + s2, 0x327c2c38u); + EXPECT_EQ(s2 + s3, 0x1e5af5e2u); + EXPECT_EQ(s2 + s4, 0x171fbe9971u); + EXPECT_EQ(s3 + s1, 0x25318c84fu); + EXPECT_EQ(s3 + s2, 0x1e5af5e2u); + EXPECT_EQ(s3 + s3, 0xa39bf8cu); + EXPECT_EQ(s3 + s4, 0x170b9d631bu); + EXPECT_EQ(s4 + s1, 0x19547c6bdeu); + EXPECT_EQ(s4 + s2, 0x171fbe9971u); + EXPECT_EQ(s4 + s3, 0x170b9d631bu); + EXPECT_EQ(s4 + s4, 0x2e0d0106aau); + } +} + +TEST(Unsigned_Addition, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 16 - 32), + r = Generation::getRandomWithBits(blocksNumber * 16 - 32); + + Aeu lA = l, rA = r; + EXPECT_EQ(lA + rA, l + r); + + lA += rA; + EXPECT_EQ(lA, l + r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto add = Generation::getRandom(); + + Aeu aeu = value; + EXPECT_EQ(aeu + add, value + add); + + aeu += add; + EXPECT_EQ(aeu, value + add); + } +} + +TEST(Unsigned_Addition, Increment) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 110); + Aeu value = l; + + const std::size_t increments = rand() % 100; + for (std::size_t j = 0; j < increments * 2; j += 2) { + EXPECT_EQ(value++, l + j); + EXPECT_EQ(++value, l + j + 2); + } + EXPECT_EQ(value, l + increments * 2); + } + + Aeu test = 0u; ++test; + EXPECT_EQ(test, 1u); + EXPECT_FALSE(test.isZero()); + EXPECT_GT(test, 0u); + + test = 0u; test++; + EXPECT_EQ(test, 1u); + EXPECT_FALSE(test.isZero()); + EXPECT_GT(test, 0u); + + Aeu<4 * 32> test2 = "0x0000_0000'FFFF_FFFF'FFFF_FFFF'FFFF_FFFF"; + EXPECT_EQ(++test2, "0x0000_0001'0000_0000'0000_0000'0000_0000"); +} + diff --git a/test/arithmetic/division.cpp b/test/arithmetic/division.cpp deleted file mode 100644 index 326bf3d..0000000 --- a/test/arithmetic/division.cpp +++ /dev/null @@ -1,371 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Division, SmallPositive) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small1 / small3, 12); - EXPECT_EQ(small3 / small1, 0); - EXPECT_EQ(small2 / small4, 1); - EXPECT_EQ(small4 / small2, 0); -} - -TEST(Division, SmallNegative) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small2 / small3, -6); - EXPECT_EQ(small3 / small2, 0); - EXPECT_EQ(small1 / small4, -3); - EXPECT_EQ(small4 / small1, 0); -} - -TEST(Division, MixedDivision) { - Aesi512 m0 = -67602113121365, m1 = -70814915; - EXPECT_EQ(m0 / m1, 954631); - Aesi512 m2 = 15113324630360, m3 = 57523730; - EXPECT_EQ(m2 / m3, 262732); - Aesi512 m4 = 34122183947714, m5 = -44752342; - EXPECT_EQ(m4 / m5, -762467); - Aesi512 m6 = 2220619718304, m7 = -6807624; - EXPECT_EQ(m6 / m7, -326196); - Aesi512 m8 = -56544544247220, m9 = -64028010; - EXPECT_EQ(m8 / m9, 883122); - Aesi512 m10 = 27311885651556, m11 = 40063554; - EXPECT_EQ(m10 / m11, 681714); - Aesi512 m12 = 65477763597661, m13 = -85123723; - EXPECT_EQ(m12 / m13, -769207); - Aesi512 m14 = -40861948934173, m15 = -56440949; - EXPECT_EQ(m14 / m15, 723977); - Aesi512 m16 = 176062774875, m17 = -14641395; - EXPECT_EQ(m16 / m17, -12025); - Aesi512 m18 = -329952273599, m19 = -3832777; - EXPECT_EQ(m18 / m19, 86087); - Aesi512 m20 = -1088200002846, m21 = -1883706; - EXPECT_EQ(m20 / m21, 577691); - Aesi512 m22 = 6974639128232, m23 = -10309004; - EXPECT_EQ(m22 / m23, -676558); - Aesi512 m24 = 31834533607632, m25 = -55868976; - EXPECT_EQ(m24 / m25, -569807); - Aesi512 m26 = 31126617188568, m27 = -54848568; - EXPECT_EQ(m26 / m27, -567501); - Aesi512 m28 = 6290940249900, m29 = 21494628; - EXPECT_EQ(m28 / m29, 292675); - Aesi512 m30 = 42187650007176, m31 = -78019518; - EXPECT_EQ(m30 / m31, -540732); - Aesi512 m32 = -20062099158147, m33 = -64832101; - EXPECT_EQ(m32 / m33, 309447); - Aesi512 m34 = -9216212918125, m35 = 26711725; - EXPECT_EQ(m34 / m35, -345025); - Aesi512 m36 = -5364545160432, m37 = -31267749; - EXPECT_EQ(m36 / m37, 171568); - Aesi512 m38 = -19899125279059, m39 = 26608409; - EXPECT_EQ(m38 / m39, -747851); - Aesi512 m40 = -5126477678000, m41 = -7908790; - EXPECT_EQ(m40 / m41, 648200); - Aesi512 m42 = -54479717879628, m43 = -56742436; - EXPECT_EQ(m42 / m43, 960123); - Aesi512 m44 = -11035329100380, m45 = 85511380; - EXPECT_EQ(m44 / m45, -129051); - Aesi512 m46 = -77240330776750, m47 = 77342810; - EXPECT_EQ(m46 / m47, -998675); - Aesi512 m48 = -25940256135750, m49 = 32187375; - EXPECT_EQ(m48 / m49, -805914); - Aesi512 m50 = 68475350540736, m51 = -72959904; - EXPECT_EQ(m50 / m51, -938534); - Aesi512 m52 = -20926969579065, m53 = -77395215; - EXPECT_EQ(m52 / m53, 270391); - Aesi512 m54 = -1875340132380, m55 = -17179580; - EXPECT_EQ(m54 / m55, 109161); - Aesi512 m56 = -287061254477, m57 = -22981447; - EXPECT_EQ(m56 / m57, 12491); - Aesi512 m58 = -22187933279568, m59 = -49281768; - EXPECT_EQ(m58 / m59, 450226); - Aesi512 m60 = -979862770236, m61 = 2721327; - EXPECT_EQ(m60 / m61, -360068); - Aesi512 m62 = -1404488473664, m63 = -39927464; - EXPECT_EQ(m62 / m63, 35176); - Aesi512 m64 = -1465619419940, m65 = 26127452; - EXPECT_EQ(m64 / m65, -56095); - Aesi512 m66 = 49073567920942, m67 = 77753978; - EXPECT_EQ(m66 / m67, 631139); - Aesi512 m68 = 8897687795196, m69 = -49216686; - EXPECT_EQ(m68 / m69, -180786); - Aesi512 m70 = 6085886956392, m71 = -16070088; - EXPECT_EQ(m70 / m71, -378709); - Aesi512 m72 = 50224482468354, m73 = 75335443; - EXPECT_EQ(m72 / m73, 666678); - Aesi512 m74 = 7740677726208, m75 = 15847496; - EXPECT_EQ(m74 / m75, 488448); - Aesi512 m76 = 1063246222290, m77 = 8595570; - EXPECT_EQ(m76 / m77, 123697); - Aesi512 m78 = -10332555271144, m79 = 29755036; - EXPECT_EQ(m78 / m79, -347254); -} - -TEST(Division, MixedDivisionAssignment) { - Aesi512 m0 = -3174698500920, m1 = 37446314; - m0 /= m1; EXPECT_EQ(m0, -84780); - Aesi512 m2 = 156000466440, m3 = -66666866; - m2 /= m3; EXPECT_EQ(m2, -2340); - Aesi512 m4 = -9664086627036, m5 = -51407724; - m4 /= m5; EXPECT_EQ(m4, 187989); - Aesi512 m6 = 683516898168, m7 = 1805609; - m6 /= m7; EXPECT_EQ(m6, 378552); - Aesi512 m8 = -24751231123115, m9 = -89301431; - m8 /= m9; EXPECT_EQ(m8, 277165); - Aesi512 m10 = 26354396493600, m11 = -49311248; - m10 /= m11; EXPECT_EQ(m10, -534450); - Aesi512 m12 = -1203507178300, m13 = 67055225; - m12 /= m13; EXPECT_EQ(m12, -17948); - Aesi512 m14 = -9860315571000, m15 = -32244750; - m14 /= m15; EXPECT_EQ(m14, 305796); - Aesi512 m16 = -13210718718360, m17 = 32872297; - m16 /= m17; EXPECT_EQ(m16, -401880); - Aesi512 m18 = -1166273423250, m19 = 5292222; - m18 /= m19; EXPECT_EQ(m18, -220375); - Aesi512 m20 = -17154168020562, m21 = -32960958; - m20 /= m21; EXPECT_EQ(m20, 520439); - Aesi512 m22 = -24461813157015, m23 = -33125755; - m22 /= m23; EXPECT_EQ(m22, 738453); - Aesi512 m24 = -3915356462184, m25 = -67492182; - m24 /= m25; EXPECT_EQ(m24, 58012); - Aesi512 m26 = 6239712095136, m27 = 46955376; - m26 /= m27; EXPECT_EQ(m26, 132886); - Aesi512 m28 = -41815750742532, m29 = 55578484; - m28 /= m29; EXPECT_EQ(m28, -752373); - Aesi512 m30 = -58740024955500, m31 = -66670100; - m30 /= m31; EXPECT_EQ(m30, 881055); - Aesi512 m32 = 25823556551045, m33 = 37417039; - m32 /= m33; EXPECT_EQ(m32, 690155); - Aesi512 m34 = 5480709811479, m35 = -54757269; - m34 /= m35; EXPECT_EQ(m34, -100091); - Aesi512 m36 = -22711656353225, m37 = -79507295; - m36 /= m37; EXPECT_EQ(m36, 285655); - Aesi512 m38 = 12409303686885, m39 = 17897733; - m38 /= m39; EXPECT_EQ(m38, 693345); - Aesi512 m40 = 13872981907785, m41 = -36991955; - m40 /= m41; EXPECT_EQ(m40, -375027); - Aesi512 m42 = -643299920236, m43 = 67038341; - m42 /= m43; EXPECT_EQ(m42, -9596); - Aesi512 m44 = 3282278192935, m45 = 4741265; - m44 /= m45; EXPECT_EQ(m44, 692279); - Aesi512 m46 = -13386640546113, m47 = -57296749; - m46 /= m47; EXPECT_EQ(m46, 233637); - Aesi512 m48 = -368301167920, m49 = 12409069; - m48 /= m49; EXPECT_EQ(m48, -29680); - Aesi512 m50 = 4999702954272, m51 = -74294207; - m50 /= m51; EXPECT_EQ(m50, -67296); - Aesi512 m52 = -13934020168638, m53 = -18893766; - m52 /= m53; EXPECT_EQ(m52, 737493); - Aesi512 m54 = 18163193044176, m55 = 18950076; - m54 /= m55; EXPECT_EQ(m54, 958476); - Aesi512 m56 = -80852334667440, m57 = 82227173; - m56 /= m57; EXPECT_EQ(m56, -983280); - Aesi512 m58 = -13961168504878, m59 = -14066626; - m58 /= m59; EXPECT_EQ(m58, 992503); - Aesi512 m60 = 35163604583850, m61 = 77817450; - m60 /= m61; EXPECT_EQ(m60, 451873); - Aesi512 m62 = -71110375898000, m63 = 74848300; - m62 /= m63; EXPECT_EQ(m62, -950060); - Aesi512 m64 = -15288429937525, m65 = 45382825; - m64 /= m65; EXPECT_EQ(m64, -336877); - Aesi512 m66 = -34335775193105, m67 = 56421811; - m66 /= m67; EXPECT_EQ(m66, -608555); - Aesi512 m68 = -20503984546510, m69 = -22501931; - m68 /= m69; EXPECT_EQ(m68, 911210); - Aesi512 m70 = -37499367266592, m71 = 43862808; - m70 /= m71; EXPECT_EQ(m70, -854924); - Aesi512 m72 = 44304906945178, m73 = -47076238; - m72 /= m73; EXPECT_EQ(m72, -941131); - Aesi512 m74 = -39150837269096, m75 = 90134744; - m74 /= m75; EXPECT_EQ(m74, -434359); - Aesi512 m76 = -22502676678930, m77 = -89545785; - m76 /= m77; EXPECT_EQ(m76, 251298); - Aesi512 m78 = -34136928128166, m79 = -79394298; - m78 /= m79; EXPECT_EQ(m78, 429967); -} - -TEST(Division, DifferentPrecision) { - { - Aesi < 256 > first = 11921542526290; // Aesi<8 blocks> - Aesi < 352 > second = 88322770; // Aesi<11 blocks> - EXPECT_EQ(first / second, 134977); - - Aesi < 320 > third = -4102459315740; // Aesi<10 blocks> - Aesi < 448 > forth = 57049914; // Aesi<14 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 320 > first = 13488766159653; // Aesi<10 blocks> - Aesi < 352 > second = 48109389; // Aesi<11 blocks> - EXPECT_EQ(first / second, 280377); - - Aesi < 320 > third = -991821198108; // Aesi<10 blocks> - Aesi < 416 > forth = 4233378; // Aesi<13 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 480 > first = -73311512255046; // Aesi<15 blocks> - Aesi < 384 > second = 86942434; // Aesi<12 blocks> - EXPECT_EQ(first / second, -843219); - - Aesi < 224 > third = 721422850272; // Aesi<7 blocks> - Aesi < 416 > forth = 15138768; // Aesi<13 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 256 > first = 57155718149216; // Aesi<8 blocks> - Aesi < 256 > second = 80590001; // Aesi<8 blocks> - EXPECT_EQ(first / second, 709216); - - Aesi < 192 > third = 657315248892; // Aesi<6 blocks> - Aesi < 448 > forth = 4018458; // Aesi<14 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 224 > first = -24101170189740; // Aesi<7 blocks> - Aesi < 224 > second = -64694181; // Aesi<7 blocks> - EXPECT_EQ(first / second, 372540); - - Aesi < 288 > third = 27530629582832; // Aesi<9 blocks> - Aesi < 384 > forth = 49146568; // Aesi<12 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 448 > first = 10440263901354; // Aesi<14 blocks> - Aesi < 352 > second = -25782631; // Aesi<11 blocks> - EXPECT_EQ(first / second, -404934); - - Aesi < 192 > third = 49691966023092; // Aesi<6 blocks> - Aesi < 416 > forth = -57556284; // Aesi<13 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 416 > first = -19076120667460; // Aesi<13 blocks> - Aesi < 384 > second = 43657645; // Aesi<12 blocks> - EXPECT_EQ(first / second, -436948); - - Aesi < 224 > third = 3594292228818; // Aesi<7 blocks> - Aesi < 384 > forth = 8218869; // Aesi<12 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 192 > first = -80928002017452; // Aesi<6 blocks> - Aesi < 480 > second = -83298854; // Aesi<15 blocks> - EXPECT_EQ(first / second, 971538); - - Aesi < 256 > third = 17240509748020; // Aesi<8 blocks> - Aesi < 352 > forth = 35593090; // Aesi<11 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 192 > first = -34515574677948; // Aesi<6 blocks> - Aesi < 224 > second = 72218589; // Aesi<7 blocks> - EXPECT_EQ(first / second, -477932); - - Aesi < 320 > third = -14100957360246; // Aesi<10 blocks> - Aesi < 448 > forth = -35406678; // Aesi<14 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } - { - Aesi < 480 > first = -1093297575920; // Aesi<15 blocks> - Aesi < 448 > second = -22640248; // Aesi<14 blocks> - EXPECT_EQ(first / second, 48290); - - Aesi < 320 > third = 6343088533611; // Aesi<10 blocks> - Aesi < 352 > forth = 8322199; // Aesi<11 blocks> - forth /= third; EXPECT_EQ(forth, 0); - } -} - -TEST(Division, Huge) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 o0 = "2713006190353794843001574597263830299754718406554841786815057226557898480996304062155538953890163418239849100307320134528405798210465559594879025314495448."; - Aesi512 o1 = "11661561043881735325505841521207566651613627725292988229211140876317241794187341201621018221552442573993825724096572."; - EXPECT_EQ(o0 / o1, "232645199055677005273199249378767621034."); o0 /= o1; EXPECT_EQ(o0, "232645199055677005273199249378767621034."); - - Aesi512 o2 = "691657383591844216575014611357784034870295742903613141672512174103876528903985094696620754198093979498076876293271199527919688738035345736374122646767573."; - Aesi512 o3 = "2409602862744372806307702972540060975260544871590287474520202002693463055313506708820654306720331381850013047928613."; - EXPECT_EQ(o2 / o3, "287042065846524508523959704981051655921."); o2 /= o3; EXPECT_EQ(o2, "287042065846524508523959704981051655921."); - - Aesi512 o4 = "862961919221122926503864097354238936894245414515494708267585978566644549468173258415739298482605508015607858266296250399665996022362011764438685647463830."; - Aesi512 o5 = "5873557982994106495137882685361231858689698157978917893282787595467180282270338468781173472015561545927736172685733."; - EXPECT_EQ(o4 / o5, "146923197441769226692308450902282780510."); o4 /= o5; EXPECT_EQ(o4, "146923197441769226692308450902282780510."); - - Aesi512 o6 = "909751349496540626286980189308431084499585627279790605720322255669065341735403163846977171861141445150947510387797653148247515123747860052126284330722202."; - Aesi512 o7 = "15561991402458290936100771430419188589420359597137447746379656966063460915846460963239225132324610295230390971530646."; - EXPECT_EQ(o6 / o7, "58459828563639314156347669206282086087."); o6 /= o7; EXPECT_EQ(o6, "58459828563639314156347669206282086087."); - - Aesi512 o8 = "25421649421044648256410363130202797785188994860967155201171938294895129536230522888280666734235813067662201778838420766660088549887626676430980696267314."; - Aesi512 o9 = "3635380412137022286721052520386439723863526171105557476789276051209134573219745677378561810465517973946503152426611."; - EXPECT_EQ(o8 / o9, "6992844362634606375592076092630167174."); o8 /= o9; EXPECT_EQ(o8, "6992844362634606375592076092630167174."); - - Aesi512 o10 = "4361619760408996497482816148465856683316591740863630138805361794028625200167831013334690318241884915315786020088677636841530018945682288958019700858180466."; - Aesi512 o11 = "17946983294462140367128935734938575269994784724208162584309403592330215378458801492365395532452117805645008857836674."; - EXPECT_EQ(o10 / o11, "243028016956746794445631914777091679609."); o10 /= o11; EXPECT_EQ(o10, "243028016956746794445631914777091679609."); - - Aesi512 o12 = "726172394863842026643532276912271267238672837581228323321295912865133609218915008946525867688511388382156657375838968785133147950886472758607057067639120."; - Aesi512 o13 = "6963643245505486388144439615168604074915851162431054977755035976588546396925217547401715343982194118163867607903024."; - EXPECT_EQ(o12 / o13, "104280528060154758712170321968763807255."); o12 /= o13; EXPECT_EQ(o12, "104280528060154758712170321968763807255."); - - Aesi512 o14 = "32637388470827471839204303046929852595530011254668835976250067681125216485847721748866065534498675747447674611564141358897997618547017563533021511035442."; - Aesi512 o15 = "8495800752323116811536861037424141384042500227031207807221799280770094104642494244733378746232366201651484118711662."; - EXPECT_EQ(o14 / o15, "3841590618977617629417109808541334191."); o14 /= o15; EXPECT_EQ(o14, "3841590618977617629417109808541334191."); - - Aesi512 o16 = "403514851571224992074670700527580311336780227973409735836910807900593428188675071364886201637165760162827231591462548327739712932076634497379216374526440."; - Aesi512 o17 = "6733396156826693256195932070648508785650780701244861235797832783776481641285701279450526328066107183446532511729671."; - EXPECT_EQ(o16 / o17, "59927389117320698400617346497363047640."); o16 /= o17; EXPECT_EQ(o16, "59927389117320698400617346497363047640."); - - Aesi512 o18 = "703085916010877168634991995210897878816519373048746252351843657754538695917849101366670841844148739057835894511089554007299580165956308796215533574899140."; - Aesi512 o19 = "3996800316069871989396775978196722373576793944323962127524656845306336180885434055130830940605076849934807431146085."; - EXPECT_EQ(o18 / o19, "175912194858469840458518768984666656884."); o18 /= o19; EXPECT_EQ(o18, "175912194858469840458518768984666656884."); - - Aesi512 o20 = "1392867926917594562735059626659923877830375057197975395188418567307349366664595102034516267516986764104663372211421060509069899981135348323082900543783280."; - Aesi512 o21 = "15140392216976894545328794445234489480411523723344802715233457965502369948861382164443999932329525612133450561181640."; - EXPECT_EQ(o20 / o21, "91996819300082217353120817415886665502."); o20 /= o21; EXPECT_EQ(o20, "91996819300082217353120817415886665502."); - - Aesi512 o22 = "564664911237330892616831807680330160443386923150487476298016715746609924327673916961717376746712620215121947484077945564140076272773087875101286543329616."; - Aesi512 o23 = "4427829722673921894941501123797908019887127300578370497420583880233872474221991949803215803100919269031040076018448."; - EXPECT_EQ(o22 / o23, "127526338320059748007000295678516004517."); o22 /= o23; EXPECT_EQ(o22, "127526338320059748007000295678516004517."); - - Aesi512 o24 = "2006539653770390597793031370613294726129181121914524896685945102724092816717630062966580381936170851502671619596802895674775645206455524594180074181318290."; - Aesi512 o25 = "8753014661316809094787261020053253628573219286495039075648090426261494590517100527929867082773655162745489615312947."; - EXPECT_EQ(o24 / o25, "229239836948762233149436135193819596070."); o24 /= o25; EXPECT_EQ(o24, "229239836948762233149436135193819596070."); - - Aesi512 o26 = "1131754130677725278471408653546150324551716089888751281301023211466577625215152808590539680048962256290057307680274655381055747926576436370522930724973990."; - Aesi512 o27 = "7532806378389133345888841679648860985161470838383015575538102816646215263409191847447160680286644424674430036796270."; - EXPECT_EQ(o26 / o27, "150243358693595851456437409905437725637."); o26 /= o27; EXPECT_EQ(o26, "150243358693595851456437409905437725637."); - - Aesi512 o28 = "392045816913861384110182837670146014418158786910171049652511119443803771652897458446761792569998529744097588316928192249202690178014492498093321730695252."; - Aesi512 o29 = "7289150240379164352847466484948682652289378198225792835750634115753219010828372615066490117130487092093411611987078."; - EXPECT_EQ(o28 / o29, "53784845144510025644355972800071310734."); o28 /= o29; EXPECT_EQ(o28, "53784845144510025644355972800071310734."); - - Aesi512 o30 = "649151807305208322819075147378512799332754074950549894308035215843567142251955013904248736157323651065409018116947670181945408611850384784226346936909125."; - Aesi512 o31 = "14114873659930250008296013710596176333852853505711578625187785033492072690322254492516381480313827691754941847973375."; - EXPECT_EQ(o30 / o31, "45990621166382878432642770774474120379."); o30 /= o31; EXPECT_EQ(o30, "45990621166382878432642770774474120379."); - - Aesi512 o32 = "491513195360149037141858565175280208443700729028629069139985697787173466595101428221812992328592164336076448530404068636684386866516329284657504623321344."; - Aesi512 o33 = "2554046695314546944451784981669847873566566722812710372548737683298595173544983436313101217242797437402567900406728."; - EXPECT_EQ(o32 / o33, "192444874348554574856789385679904322848."); o32 /= o33; EXPECT_EQ(o32, "192444874348554574856789385679904322848."); - - Aesi512 o34 = "1750111615128054584071209571169512721812101352190946637938110753081617382339234788467719485061656096907148315690036457646746677201438110604897942230502345."; - Aesi512 o35 = "17583576419554686978419858424675588345342539289060158672542125590077526480096964009077379694043904132946027279265861."; - EXPECT_EQ(o34 / o35, "99531038132933883049213867009174302645."); o34 /= o35; EXPECT_EQ(o34, "99531038132933883049213867009174302645."); - - Aesi512 o36 = "975058314705345060304615149116899781753795322425846036902427477482509651452222506388525256460347290469421379642225502384220625878009064793990547328185220."; - Aesi512 o37 = "4709711523694740054104021806004566195987773630282623336315586126128147683851911129505467994549060052606350281875270."; - EXPECT_EQ(o36 / o37, "207031430651280684176356796387804025686."); o36 /= o37; EXPECT_EQ(o36, "207031430651280684176356796387804025686."); - - Aesi512 o38 = "1424332986368404409944310221477738117356487171558651898706383584604542338320396149762082436191242347159948952981047537355884297272057017655564953647383312."; - Aesi512 o39 = "5398100402588307676844060457667058824456130242156306208509550786794035241114781897022580844578292097188483328808084."; - EXPECT_EQ(o38 / o39, "263858187166259123024781973845635300468."); o38 /= o39; EXPECT_EQ(o38, "263858187166259123024781973845635300468."); - -#ifdef NDEBUG - Logging::addRecord("Division", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/arithmetic/division/signed.cpp b/test/arithmetic/division/signed.cpp new file mode 100755 index 0000000..698a8ab --- /dev/null +++ b/test/arithmetic/division/signed.cpp @@ -0,0 +1,72 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Division, Basic) { + Aesi128 one = 1, mOne = -1, zero = 0, ten = 10, two = 2; + EXPECT_EQ(one / mOne, -1); + EXPECT_EQ(one / zero, 0); + EXPECT_EQ(one / ten, 0); + EXPECT_EQ(one / two, 0); + EXPECT_EQ(mOne / zero, 0); + EXPECT_EQ(mOne / ten, 0); + EXPECT_EQ(mOne / two, 0); + EXPECT_EQ(zero / ten, 0); + EXPECT_EQ(zero / two, 0); + EXPECT_EQ(ten / two, 5); + + EXPECT_EQ(two / ten, 0); + EXPECT_EQ(two / zero, 0); + EXPECT_EQ(two / mOne, -2); + EXPECT_EQ(two / one, 2); + EXPECT_EQ(ten / zero, 0); + EXPECT_EQ(ten / mOne, -10); + EXPECT_EQ(ten / one, 10); + EXPECT_EQ(zero / mOne, 0); + EXPECT_EQ(zero / one, 0); + EXPECT_EQ(mOne / one, -1); +} + +TEST(Signed_Division, Huge) { + constexpr auto testsAmount = 128, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + int first, second; + switch(i % 4) { + case 0: + first = 1, second = 1; break; + case 1: + first = -1, second = -1; break; + case 2: + first = -1, second = 1; break; + default: + first = 1, second = -1; + } + const auto l = first * Generation::getRandomWithBits(blocksNumber * 32 - 110), + r = second * Generation::getRandomWithBits(blocksNumber * 16 - 110); + + Aesi lA = l, rA = r; + if(first == 1) { + EXPECT_EQ(lA / rA, l / r ); + lA /= rA; + EXPECT_EQ(lA, l / r); + } else { + auto result = -1 * ((l * -1) / r); // Cryptopp thank you!!! + EXPECT_EQ(lA / rA, result); + lA /= rA; + EXPECT_EQ(lA, result); + } + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto mod = Generation::getRandom(); + + Aesi aeu = value; + EXPECT_EQ(aeu / mod, value / mod); + + aeu /= mod; + EXPECT_EQ(aeu, value / mod); + } +} \ No newline at end of file diff --git a/test/arithmetic/division/unsigned.cpp b/test/arithmetic/division/unsigned.cpp new file mode 100755 index 0000000..1283b40 --- /dev/null +++ b/test/arithmetic/division/unsigned.cpp @@ -0,0 +1,37 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Division, Basic) { + Aeu128 one = 1u, zero = 0u, ten = 10u, two = 2u; + EXPECT_EQ(zero / one, zero); + EXPECT_EQ(ten / two, 5u); + EXPECT_EQ(two / ten, 0u); +} + +TEST(Unsigned_Division, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 5), + r = Generation::getRandomWithBits(blocksNumber * 16 - 32); + + Aeu lA = l, rA = r; + EXPECT_EQ(lA / rA, l / r); + + lA /= rA; + EXPECT_EQ(lA, l / r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 10); + const auto subU = Generation::getRandom(); + + Aeu aeu = value; + EXPECT_EQ(aeu / subU, value / subU); + + aeu /= subU; + EXPECT_EQ(aeu, value / subU); + } +} \ No newline at end of file diff --git a/test/arithmetic/modulo.cpp b/test/arithmetic/modulo.cpp deleted file mode 100644 index ebc7fd4..0000000 --- a/test/arithmetic/modulo.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Modulo, MixedModulo) { - Aesi512 m0 = -4825285950739, m1 = -26462400; - EXPECT_EQ(m0 % m1, -26085139); - Aesi512 m2 = -15187820465943, m3 = -73508543; - EXPECT_EQ(m2 % m3, -73379627); - Aesi512 m4 = 29744669116783, m5 = -59738688; - EXPECT_EQ(m4 % m5, 59497327); - Aesi512 m6 = 1445481773735, m7 = -10943575; - EXPECT_EQ(m6 % m7, 10613435); - Aesi512 m8 = -9608444938718, m9 = -14443665; - EXPECT_EQ(m8 % m9, -13452443); - Aesi512 m10 = -1827101039843, m11 = -5476397; - EXPECT_EQ(m10 % m11, -5232336); - Aesi512 m12 = -8555190917773, m13 = 26131496; - EXPECT_EQ(m12 % m13, -442333); - Aesi512 m14 = 3835023546766, m15 = -66353339; - EXPECT_EQ(m14 % m15, 65965922); - Aesi512 m16 = 4152238729728, m17 = 70516764; - EXPECT_EQ(m16 % m17, 115116); - Aesi512 m18 = 21152437469773, m19 = 27580050; - EXPECT_EQ(m18 % m19, 862423); - Aesi512 m20 = -16788008144183, m21 = 74026418; - EXPECT_EQ(m20 % m21, -964471); - Aesi512 m22 = -28451749301697, m23 = 53230588; - EXPECT_EQ(m22 % m23, -15697); - Aesi512 m24 = -3270181161316, m25 = -8281687; - EXPECT_EQ(m24 % m25, -7979000); - Aesi512 m26 = 49633340100976, m27 = 66209125; - EXPECT_EQ(m26 % m27, 590351); - Aesi512 m28 = -46340911398101, m29 = -51209841; - EXPECT_EQ(m28 % m29, -50870540); - Aesi512 m30 = 185622644633, m31 = 9521052; - EXPECT_EQ(m30 % m31, 214841); - Aesi512 m32 = -10811475069954, m33 = 59784751; - EXPECT_EQ(m32 % m33, -699114); - Aesi512 m34 = 12380907605205, m35 = 15918898; - EXPECT_EQ(m34 % m35, 604603); - Aesi512 m36 = 1257249026383, m37 = -61467173; - EXPECT_EQ(m36 % m37, 60937014); - Aesi512 m38 = 61847752758018, m39 = -72413117; - EXPECT_EQ(m38 % m39, 71593903); - Aesi512 m40 = -37469111279132, m41 = 74062214; - EXPECT_EQ(m40 % m41, -345536); - Aesi512 m42 = -31033946342900, m43 = 31210566; - EXPECT_EQ(m42 % m43, -935894); - Aesi512 m44 = 262286204362, m45 = 1046069; - EXPECT_EQ(m44 % m45, 93647); - Aesi512 m46 = -38784099239147, m47 = -66593692; - EXPECT_EQ(m46 % m47, -66205731); - Aesi512 m48 = -49611834841836, m49 = 50734228; - EXPECT_EQ(m48 % m49, -167880); - Aesi512 m50 = -5264331698408, m51 = -13698889; - EXPECT_EQ(m50 % m51, -13042376); - Aesi512 m52 = 8207558345771, m53 = 29861083; - EXPECT_EQ(m52 % m53, 794557); - Aesi512 m54 = 13581825744423, m55 = 71047285; - EXPECT_EQ(m54 % m55, 460113); - Aesi512 m56 = -10767453796459, m57 = 85680382; - EXPECT_EQ(m56 % m57, -190519); - Aesi512 m58 = -7637085665123, m59 = 12026053; - EXPECT_EQ(m58 % m59, -837738); - Aesi512 m60 = 11626011187006, m61 = 13548218; - EXPECT_EQ(m60 % m61, 808628); - Aesi512 m62 = -23116846973385, m63 = 70653532; - EXPECT_EQ(m62 % m63, -452433); - Aesi512 m64 = -10189597866429, m65 = 39212175; - EXPECT_EQ(m64 % m65, -495279); - Aesi512 m66 = 35873994210322, m67 = 66136687; - EXPECT_EQ(m66 % m67, 174408); - Aesi512 m68 = 4535653103788, m69 = 13603381; - EXPECT_EQ(m68 % m69, 207387); - Aesi512 m70 = 9262614882707, m71 = -68228371; - EXPECT_EQ(m70 % m71, 67692489); - Aesi512 m72 = -25362332495829, m73 = 31704461; - EXPECT_EQ(m72 % m73, -169808); - Aesi512 m74 = 46943441312445, m75 = -56547122; - EXPECT_EQ(m74 % m75, 56324437); - Aesi512 m76 = 6397582511119, m77 = 12738858; - EXPECT_EQ(m76 % m77, 634939); - Aesi512 m78 = -10713134329789, m79 = -20339953; - EXPECT_EQ(m78 % m79, -20064830); -} - -TEST(Modulo, MixedModuloAssignment) { - Aesi512 m0 = 347971189167, m1 = -10468158; - m0 %= m1; EXPECT_EQ(m0, 9617247); - Aesi512 m2 = 82299524104295, m3 = -85161108; - m2 %= m3; EXPECT_EQ(m2, 84816419); - Aesi512 m4 = 15733272660162, m5 = 58445417; - m4 %= m5; EXPECT_EQ(m4, 185430); - Aesi512 m6 = 21441802118831, m7 = 32445743; - m6 %= m7; EXPECT_EQ(m6, 411538); - Aesi512 m8 = -225797197700, m9 = -791578; - m8 %= m9; EXPECT_EQ(m8, -364778); - Aesi512 m10 = 37158981415510, m11 = -85944342; - m10 %= m11; EXPECT_EQ(m10, 85708390); - Aesi512 m12 = -84978103484, m13 = -1337355; - m12 %= m13; EXPECT_EQ(m12, -1229429); - Aesi512 m14 = -36479221879833, m15 = -57772210; - m14 %= m15; EXPECT_EQ(m14, -57547323); - Aesi512 m16 = 19799281452078, m17 = -88989537; - m16 %= m17; EXPECT_EQ(m16, 88354485); - Aesi512 m18 = 62544905852708, m19 = 88569191; - m18 %= m19; EXPECT_EQ(m18, 244238); - Aesi512 m20 = 10563516105678, m21 = 33470367; - m20 %= m21; EXPECT_EQ(m20, 517542); - Aesi512 m22 = 14792471248628, m23 = 16633406; - m22 %= m23; EXPECT_EQ(m22, 724490); - Aesi512 m24 = -4474855045896, m25 = 30121937; - m24 %= m25; EXPECT_EQ(m24, -329050); - Aesi512 m26 = -67695068629974, m27 = 68710890; - m26 %= m27; EXPECT_EQ(m26, -427734); - Aesi512 m28 = -26367812003697, m29 = 89576749; - m28 %= m29; EXPECT_EQ(m28, -168057); - Aesi512 m30 = -73884520718086, m31 = 78543985; - m30 %= m31; EXPECT_EQ(m30, -540241); - Aesi512 m32 = 27121633606354, m33 = 33856377; - m32 %= m33; EXPECT_EQ(m32, 975571); - Aesi512 m34 = 7643784867640, m35 = 8394625; - m34 %= m35; EXPECT_EQ(m34, 311515); - Aesi512 m36 = 20823365064094, m37 = -26717860; - m36 %= m37; EXPECT_EQ(m36, 26055154); - Aesi512 m38 = 32317724233551, m39 = -42171193; - m38 %= m39; EXPECT_EQ(m38, 41333966); - Aesi512 m40 = -79175100071807, m41 = 86660675; - m40 %= m41; EXPECT_EQ(m40, -856957); - Aesi512 m42 = 49371377679669, m43 = -72600911; - m42 %= m43; EXPECT_EQ(m42, 71965962); - Aesi512 m44 = 4496522629453, m45 = -38748432; - m44 %= m45; EXPECT_EQ(m44, 38334877); - Aesi512 m46 = -56997212920295, m47 = 88560132; - m46 %= m47; EXPECT_EQ(m46, -525227); - Aesi512 m48 = 21973208639078, m49 = 86842729; - m48 %= m49; EXPECT_EQ(m48, 819311); - Aesi512 m50 = 14554092528935, m51 = 25879784; - m50 %= m51; EXPECT_EQ(m50, 761503); - Aesi512 m52 = 37798099783123, m53 = 48852995; - m52 %= m53; EXPECT_EQ(m52, 168678); - Aesi512 m54 = 57333872564438, m55 = -59196307; - m54 %= m55; EXPECT_EQ(m54, 58971579); - Aesi512 m56 = 71400434364443, m57 = 89222326; - m56 %= m57; EXPECT_EQ(m56, 315965); - Aesi512 m58 = -15529620519738, m59 = 70288538; - m58 %= m59; EXPECT_EQ(m58, -645480); - Aesi512 m60 = 19311829893256, m61 = -36260355; - m60 %= m61; EXPECT_EQ(m60, 36204871); - Aesi512 m62 = 21676016617116, m63 = 75122829; - m62 %= m63; EXPECT_EQ(m62, 414627); - Aesi512 m64 = -1999725666682, m65 = -4655668; - m64 %= m65; EXPECT_EQ(m64, -4524650); - Aesi512 m66 = -13442336259545, m67 = -79617243; - m66 %= m67; EXPECT_EQ(m66, -79420397); - Aesi512 m68 = 7141387217361, m69 = 18976547; - m68 %= m69; EXPECT_EQ(m68, 214492); - Aesi512 m70 = -70624997799901, m71 = -78849999; - m70 %= m71; EXPECT_EQ(m70, -78745588); - Aesi512 m72 = -848542427966, m73 = -1009884; - m72 %= m73; EXPECT_EQ(m72, -525458); - Aesi512 m74 = -18916578704681, m75 = 78085076; - m74 %= m75; EXPECT_EQ(m74, -533225); - Aesi512 m76 = 36446022312946, m77 = -64759312; - m76 %= m77; EXPECT_EQ(m76, 64353154); - Aesi512 m78 = 37344597379618, m79 = 79024810; - m78 %= m79; EXPECT_EQ(m78, 967538); -} - -TEST(Modulo, DifferentPrecision) { - { - Aesi < 384 > first = "-9212123903380763278101201131077887055248270472066703026833951090289752111125710803750532800554307780355950233624499."; - Aesi < 384 > second = "-37087789512414492205196779606086372414501194510707902956528508145980596721567."; - EXPECT_EQ(first % second, "-9052785355585321901678007264182200660636851749985107144462309299294274871465."); - - Aesi512 third = "12089899034527593196140344328636122649910515780008608308617745290839686195645435400927167283773708549570445484997504."; - Aesi < 384 > forth = "38791081228502430712295259601297978608185027799939115358486031550869170231270."; - third %= forth; EXPECT_EQ(third, "8229687390510874391492419228200312885571290359808778645138412734611230783154."); - } - { - Aesi < 480 > first = "25414663572306423936490250923572266652416682314002638641807901374746684688007267878261403919132312814374630716851907."; - Aesi < 352 > second = "-57748043104944908853467289109093066086320028315245852872075560040678510723143."; - EXPECT_EQ(first % second, "7811518141519210546951227708961227216767377145666525439039853091819876995170."); - - Aesi < 448 > third = "22757490737086579577394309223959070847014595257477270224373020007725779776762142727489192667823520369419737745918275."; - Aesi < 320 > forth = "-77937983826943278060297401266069340866369983469857999581207368639217128209499."; - third %= forth; EXPECT_EQ(third, "50072887114738719811992856366839041528849040372290680330692851276184261984500."); - } - { - Aesi < 448 > first = "-14440547008645304188997321069862130815751971449927948904946175806842433185837031351222212459083146785238909192902275."; - Aesi < 320 > second = "112243590895343647310811440527884338254586019129397908671896596052123913308399."; - EXPECT_EQ(first % second, "-105207684422391308462667250571554459875195292666975849711787192697916843753745."); - - Aesi < 416 > third = "-10268949206820969989650611477721896714787377575245565315296992625964313634488310621397554691862059871720214276194032."; - Aesi < 256 > forth = "-97915859798192899741146385835304197695884521475350318896921504856785445282710."; - third %= forth; EXPECT_EQ(third, "-21354871838365052150982584642258077127963991294614846633906216571672069408642."); - } - { - Aesi < 448 > first = "1032860400567937369294772897465672303081805162378681352688737456777397449446292230974770359450531789943904891108387."; - Aesi < 256 > second = "49992660152609979714616642494208374242393532898305184801038884289201332944987."; - EXPECT_EQ(first % second, "113339249487640625811812408254081423215075210215409887918689878459009614131."); - - Aesi < 480 > third = "10980211111151232730221827844457700856371004188825896750254777877040050084717142885525432167659985530456887665107732."; - Aesi < 288 > forth = "111621867721925962090303827881892225819466844466429605168925336016810664659780."; - third %= forth; EXPECT_EQ(third, "44381282469867310094177193417659636271343100057435928554900709821497673605152."); - } - { - Aesi < 448 > first = "-25312179451839675712380043563674090495413264683538724166215812895403185336921532657434465273628749843184136930807580."; - Aesi < 256 > second = "-13895025758207086054244308634159781036094931846266326751823269030546314855586."; - EXPECT_EQ(first % second, "-201748163201676557356245742421857800785977779813132610985415626669522669092."); - - Aesi < 416 > third = "-2317827191029444904787826232969645717508041352748511323648884219838964298888609893452064919399820318106223227173844."; - Aesi < 320 > forth = "8436753361943231389439346120724592165859648921557619449921495675330933425699."; - third %= forth; EXPECT_EQ(third, "-2263846971461383090136249614950370347898202632502562196203041317425754139606."); - } - { - Aesi512 first = "31244392556242193721445195543558932714691196546472353207928976569317835494440164003717806353246559324551981369843869."; - Aesi < 384 > second = "112655450252104889127696699479658308940753477957066554290717216582011363805116."; - EXPECT_EQ(first % second, "12345422148729111675954511994026012126840701016415285005720252426519703009925."); - - Aesi < 384 > third = "-109140342621221363471153771322382958301489183498408786342767976384318181205816199407011529603128663344781669905628."; - Aesi < 288 > forth = "-75892564242748082637611017838729600362288292764818468621370824333290922949383."; - third %= forth; EXPECT_EQ(third, "-70926535546088036262298176982017305013465936388853829442915816024123147606474."); - } - { - Aesi < 384 > first = "-28369946867488170055671205491826488365803381329638654051798981143787271497672096395411274222232984227455180006372868."; - Aesi < 256 > second = "50869792556243205506291616301118960727198628942580629046575048241139947195320."; - EXPECT_EQ(first % second, "-5300589201189115965645598494258157144445538457811986299293419485426972890868."); - - Aesi < 448 > third = "2007239891649539723191422951266448511743117164767402034827412248055153401146597539085381864969696749809063896624858."; - Aesi < 288 > forth = "-30823171253870387123979167629666532829308854120927969018392818887298177506474."; - third %= forth; EXPECT_EQ(third, "16818192648133960168125890848363499312578421253764243840705735777959142558534."); - } - { - Aesi < 480 > first = "18401784329762856598409454200368774170003833871662814584097362056242378565769588367902877940864902578881991115004039."; - Aesi < 352 > second = "109146620508541400731363919556439697970404771684009134024160960730813195563451."; - EXPECT_EQ(first % second, "59062318667871312439029780554739593471079465958987683296021934946388679263920."); - - Aesi < 416 > third = "-6269512436411102690352587190692204852716188403995915713384495919931337525940639612612950219904620161855090128450306."; - Aesi < 288 > forth = "103817385037534075520242607790864340548028903204102817176165192185569351086737."; - third %= forth; EXPECT_EQ(third, "-5370583930034390280524814130445256149197679585696656312308038931817196793102."); - } - { - Aesi < 448 > first = "-15809470961307875686900914101691535179028188048740623626775500132444594667772158915089086882184961833896937757697518."; - Aesi < 352 > second = "-55637352332499955585093674745884423921382906037056045925844302017211169047179."; - EXPECT_EQ(first % second, "-2618350721932096066273996677127790516943984555887062896398971595895395989801."); - - Aesi < 448 > third = "-533079177926794179257261659652505711444679644908658230707697657135068057932350373496071031312272808107935093829461."; - Aesi < 320 > forth = "-59508398298085357125846173095202557527114876375603676425011417164862105407439."; - third %= forth; EXPECT_EQ(third, "-85404996746367892246051259587090408338841652256247697076697106516788249173."); - } - { - Aesi < 384 > first = "-36583676311863234784357950896068621336718336700978459059373589557061144517325459533454086638519471788560272064006479."; - Aesi < 256 > second = "12357806850776818332841004196660059289899452652284173242333290284856306917298."; - EXPECT_EQ(first % second, "-7546961048141504531649148628520554208233034929255061220239509820294525628715."); - - Aesi512 third = "29272051253423958896544921736048012129706170514888662826161006110021915492709160102383017123215486139604235442614027."; - Aesi < 288 > forth = "-62731245046001680312430732227512103478313587961638610237569835747267981007697."; - third %= forth; EXPECT_EQ(third, "37269649534141699019542914304358347533220752508841119952650366538322887929711."); - } -} - -TEST(Modulo, Huge) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 o0 = "409500603940670545537551287796342541477788606852461036351697131464175962962845171905572635924624049942630184447440898508507588051822633537161798509461250."; - Aesi512 o1 = "10261006895462786798066807577829165719."; - EXPECT_EQ(o0 % o1, "7497189308736801177714364072477269726."); o0 %= o1; EXPECT_EQ(o0, "7497189308736801177714364072477269726."); - - Aesi512 o2 = "3886411772506028221227877545626782790074712740712553207205545966324480930589712753901017430541974158930992947273912583719658305944138848039654435813751038."; - Aesi512 o3 = "44096160074129786340066812371492655363."; - EXPECT_EQ(o2 % o3, "20727140241842290502169830885947155782."); o2 %= o3; EXPECT_EQ(o2, "20727140241842290502169830885947155782."); - - Aesi512 o4 = "5782112607144331445913519101823821390836357661493880199113633328285711461417518241649866161455224635233300522624220946448998880164188304554140297509893037."; - Aesi512 o5 = "186990788979412509144995548940300654866."; - EXPECT_EQ(o4 % o5, "12306435039372636481765829227078211559."); o4 %= o5; EXPECT_EQ(o4, "12306435039372636481765829227078211559."); - - Aesi512 o6 = "2843367156814186681542379218890611049194003988673027820663942011295378309145895243790785406022245564376536475556957271004080525636638225062568533884101072."; - Aesi512 o7 = "228636154598164644322391966513151458997."; - EXPECT_EQ(o6 % o7, "194355276045908173211405259771300174660."); o6 %= o7; EXPECT_EQ(o6, "194355276045908173211405259771300174660."); - - Aesi512 o8 = "5268624167917989426050251946214907727544521871316281653054093634261481666781354471840456657534844285146243659351531171776807117198814130432780172839819510."; - Aesi512 o9 = "262920781462421681850649216248130035430."; - EXPECT_EQ(o8 % o9, "224316096031665473488622865469212905010."); o8 %= o9; EXPECT_EQ(o8, "224316096031665473488622865469212905010."); - - Aesi512 o10 = "3255796819162371772904139044318827357967373867885413075708573651599340942456720610736045929439330946266098941387425056080719071520970968310702255644695028."; - Aesi512 o11 = "259009686937591867471923336259624583741."; - EXPECT_EQ(o10 % o11, "158827090753501984610230418806072355711."); o10 %= o11; EXPECT_EQ(o10, "158827090753501984610230418806072355711."); - - Aesi512 o12 = "1937377249121786152288673920996562706638298937149225729800615065636170823578002251140359176671629015890726222367167405797638750093707880654269403751319963."; - Aesi512 o13 = "264527922677648264750359572855100885."; - EXPECT_EQ(o12 % o13, "154942033182658075561332168883657608."); o12 %= o13; EXPECT_EQ(o12, "154942033182658075561332168883657608."); - - Aesi512 o14 = "1004619018110078573146586018714489307479676958048469894762326056956188302698266541490825190187971837893626477831382913310677130751537651231741654765057804."; - Aesi512 o15 = "78604148911840414524739578695508301374."; - EXPECT_EQ(o14 % o15, "2673893063474941930634501880419379360."); o14 %= o15; EXPECT_EQ(o14, "2673893063474941930634501880419379360."); - - Aesi512 o16 = "2968308201678225070789020661140137670353545701927900382857175964818890203445515853740569959700311024105611455539739145781359705351814009021402824580191694."; - Aesi512 o17 = "102335699045058185986847295724245368593."; - EXPECT_EQ(o16 % o17, "83018314434645209561389061119121391269."); o16 %= o17; EXPECT_EQ(o16, "83018314434645209561389061119121391269."); - - Aesi512 o18 = "6399223173495461022814389622224888155709137194509163748069011262368265881242332077276505334097101129630929712761185904867738790983108455519052748667822324."; - Aesi512 o19 = "323647146437674715682665224889038002887."; - EXPECT_EQ(o18 % o19, "295772928839849326058916007422140572613."); o18 %= o19; EXPECT_EQ(o18, "295772928839849326058916007422140572613."); - - Aesi512 o20 = "6575890394347046165268210624739882837600890257472722546904136362203033023854575209766241340128025210889225150005208977548836726881179415009099311192797015."; - Aesi512 o21 = "168376457763065705046441976475060762246."; - EXPECT_EQ(o20 % o21, "155352949924991062968278479623860679005."); o20 %= o21; EXPECT_EQ(o20, "155352949924991062968278479623860679005."); - - Aesi512 o22 = "4041789371535566240417701768508927524915551543709807836289714165726516264092034971407694450602438130381275260327868337897367753156151007095214720873052399."; - Aesi512 o23 = "123374323747828929507911544081484071237."; - EXPECT_EQ(o22 % o23, "13320076866500736646281629579480866720."); o22 %= o23; EXPECT_EQ(o22, "13320076866500736646281629579480866720."); - - Aesi512 o24 = "590869823402819086989170628687010150951691926308152736817633991948600085446047537496411979552821752174491137647422974798297797197624832652578926636605930."; - Aesi512 o25 = "314553084668450361630418155239078801123."; - EXPECT_EQ(o24 % o25, "220287220658243788130402890302396016445."); o24 %= o25; EXPECT_EQ(o24, "220287220658243788130402890302396016445."); - - Aesi512 o26 = "1255347790745621962558443760354458476033096824995022913344089590443998331465310225325616786089254163138528065491459202824356793472756199799206396239679459."; - Aesi512 o27 = "218355050285715746012411800450761028105."; - EXPECT_EQ(o26 % o27, "24761501791080241662542463171241123689."); o26 %= o27; EXPECT_EQ(o26, "24761501791080241662542463171241123689."); - - Aesi512 o28 = "4381496889340101805506525945483709074356222961676263171524797959684865493014817513528842471387653457839322714274888410560424445186746292816603977255073914."; - Aesi512 o29 = "213646455571661215597944392522675211455."; - EXPECT_EQ(o28 % o29, "11293812890720308297039503199609002539."); o28 %= o29; EXPECT_EQ(o28, "11293812890720308297039503199609002539."); - - Aesi512 o30 = "333867399274973622550994403766046829963885836018123458264166484573394379157213306412994521506872094126340500566748952725955867119701609638561645349313850."; - Aesi512 o31 = "254770913098881001110999644381084874607."; - EXPECT_EQ(o30 % o31, "24905172009758338194804279867673180189."); o30 %= o31; EXPECT_EQ(o30, "24905172009758338194804279867673180189."); - - Aesi512 o32 = "4153957660216755241712750834150411661035298295206729249711442788183588355380702666847500257892872704424548402482292801439719912730182796069865834062254139."; - Aesi512 o33 = "35172699062374537619339059626016156514."; - EXPECT_EQ(o32 % o33, "11916123947850557221344759305315357637."); o32 %= o33; EXPECT_EQ(o32, "11916123947850557221344759305315357637."); - - Aesi512 o34 = "6564694609793748905027852014916558493090912779101388542515970857992202876322747849605134933014988255333082800961843126101195762330518076934117865523730038."; - Aesi512 o35 = "246242350222197521652120611865691858177."; - EXPECT_EQ(o34 % o35, "103632595141445024701649882083556357692."); o34 %= o35; EXPECT_EQ(o34, "103632595141445024701649882083556357692."); - - Aesi512 o36 = "5312195220127511325547902706779167794285142602042722851112237562160335575848449548077927679780286915630540657371591170037296964978376150839519336050273863."; - Aesi512 o37 = "178934842548515544690430019499484966948."; - EXPECT_EQ(o36 % o37, "142334313754817206394898080858138985023."); o36 %= o37; EXPECT_EQ(o36, "142334313754817206394898080858138985023."); - - Aesi512 o38 = "1401047116413257578346839568879405361213132567894990121171733539467157022041516175484487632432100930077579116773399387005960318967953549095134207067150841."; - Aesi512 o39 = "151246567336848655594742713804671303477."; - EXPECT_EQ(o38 % o39, "56129243505051103512160725382779920784."); o38 %= o39; EXPECT_EQ(o38, "56129243505051103512160725382779920784."); - -#ifdef NDEBUG - Logging::addRecord("Modulo", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/arithmetic/modulo/signed.cpp b/test/arithmetic/modulo/signed.cpp new file mode 100755 index 0000000..846e088 --- /dev/null +++ b/test/arithmetic/modulo/signed.cpp @@ -0,0 +1,55 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Modulo, Basic) { + Aesi128 one = 1u, mOne = -1, zero = 0u, ten = 10u, two = 2u; + EXPECT_EQ(one % mOne, 0); + EXPECT_EQ(one % zero, 1); + EXPECT_EQ(one % ten, 1); + EXPECT_EQ(one % two, 1); + EXPECT_EQ(mOne % zero, -1); + EXPECT_EQ(mOne % ten, -1); + EXPECT_EQ(mOne % two, -1); + EXPECT_EQ(zero % ten, 0); + EXPECT_EQ(zero % two, 0); + EXPECT_EQ(ten % two, 0); + + EXPECT_EQ(two % ten, 2); + EXPECT_EQ(two % zero, 2); + EXPECT_EQ(two % mOne, 0); + EXPECT_EQ(two % one, 0); + EXPECT_EQ(ten % zero, 10); + EXPECT_EQ(ten % mOne, 0); + EXPECT_EQ(ten % one, 0); + EXPECT_EQ(zero % mOne, 0); + EXPECT_EQ(zero % one, 0); + EXPECT_EQ(mOne % one, 0); +} + +TEST(Signed_Modulo, Huge) { + constexpr auto testsAmount = 128, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 110), + r = Generation::getRandomWithBits(blocksNumber * 16 - 110); + + Aesi lA = l, rA = r; + EXPECT_EQ(lA % rA, l % r); + + lA %= rA; + EXPECT_EQ(lA, l % r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto mod = Generation::getRandom(); + + Aesi aesi = value; + EXPECT_EQ(aesi % mod, value % mod); + + aesi %= mod; aesi %= mod; + EXPECT_EQ(aesi, value % mod); + } +} \ No newline at end of file diff --git a/test/arithmetic/modulo/unsigned.cpp b/test/arithmetic/modulo/unsigned.cpp new file mode 100755 index 0000000..610688b --- /dev/null +++ b/test/arithmetic/modulo/unsigned.cpp @@ -0,0 +1,39 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Modulo, Basic) { + Aeu128 one = 1u, zero = 0u, ten = 10u, two = 2u; + EXPECT_EQ(zero % one, zero); + EXPECT_EQ(ten % two, 0u); + EXPECT_EQ(two % ten, 2u); + EXPECT_EQ(ten % one, 0u); + EXPECT_EQ(one % ten, 1u); +} + +TEST(Unsigned_Modulo, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 5), + r = Generation::getRandomWithBits(blocksNumber * 16 - 32); + + Aeu lA = l, rA = r; + EXPECT_EQ(lA % rA, l % r); + + lA %= rA; + EXPECT_EQ(lA, l % r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto mod = Generation::getRandom(); + + Aeu aeu = value; + EXPECT_EQ(aeu % mod, value % mod); + + aeu %= mod; + EXPECT_EQ(aeu, value % mod); + } +} \ No newline at end of file diff --git a/test/arithmetic/multiplication.cpp b/test/arithmetic/multiplication.cpp deleted file mode 100644 index 0492e8f..0000000 --- a/test/arithmetic/multiplication.cpp +++ /dev/null @@ -1,625 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Multiplication, ZeroOne) { - Aesi512 zero = 0, one = 1; - Aesi512 m0 = 10919396; - EXPECT_EQ(m0 * 0, 0); - EXPECT_EQ(0 * m0, 0); - EXPECT_EQ(m0 * 1, 10919396); - EXPECT_EQ(1 * m0, 10919396); - EXPECT_EQ(m0 * -1, -10919396); - EXPECT_EQ(-1 * m0, -10919396); - - EXPECT_EQ(m0 * zero, 0); - EXPECT_EQ(m0 * -zero, 0); - EXPECT_EQ(m0 * +zero, 0); - EXPECT_EQ(m0 * one, 10919396); - EXPECT_EQ(m0 * -one, -10919396); - EXPECT_EQ(m0 * +one, 10919396); - - EXPECT_EQ(zero * m0, 0); - EXPECT_EQ(zero * -m0, 0); - EXPECT_EQ(zero * +m0, 0); - EXPECT_EQ(one * m0, 10919396); - EXPECT_EQ(one * -m0, -10919396); - EXPECT_EQ(one * +m0, 10919396); - - EXPECT_EQ(+zero * m0, 0); - EXPECT_EQ(+zero * -m0, 0); - EXPECT_EQ(+zero * +m0, 0); - EXPECT_EQ(+one * m0, 10919396); - EXPECT_EQ(+one * -m0, -10919396); - EXPECT_EQ(+one * +m0, 10919396); - - EXPECT_EQ(-zero * m0, 0); - EXPECT_EQ(-zero * -m0, 0); - EXPECT_EQ(-zero * +m0, 0); - EXPECT_EQ(-one * m0, -10919396); - EXPECT_EQ(-one * -m0, 10919396); - EXPECT_EQ(-one * +m0, -10919396); - - m0 *= 0; EXPECT_EQ(m0, 0); m0 = 10919396; - m0 *= zero; EXPECT_EQ(m0, 0); m0 = 10919396; - m0 *= -zero; EXPECT_EQ(m0, 0); m0 = 10919396; - m0 *= +zero; EXPECT_EQ(m0, 0); m0 = 10919396; - zero *= m0; EXPECT_EQ(zero, 0); - zero *= +m0; EXPECT_EQ(zero, 0); - zero *= -m0; EXPECT_EQ(zero, 0); - - m0 *= 1; EXPECT_EQ(m0, 10919396); - m0 *= -1; EXPECT_EQ(m0, -10919396); m0 *= -1; - - m0 *= one; EXPECT_EQ(m0, 10919396); - m0 *= -one; EXPECT_EQ(m0, -10919396); m0 *= -1; - m0 *= +one; EXPECT_EQ(m0, 10919396); - one *= m0; EXPECT_EQ(one, 10919396); one = 1; - one *= +m0; EXPECT_EQ(one, 10919396); one = 1; - one *= -m0; EXPECT_EQ(one, -10919396); one = 1; - - - - Aesi512 m1 = -14144694; - EXPECT_EQ(m1 * 0, 0); - EXPECT_EQ(0 * m1, 0); - EXPECT_EQ(m1 * 1, -14144694); - EXPECT_EQ(1 * m1, -14144694); - EXPECT_EQ(m1 * -1, 14144694); - EXPECT_EQ(-1 * m1, 14144694); - - EXPECT_EQ(m1 * zero, 0); - EXPECT_EQ(m1 * -zero, 0); - EXPECT_EQ(m1 * +zero, 0); - EXPECT_EQ(m1 * one, -14144694); - EXPECT_EQ(m1 * -one, 14144694); - EXPECT_EQ(m1 * +one, -14144694); - - EXPECT_EQ(zero * m1, 0); - EXPECT_EQ(zero * -m1, 0); - EXPECT_EQ(zero * +m1, 0); - EXPECT_EQ(one * m1, -14144694); - EXPECT_EQ(one * -m1, 14144694); - EXPECT_EQ(one * +m1, -14144694); - - EXPECT_EQ(+zero * m1, 0); - EXPECT_EQ(+zero * -m1, 0); - EXPECT_EQ(+zero * +m1, 0); - EXPECT_EQ(+one * m1, -14144694); - EXPECT_EQ(+one * -m1, 14144694); - EXPECT_EQ(+one * +m1, -14144694); - - EXPECT_EQ(-zero * m1, 0); - EXPECT_EQ(-zero * -m1, 0); - EXPECT_EQ(-zero * +m1, 0); - EXPECT_EQ(-one * m1, 14144694); - EXPECT_EQ(-one * -m1, -14144694); - EXPECT_EQ(-one * +m1, 14144694); - - m1 *= 0; EXPECT_EQ(m1, 0); m1 = -14144694; - m1 *= zero; EXPECT_EQ(m1, 0); m1 = -14144694; - m1 *= -zero; EXPECT_EQ(m1, 0); m1 = -14144694; - m1 *= +zero; EXPECT_EQ(m1, 0); m1 = -14144694; - zero *= m1; EXPECT_EQ(zero, 0); - zero *= +m1; EXPECT_EQ(zero, 0); - zero *= -m1; EXPECT_EQ(zero, 0); - - m1 *= 1; EXPECT_EQ(m1, -14144694); - m1 *= -1; EXPECT_EQ(m1, 14144694); m1 *= -1; - - m1 *= one; EXPECT_EQ(m1, -14144694); - m1 *= -one; EXPECT_EQ(m1, 14144694); m1 *= -1; - m1 *= +one; EXPECT_EQ(m1, -14144694); - one *= m1; EXPECT_EQ(one, -14144694); one = 1; - one *= +m1; EXPECT_EQ(one, -14144694); one = 1; - one *= -m1; EXPECT_EQ(one, 14144694); one = 1; - - - - Aesi512 m2 = -49285963; - EXPECT_EQ(m2 * 0, 0); - EXPECT_EQ(0 * m2, 0); - EXPECT_EQ(m2 * 1, -49285963); - EXPECT_EQ(1 * m2, -49285963); - EXPECT_EQ(m2 * -1, 49285963); - EXPECT_EQ(-1 * m2, 49285963); - - EXPECT_EQ(m2 * zero, 0); - EXPECT_EQ(m2 * -zero, 0); - EXPECT_EQ(m2 * +zero, 0); - EXPECT_EQ(m2 * one, -49285963); - EXPECT_EQ(m2 * -one, 49285963); - EXPECT_EQ(m2 * +one, -49285963); - - EXPECT_EQ(zero * m2, 0); - EXPECT_EQ(zero * -m2, 0); - EXPECT_EQ(zero * +m2, 0); - EXPECT_EQ(one * m2, -49285963); - EXPECT_EQ(one * -m2, 49285963); - EXPECT_EQ(one * +m2, -49285963); - - EXPECT_EQ(+zero * m2, 0); - EXPECT_EQ(+zero * -m2, 0); - EXPECT_EQ(+zero * +m2, 0); - EXPECT_EQ(+one * m2, -49285963); - EXPECT_EQ(+one * -m2, 49285963); - EXPECT_EQ(+one * +m2, -49285963); - - EXPECT_EQ(-zero * m2, 0); - EXPECT_EQ(-zero * -m2, 0); - EXPECT_EQ(-zero * +m2, 0); - EXPECT_EQ(-one * m2, 49285963); - EXPECT_EQ(-one * -m2, -49285963); - EXPECT_EQ(-one * +m2, 49285963); - - m2 *= 0; EXPECT_EQ(m2, 0); m2 = -49285963; - m2 *= zero; EXPECT_EQ(m2, 0); m2 = -49285963; - m2 *= -zero; EXPECT_EQ(m2, 0); m2 = -49285963; - m2 *= +zero; EXPECT_EQ(m2, 0); m2 = -49285963; - zero *= m2; EXPECT_EQ(zero, 0); - zero *= +m2; EXPECT_EQ(zero, 0); - zero *= -m2; EXPECT_EQ(zero, 0); - - m2 *= 1; EXPECT_EQ(m2, -49285963); - m2 *= -1; EXPECT_EQ(m2, 49285963); m2 *= -1; - - m2 *= one; EXPECT_EQ(m2, -49285963); - m2 *= -one; EXPECT_EQ(m2, 49285963); m2 *= -1; - m2 *= +one; EXPECT_EQ(m2, -49285963); - one *= m2; EXPECT_EQ(one, -49285963); one = 1; - one *= +m2; EXPECT_EQ(one, -49285963); one = 1; - one *= -m2; EXPECT_EQ(one, 49285963); one = 1; -} - -TEST(Multiplication, SmallPositive) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small1 * small3, 5757576); //5766068 - EXPECT_EQ(small3 * small1, 5757576); - EXPECT_EQ(small2 * small4, 9856489); - EXPECT_EQ(small4 * small2, 9856489); -} - -TEST(Multiplication, SmallNegative) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small2 * small1, -36031556); - EXPECT_EQ(small1 * small2, -36031556); - EXPECT_EQ(small3 * small2, -2876754); - EXPECT_EQ(small2 * small3, -2876754); -} - -TEST(Multiplication, MixedMultiplication) { - Aesi512 m0 = -632224826, m1 = 854946415; - EXPECT_EQ(m0 * m1, -540518348462698790); - Aesi512 m2 = 15124283, m3 = 855984917; - EXPECT_EQ(m2 * m3, 12946158128439511); - Aesi512 m4 = -255413170, m5 = -976424326; - EXPECT_EQ(m4 * m5, 249391632368773420); - Aesi512 m6 = -436691566, m7 = -215084769; - EXPECT_EQ(m6 * m7, 93925704597358254); - Aesi512 m8 = -508779305, m9 = -969810292; - EXPECT_EQ(m8 * m9, 493419406345607060); - Aesi512 m10 = 389511413, m11 = 558722925; - EXPECT_EQ(m10 * m11, 217628955992243025); - Aesi512 m12 = 33861785, m13 = -471602607; - EXPECT_EQ(m12 * m13, -15969306083673495); - Aesi512 m14 = 9170436, m15 = -469382092; - EXPECT_EQ(m14 * m15, -4304438434232112); - Aesi512 m16 = 459781677, m17 = -589479067; - EXPECT_EQ(m16 * m17, -271031673981655359); - Aesi512 m18 = -605361046, m19 = 568168204; - EXPECT_EQ(m18 * m19, -343946898277381384); - Aesi512 m20 = 814926234, m21 = -397421695; - EXPECT_EQ(m20 * m21, -323869365216246630); - Aesi512 m22 = 855291014, m23 = -737527571; - EXPECT_EQ(m22 * m23, -630800704053546994); - Aesi512 m24 = -683591332, m25 = -662674041; - EXPECT_EQ(m24 * m25, 452998230369012612); - Aesi512 m26 = -115005179, m27 = -86969330; - EXPECT_EQ(m26 * m27, 10001923364160070); - Aesi512 m28 = -698162382, m29 = -709316011; - EXPECT_EQ(m28 * m29, 495217755830498202); - Aesi512 m30 = 264231125, m31 = 576272843; - EXPECT_EQ(m30 * m31, 152269221612838375); - Aesi512 m32 = -416242575, m33 = -775215804; - EXPECT_EQ(m32 * m33, 322677822437655300); - Aesi512 m34 = -631448808, m35 = 169513175; - EXPECT_EQ(m34 * m35, -107038892294045400); - Aesi512 m36 = 882601391, m37 = -396333897; - EXPECT_EQ(m36 * m37, -349804848792650727); - Aesi512 m38 = -364424759, m39 = -814894879; - EXPECT_EQ(m38 * m39, 296967869889909161); - Aesi512 m40 = 37054480, m41 = 755633477; - EXPECT_EQ(m40 * m41, 27999605560826960); - Aesi512 m42 = -479511582, m43 = 753322217; - EXPECT_EQ(m42 * m43, -361226728029417294); - Aesi512 m44 = -409793824, m45 = -424625374; - EXPECT_EQ(m44 * m45, 174008855778890176); - Aesi512 m46 = 183576582, m47 = -987453846; - EXPECT_EQ(m46 * m47, -181273401931434372); - Aesi512 m48 = -562035517, m49 = 439637934; - EXPECT_EQ(m48 * m49, -247092133528501878); - Aesi512 m50 = -499481757, m51 = -930190942; - EXPECT_EQ(m50 * m51, 464613406055645094); - Aesi512 m52 = 220311749, m53 = -446455934; - EXPECT_EQ(m52 * m53, -98359487670968566); - Aesi512 m54 = -893464199, m55 = 503713658; - EXPECT_EQ(m54 * m55, -450050119970329942); - Aesi512 m56 = -510392458, m57 = -499319405; - EXPECT_EQ(m56 * m57, 254848858445047490); - Aesi512 m58 = 978772862, m59 = 38529994; - EXPECT_EQ(m58 * m59, 37712112500222828); - Aesi512 m60 = 302637761, m61 = -377843880; - EXPECT_EQ(m60 * m61, -114349825850752680); - Aesi512 m62 = -606373345, m63 = -957840592; - EXPECT_EQ(m62 * m63, 580809003747820240); - Aesi512 m64 = -482327274, m65 = 72347072; - EXPECT_EQ(m64 * m65, -34894966019641728); - Aesi512 m66 = -124692430, m67 = -448472121; - EXPECT_EQ(m66 * m67, 55921078554744030); - Aesi512 m68 = 100886786, m69 = 486116510; - EXPECT_EQ(m68 * m69, 49042732315436860); - Aesi512 m70 = 417006369, m71 = -824160488; - EXPECT_EQ(m70 * m71, -343680172574148072); - Aesi512 m72 = 602004950, m73 = -699239102; - EXPECT_EQ(m72 * m73, -420945400637554900); - Aesi512 m74 = 333271488, m75 = -742295106; - EXPECT_EQ(m74 * m75, -247385794511737728); - Aesi512 m76 = -321447732, m77 = -339153497; - EXPECT_EQ(m76 * m77, 109020122410518804); - Aesi512 m78 = -293108259, m79 = 82767790; - EXPECT_EQ(m78 * m79, -24259922828177610); -} - -TEST(Multiplication, MixedMultiplicationAssignment) { - Aesi512 m0 = -78990477, m1 = -924464422; - m0 *= m1; EXPECT_EQ(m0, 73023885663309294); - Aesi512 m2 = -130189339, m3 = 753383660; - m2 *= m3; EXPECT_EQ(m2, -98082520708800740); - Aesi512 m4 = -790677253, m5 = 866863439; - m4 *= m5; EXPECT_EQ(m4, -685409202674653067); - Aesi512 m6 = 166592228, m7 = 593311507; - m6 *= m7; EXPECT_EQ(m6, 98841085849167596); - Aesi512 m8 = -437879590, m9 = 808169924; - m8 *= m9; EXPECT_EQ(m8, -353881114971451160); - Aesi512 m10 = -787058027, m11 = 414778979; - m10 *= m11; EXPECT_EQ(m10, -326455124852814433); - Aesi512 m12 = -918620953, m13 = -322386314; - m12 *= m13; EXPECT_EQ(m12, 296150823000837242); - Aesi512 m14 = 474122456, m15 = -84479346; - m14 *= m15; EXPECT_EQ(m14, -40053555006793776); - Aesi512 m16 = 727097635, m17 = -47548650; - m16 *= m17; EXPECT_EQ(m16, -34572510962442750); - Aesi512 m18 = 897765113, m19 = 975202363; - m18 *= m19; EXPECT_EQ(m18, 875502659616562019); - Aesi512 m20 = -454181230, m21 = -785982875; - m20 *= m21; EXPECT_EQ(m20, 356978668926436250); - Aesi512 m22 = -766757515, m23 = 755940205; - m22 *= m23; EXPECT_EQ(m22, -579622833074390575); - Aesi512 m24 = -676345196, m25 = -868942436; - m24 *= m25; EXPECT_EQ(m24, 587705042189137456); - Aesi512 m26 = -764919638, m27 = -644748000; - m26 *= m27; EXPECT_EQ(m26, 493180406761224000); - Aesi512 m28 = -36106476, m29 = 5898500; - m28 *= m29; EXPECT_EQ(m28, -212974048686000); - Aesi512 m30 = -508311768, m31 = -400158082; - m30 *= m31; EXPECT_EQ(m30, 203405062140908976); - Aesi512 m32 = 699063090, m33 = -567008183; - m32 *= m33; EXPECT_EQ(m32, -396374492463265470); - Aesi512 m34 = -217982726, m35 = -203957548; - m34 *= m35; EXPECT_EQ(m34, 44459222301315848); - Aesi512 m36 = -94926525, m37 = -919379377; - m36 *= m37; EXPECT_EQ(m36, 87273489415274925); - Aesi512 m38 = 228581475, m39 = -75340786; - m38 *= m39; EXPECT_EQ(m38, -17221507991539350); - Aesi512 m40 = -548442627, m41 = 276540841; - m40 *= m41; EXPECT_EQ(m40, -151666785310829307); - Aesi512 m42 = 311095923, m43 = -635342106; - m42 *= m43; EXPECT_EQ(m42, -197652338886833838); - Aesi512 m44 = -48816753, m45 = 342286992; - m44 *= m45; EXPECT_EQ(m44, -16709339543576976); - Aesi512 m46 = -315839248, m47 = -928470470; - m46 *= m47; EXPECT_EQ(m46, 293247415035006560); - Aesi512 m48 = -249050979, m49 = -516669820; - m48 *= m49; EXPECT_EQ(m48, 128677124490753780); - Aesi512 m50 = 171420914, m51 = 717817322; - m50 *= m51; EXPECT_EQ(m50, 123048901422272308); - Aesi512 m52 = -41298512, m53 = 224451575; - m52 *= m53; EXPECT_EQ(m52, -9269516063556400); - Aesi512 m54 = -948716932, m55 = -386328174; - m54 *= m55; EXPECT_EQ(m54, 366516079982442168); - Aesi512 m56 = 648648935, m57 = -707788376; - m56 *= m57; EXPECT_EQ(m56, -459106176297779560); - Aesi512 m58 = 103993409, m59 = -766917779; - m58 *= m59; EXPECT_EQ(m58, -79754394260918611); - Aesi512 m60 = 32082502, m61 = -164829182; - m60 *= m61; EXPECT_EQ(m60, -5288132561173364); - Aesi512 m62 = -501474190, m63 = -188061417; - m62 *= m63; EXPECT_EQ(m62, 94307946760327230); - Aesi512 m64 = -520504227, m65 = -366873757; - m64 *= m65; EXPECT_EQ(m64, 190959341293870839); - Aesi512 m66 = 151343708, m67 = -769245438; - m66 *= m67; EXPECT_EQ(m66, -116420456949004104); - Aesi512 m68 = 582249656, m69 = -197127361; - m68 *= m69; EXPECT_EQ(m68, -114777338130437816); - Aesi512 m70 = -69879403, m71 = -573718443; - m70 *= m71; EXPECT_EQ(m70, 40091102286929529); - Aesi512 m72 = 316032836, m73 = -595187191; - m72 *= m73; EXPECT_EQ(m72, -188098695922603676); - Aesi512 m74 = 594592468, m75 = 445255386; - m74 *= m75; EXPECT_EQ(m74, 264745498852032648); - Aesi512 m76 = -933643542, m77 = 838661995; - m76 *= m77; EXPECT_EQ(m76, -783011355552586290); - Aesi512 m78 = -887038650, m79 = 333513342; - m78 *= m79; EXPECT_EQ(m78, -295839224644668300); -} - -TEST(Multiplication, DifferentPrecision) { - { - Aesi < 320 > first = 80176598; // Aesi<10 blocks> - Aesi < 480 > second = -426614748; // Aesi<15 blocks> - EXPECT_EQ(first * second, -34204519151267304); - - Aesi < 320 > third = 638380867; // Aesi<10 blocks> - Aesi < 352 > forth = 534963661; // Aesi<11 blocks> - forth *= third; EXPECT_EQ(forth, 341510565722674087); - } - { - Aesi < 352 > first = 118510918; // Aesi<11 blocks> - Aesi < 256 > second = 392821062; // Aesi<8 blocks> - EXPECT_EQ(first * second, 46553584667354916); - - Aesi < 320 > third = 490743664; // Aesi<10 blocks> - Aesi < 416 > forth = -755654452; // Aesi<13 blocks> - forth *= third; EXPECT_EQ(forth, -370832634492392128); - } - { - Aesi < 480 > first = 368054998; // Aesi<15 blocks> - Aesi < 352 > second = -412866557; // Aesi<11 blocks> - EXPECT_EQ(first * second, -151957599810901886); - - Aesi < 256 > third = -806407399; // Aesi<8 blocks> - Aesi < 416 > forth = -755378465; // Aesi<13 blocks> - forth *= third; EXPECT_EQ(forth, 609142783221262535); - } - { - Aesi < 288 > first = 929534487; // Aesi<9 blocks> - Aesi < 480 > second = -405487320; // Aesi<15 blocks> - EXPECT_EQ(first * second, -376914447981204840); - - Aesi < 320 > third = -797426321; // Aesi<10 blocks> - Aesi < 352 > forth = 271542653; // Aesi<11 blocks> - forth *= third; EXPECT_EQ(forth, -216535258776369613); - } - { - Aesi < 256 > first = -143407538; // Aesi<8 blocks> - Aesi < 320 > second = 342454657; // Aesi<10 blocks> - EXPECT_EQ(first * second, -49110579237004466); - - Aesi < 224 > third = -549448186; // Aesi<7 blocks> - Aesi < 416 > forth = -271976909; // Aesi<13 blocks> - forth *= third; EXPECT_EQ(forth, 149437219283937074); - } - { - Aesi < 352 > first = -219679513; // Aesi<11 blocks> - Aesi < 416 > second = -854551178; // Aesi<13 blocks> - EXPECT_EQ(first * second, 187727386616616314); - - Aesi < 224 > third = 666244848; // Aesi<7 blocks> - Aesi < 480 > forth = 296272756; // Aesi<15 blocks> - forth *= third; EXPECT_EQ(forth, 197390197287761088); - } - { - Aesi < 448 > first = -268356793; // Aesi<14 blocks> - Aesi < 416 > second = 842723607; // Aesi<13 blocks> - EXPECT_EQ(first * second, -226150604559912351); - - Aesi < 192 > third = -616257946; // Aesi<6 blocks> - Aesi < 448 > forth = 491688630; // Aesi<14 blocks> - forth *= third; EXPECT_EQ(forth, -303007025195353980); - } - { - Aesi < 256 > first = 456747220; // Aesi<8 blocks> - Aesi < 384 > second = -110801174; // Aesi<12 blocks> - EXPECT_EQ(first * second, -50608128197236280); - - Aesi < 224 > third = -396227181; // Aesi<7 blocks> - Aesi < 416 > forth = -244030095; // Aesi<13 blocks> - forth *= third; EXPECT_EQ(forth, 96691356621012195); - } - { - Aesi < 352 > first = 623180065; // Aesi<11 blocks> - Aesi < 288 > second = -2907435; // Aesi<9 blocks> - EXPECT_EQ(first * second, -1811855532283275); - - Aesi < 256 > third = 541805924; // Aesi<8 blocks> - Aesi < 448 > forth = 257383120; // Aesi<14 blocks> - forth *= third; EXPECT_EQ(forth, 139451699153602880); - } - { - Aesi < 288 > first = -84363176; // Aesi<9 blocks> - Aesi < 352 > second = -347420155; // Aesi<11 blocks> - EXPECT_EQ(first * second, 29309467682212280); - - Aesi < 224 > third = 289550886; // Aesi<7 blocks> - Aesi < 480 > forth = -717975170; // Aesi<15 blocks> - forth *= third; EXPECT_EQ(forth, -207890346599500620); - } -} - -TEST(Multiplication, Huge) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = "-24436584029911644622966671247078146034108132532621077502273052079359378180180.", m1 = "7147940486803143509360502056668087409959845176315408623242511200988769264844."; - EXPECT_EQ(m0 * m1, "-174671248346572563457913712858818111096180221900695136871112386634795218735942661878529845190166227794674231400434163243396431169329565925693553171591920."); - Aesi512 m2 = "75255885530711625886631263889926989789912566750259610202310111887822319306741.", m3 = "-28265398609831959947228222909049452638383512583189228614662207731909554387640."; - EXPECT_EQ(m2 * m3, "-2127137602261449499670859746314091458827106528946637743545602434646084975300998780052276301387881436929194736658543785902861255217756564624838359579081240."); - Aesi512 m4 = "-58703316035301545116710440831263208749107882596237349724412380774420969117549.", m5 = "-44614227115696829840744360031215191960959365566333801559474751875052908259214."; - EXPECT_EQ(m4 * m5, "2619003074043470713711383801129648642197009127609571708621970758957496275703036126608599011925812660388023546397517179777620599292608417849203371328346486."); - Aesi512 m6 = "96216664315080874406515512572676456565627596477424802327420731827269481316835.", m7 = "54770399467878291132041406435877621085309416629404510482710223915950330690807."; - EXPECT_EQ(m6 * m7, "5269825140003729686679051546133119722265424240906557017963217233532028010606971614993567264566638800391974033416826101467319520821274406689401385588835845."); - Aesi512 m8 = "88030355588247214857094154494567310402291375508399077233409621872939109165252.", m9 = "89669337094600817357419060270086504262328467495187339824058239770574816855533."; - EXPECT_EQ(m8 * m9, "7893623629800116339244611673151943678397009602159281657059946745546035684805892635210092852838393153082939528294718128057329367474586565267188375107539316."); - Aesi512 m10 = "-50978820904996324262967061501451244179111687465647116169958122485388981313610.", m11 = "55520850362974897292408344433298251187076107953999595065677557862443671243534."; - EXPECT_EQ(m10 * m11, "-2830387487147197452034674983283509822799046687210695418203931860416320777372142979094686295685233842288747089908603739504672337247653959186930837538697740."); - Aesi512 m12 = "26086540981517597492007854071161567130526857930406124685804033373287359174745.", m13 = "75667069542040994745694342788849857011877636394600426958617410491287825123093."; - EXPECT_EQ(m12 * m13, "1973892110559794397238105448451520633181360220953852514702075915688145620177281245400408166597299332475779772714985580238629917343224979422326882521886285."); - Aesi512 m14 = "56999189227909524865975100531504195721398373304794935347547101233337852229463.", m15 = "109156358721849074244238038156812415196591791749078499025838750230261001872591."; - EXPECT_EQ(m14 * m15, "6221823946216247664718915726540500414244262850644973422424843053753652317769791311342807180452257102496204726074161781416651899819218129095741887222348633."); - Aesi512 m16 = "12217386005784217519282459099080729649456896389334165562191482230084549641237.", m17 = "-54427935291360248242088676429379444820549959605761736317948465639292559478510."; - EXPECT_EQ(m16 * m17, "-664967094952393634680076788956130559532309393926535687096648563121154935572959201348145951840365038608809057039215587510419572117629539631691504311316870."); - Aesi512 m18 = "-24005744204711879313663725073278359707871318773877531556008014202908980265403.", m19 = "-93293043177138299632205327776400411228228289179938709333224047166257151816032."; - EXPECT_EQ(m18 * m19, "2239568930589522869248769860973514155337357417034105153014024120121488772971799615713690278922004590583150049220335817156221966663236563210347630790340896."); - Aesi512 m20 = "-38817524438172549589179425891318731317414851478607744830336936455280860326570.", m21 = "30945553112121688854566922027234435481189106971440090604490074829935154974989."; - EXPECT_EQ(m20 * m21, "-1201229764182550253618410425477948177849700040233840666369380071715344486851492040122408540038488427579885139529333479761290894179077732162193970722157730."); - Aesi512 m22 = "19701077572984102506063004577801939598692158592815491261917763397364154112090.", m23 = "-111993684482754136764271215381937318276851516751253041002351743328031274846542."; - EXPECT_EQ(m22 * m23, "-2206396265679045210159512066865172307906924503557259524488541462652344215247532807651752169785145687231740439432209021247637947888347850122667253016892780."); - Aesi512 m24 = "-34408749266039341994532643381522524005484387847402615420023932765923021826651.", m25 = "36238931131547729159662299291733316512813797448232626609610874543640037865699."; - EXPECT_EQ(m24 * m25, "-1246936294974693186996943128354283583320593023974521084108313660620983537290477463117515001362980848855066141266698521360843384242995099493151298396944049."); - Aesi512 m26 = "-23097280300789681176811619033543345317046072017832678489528594950163492671160.", m27 = "-79407204422127198589063146342493982440929997996962103136935602379143045897817."; - EXPECT_EQ(m26 * m27, "1834090458439977802700742210585365973027776453121457507308198871731413767638406803062466784888410959493896809155054743359912924237587029869722581742857720."); - Aesi512 m28 = "-15424763053753869904533373662513621747712193633108267361573398495444352181091.", m29 = "-81083679296940708546272958119091919820773832612463167687731044023339764263422."; - EXPECT_EQ(m28 * m29, "1250696540681878602686991843690545385442976444059171844177036927621053869730344980300704357424451684788071016484390867594996739084404522510491342771353402."); - Aesi512 m30 = "106872840522201611992006193978254523203862367939195189759357711450230326628869.", m31 = "77625752489319692320568374152720041029662625495662899637080699257794791221335."; - EXPECT_EQ(m30 * m31, "8296084666206958268240563465336962556596570846792198065071051635076620808246917475800350633189224414613984859781367697500874673887049118418747765779720115."); - Aesi512 m32 = "-52711217480964793821383740724641059707650627870018107448349487078030726207894.", m33 = "100428073425324066117762164117278644194755501017516454018988915136264003892213."; - EXPECT_EQ(m32 * m33, "-5293686019516557773345486029284878642653843002641441990868872594658781686680132253711860090985968839275104732845841698708176068289452519445674961805729422."); - Aesi512 m34 = "13864350367948987093779839711930686467895820466156967092515335777384879028413.", m35 = "11043691551478534610807078489529250432510840377203645036693671913015013063037."; - EXPECT_EQ(m34 * m35, "153113609025256541474003904472868741026989533304616556697640791506228871514184371266747590222016033700400159037077932529930388927695927651933183683070281."); - Aesi512 m36 = "28974101975302136744724298757732379236237494303059049090929652977061223391687.", m37 = "95165352135790387526323822440459843158659156557573963372613515213828647211061."; - EXPECT_EQ(m36 * m37, "2757330617297927685117323728146495956384638187867991195178168876306886431048626511432769996769815732895616559229990083134232292202941770805701127761849907."); - Aesi512 m38 = "74013494604885236995564035258143590608121469306245206718591074721180020756235.", m39 = "-113690692323687652104911904378878520187736971082245578651848273227573836532148."; - EXPECT_EQ(m38 * m39, "-8414645442924923467344542860102761664473578540192670731964620224357761660493095935522448027978163360773427593728021061491215385432309732937525552848942780."); - Aesi512 m40 = "16734851497199911459025873930306397999904293251741298822031923819309101045776.", m41 = "33124281958515362630748538016105214781226569549499205810942707292640841863354."; - EXPECT_EQ(m40 * m41, "554329939527132831754191268629650885325020120190948038017269765012732109363809749246433164812040872267431425804860236686470698405217281717657761890892704."); - Aesi512 m42 = "-64214456321584724798585697913923326047585024520134700963697108783799567623762.", m43 = "-102660207194453794260911420228738100681701714407942929831762178754122456494440."; - EXPECT_EQ(m42 * m43, "6592269390853091093994559882694651600489438980451460163337817827935495594934335006668456078017832607855661257727833693059331821725067088867341615364883280."); - Aesi512 m44 = "-107799357473927603134987643235677765574158334375982285375873773420553798612261.", m45 = "52832296185583925384651469799040295620951618676446637260263801931614747939912."; - EXPECT_EQ(m44 * m45, "-5695287582678183325352946175141449338847077443892121511408063213431030007572274874447084066987193809612289842710296350708030709405394881371044574214461032."); - Aesi512 m46 = "2291270309580905066221087202727533772959694445085380461172919050346315156197.", m47 = "-68090189032365634209126228406514189606046386201337765808132595882826855586221."; - EXPECT_EQ(m46 * m47, "-156013028503610753464178328283737391982854668544631187482277329659801109337538652103389541894105283608355101469736415765767751286385790012298487615961537."); - Aesi512 m48 = "109805901345352651598335288137450714972271563631273551359422702227047175447842.", m49 = "50232354748237056036717335637498559651166846170060126586373789555562810716916."; - EXPECT_EQ(m48 * m49, "5515808989829675008031131452819883419652893111953400222551921814561700982725356682626988707912379569001185772506005052626813270634358197509862789385095272."); - Aesi512 m50 = "-80793925984645942386530025516138761593228215359323235950887370472489629756166.", m51 = "43370590056527276100947377378103425732109404962703231455929038271257535403883."; - EXPECT_EQ(m50 * m51, "-3504080242937486023823403143144084397559913449176305127407924556938461140719535025548132416039832881905986713989164387421188414602505077568769345619592578."); - Aesi512 m52 = "2850565569917202121876697402202949811110467710817251825802664246241931838226.", m53 = "103616139367142381966830987835649617611198436530293073692503910966863539880860."; - EXPECT_EQ(m52 * m53, "295364599367718466843509504625002690748851141644190747936961076595449505985718242632454604311839039055440877574946099725404924449768958908633920833754360."); - Aesi512 m54 = "27792955963318582014161429018975582379674421206450421291585305032716042882068.", m55 = "-34515344518200129629387359181562831848695510109776035315361040427407132622498."; - EXPECT_EQ(m54 * m55, "-959283450253105622786538219559608097556464747001982950461009861732300934127419662606140634260080997358888672987690943599148258901161101589369370977565864."); - Aesi512 m56 = "-52452099132254247928016163853162449393460308647804335250488565966909189848329.", m57 = "58708810283610868128690563875348883637308706853872752004578328682320128211946."; - EXPECT_EQ(m56 * m57, "-3079400336932664883369558905911544933851091585336487516745123297460507520759352630209729730299010144361158720186580461139101280825892198022679017705938234."); - Aesi512 m58 = "90120126340374678426116322430681317808986569892980204219828934596299853723983.", m59 = "86386989825335383361702238867579076507913042908831737337293646371641310172047."; - EXPECT_EQ(m58 * m59, "7785206437223886622813623105202879370363587370419490713023104034722157852133645276910880180808835277416541480472945856083222644982011213297021471380103201."); - Aesi512 m60 = "65664984843896395163118811561897405531737741511887134695354690857397884298813.", m61 = "-26047654134693977237521964602953884554992652238365251973855571839958920596962."; - EXPECT_EQ(m60 * m61, "-1710418813973735286922198210685002538110063669129826432937078349587252536557312591488002346506986176163456917030103201315038786597596606752880568748006106."); - Aesi512 m62 = "115147850630345245570356312342978779414937591148739129183408519346204364546554.", m63 = "-25196606771810870628621938489498796937626338206118434758597021874683870163607."; - EXPECT_EQ(m62 * m63, "-2901335112952023642630790741886209043736079855971028664198121128321696775364823801845011213764151897908032771149252015249795379667701232779105354348060278."); - Aesi512 m64 = "-1140238235457395562356211772540335170569801424376523415764243584615669020974.", m65 = "-10515979348297267138616926808744098968766483822502409135410758493972659669454."; - EXPECT_EQ(m64 * m65, "11990721736208888425200802855112903320284807491919685146073480494644498289083013923313493400910219808699829115498228044618434566536682341751638633128196."); - Aesi512 m66 = "-29935458349963657374634328770239566550964980634984808074278126642601808837004.", m67 = "92440004332665488652300601179897111816219173031438435160546684599804822685167."; - EXPECT_EQ(m66 * m67, "-2767233899570967767587079191132852946518893084816985923253469464187444253240550585283870675317104781448135088790013468325539913111045458424764788711519668."); - Aesi512 m68 = "27589889680268049278923569483355576280211040741748094669392476147129509946835.", m69 = "55766479695676178606897363359106454534633067950264192686209469207248895613842."; - EXPECT_EQ(m68 * m69, "1538591022660613905438806220399094071077015148915825822707695886877387615066716264874729868548455979980815389374820151030146058023528282094335142110090070."); - Aesi512 m70 = "10249655423991078095152119851154369642477668896819400001626061667015949502787.", m71 = "-91039608277923388350159435250041260581241669396801972213779500411697312237661."; - EXPECT_EQ(m70 * m71, "-933124614783840510137226152367613797730577998347267548021170735934517848124354569361501987021629397588791077400228397614377913938210379769821983325861207."); - Aesi512 m72 = "3340007579307911131627785903081926471472738796913159670359374735535741173583.", m73 = "62179929850210291333484095895791702323667450262147784495626349489464950276640."; - EXPECT_EQ(m72 * m73, "207681436980536600362349491574824770837881416438520411282881017806262465505354528799677374109293243804937766462536306071287075112399742046351854110001120."); - Aesi512 m74 = "41771629481164654105165473494680633989938633730212655588819830680183869014863.", m75 = "38544767051922770429239072738495911725688076382297636403738572424287142654650."; - EXPECT_EQ(m74 * m75, "1610077727730721209124943844800338674022404032774983383988832845244245268813278142715241453312816340107223781827501910897405830803866369236947642126062950."); - Aesi512 m76 = "-95460758409065436221113072759185912202810208711505145946696767769662451292516.", m77 = "10864840734240282399191552767566024003268294966258699065276272647988994236831."; - EXPECT_EQ(m76 * m77, "-1037165936484284726385803782564307497974821768712997410605537228996672405798748413007283167346037595834539745606070144392389505258363720620370570961856796."); - Aesi512 m78 = "93223467270975916336090734961983001873625192983522347709478293874654649973949.", m79 = "1949754677213569656105635639406237736419892971123793020254427530588386527870."; - EXPECT_EQ(m78 * m79, "181762891337651423076690920197513471149367082716107153842463094269566275979670850596739166785036161010139697396038638980270361053905946909492038062458630."); - - -#ifdef NDEBUG - Logging::addRecord("Multiplication", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Multiplication, HugeAssignment) { - Aesi512 m0 = "5126831531378800445192629830277927212477463890241609534491558169598240131749.", m1 = "-50103402077463208237128372473832321492034315109589471637179365719310501327138."; - m0 *= m1; EXPECT_EQ(m0, "-256871701600088471495137062483436394756503487120375333548328365648200352425379979685069788186952238365121495931458765296871314183196593757708276469104362."); - Aesi512 m2 = "44889638123020072937492576176116204759273304455494561945690498248993123630042.", m3 = "94535640730752117815433283034390188298910118978960788631848036242753485554041."; - m2 *= m3; EXPECT_EQ(m2, "4243670702131299454357870405504985901809248925246001578573606462918942897410036282403510609902290610296765462422124247582492712525016140110945405482099722."); - Aesi512 m4 = "-111317960711337451362629552080932580070543339159612194343611177578703732227175.", m5 = "53721062769952906612339167785508061515848605186290196571348348110207170496470."; - m4 *= m5; EXPECT_EQ(m4, "-5980119154796910735426251895222549531537682064561080305629857600462134519545953345568525955677530066341176711915171036006026252819828886593795783575572250."); - Aesi512 m6 = "-16312553556129140778494331818784013521167053560976472471351587341074339241932.", m7 = "-73140096322955737357387819440268930492212274377607337047153676127270065963604."; - m6 *= m7; EXPECT_EQ(m6, "1193101738368659506838155636904706247985360051746871167534865700701489023878361112909888868784784888227399754816424459586062077648130435393333956462642928."); - Aesi512 m8 = "83141059197353800735609286324544545862389703907976540449213717758603829919696.", m9 = "-101021064008526849881233130821503337901252471549129657118568637741764703206056."; - m8 *= m9; EXPECT_EQ(m8, "-8398998262912598265497785747534803832811609615379200309867668098596187107712385910427881557730582356430424364036050413585867116369951595864688068220878976."); - Aesi512 m10 = "66828679076773454746137637401679691971051086232678706593908376540926401205391.", m11 = "94999567391067401818281656138885285549376844981254225152189357567577709333502."; - m10 *= m11; EXPECT_EQ(m10, "6348695601609955851478727081441990319874412445872135832015996064598035254483006180803871183148102542349584667358696487941008430237464150509698884019309282."); - Aesi512 m12 = "-56559506493642757838920881209217033534242031679562113417799735764119410198082.", m13 = "-107372876700509857757830911667382822944794768750178563829310102403435828809746."; - m12 *= m13; EXPECT_EQ(m12, "6072956916983590474451281824250636118656179972944582229251996092225818091115237543428392176900304786498313460220310908434265555505615404551491612152107172."); - Aesi512 m14 = "55855071408212204060207506970957636007592856082411206504272014296396234572189.", m15 = "-87781754164396213139233323479067592485576964298109010225944105668068220734256."; - m14 *= m15; EXPECT_EQ(m14, "-4903056147190479500742487239085255736735583472166445349370723989326381869778279815112805427924341037917647203749548629993838098482038470404480345617206384."); - Aesi512 m16 = "103333364256500530120527219733915454057989259497278277847259336480191594775389.", m17 = "-108695940817410645728134219642848058571271981668433646945355141293261985640613."; - m16 *= m17; EXPECT_EQ(m16, "-11231917245688518234115621759203754352442015192393951446172068692139018466076130748248737936255155298462085432278628404873518356726977009580185391011273457."); - Aesi512 m18 = "-67853014137041196132953367575838181020010111936918449980582929430933428627118.", m19 = "-38822137998914687690212221830609733026077851166968261805235207663217908104733."; - m18 *= m19; EXPECT_EQ(m18, "2634199078470522516459447037326247619808806921090764849639482866269260517483128084322565879133110957294222578171234525253712605086779512860462809547949494."); - Aesi512 m20 = "-93291815458818778611192271974943835889161757539070415227685605001698892417117.", m21 = "-592998033423813716395997270765126694094180130212706712121913841023805066027."; - m20 *= m21; EXPECT_EQ(m20, "55321863101616879238831024906149528046748205917737564886381950325664310170670586497539340617965100481761717321313197018159975154783391197559239809984159."); - Aesi512 m22 = "69591885086750438733622229167327716736514701761719521083857645700312107603602.", m23 = "-9088905857687677131587404576816785117777037406945506173239456017895686069109."; - m22 *= m23; EXPECT_EQ(m22, "-632514092012493763621555561134914706215602694442158024243854891793468575717815832357963982977914794159422600032851889948842342809827736887143305349330618."); - Aesi512 m24 = "-44634549170914499634248366989354714829650785235321266390484036736584048516292.", m25 = "63553589111825121605734826453929961880456834395932030922846639769582741603403."; - m24 *= m25; EXPECT_EQ(m24, "-2836685798199854752750335537710194204665920956221819960465074908625312129810186319897471093627387962682793244117647187439536559335295195598005143248141676."); - Aesi512 m26 = "-57050009737269964730500248898648465373172558441827380922042557732558269138926.", m27 = "66063935733701979696086033400764135712851489744282282440292544332769648252636."; - m26 *= m27; EXPECT_EQ(m26, "-3768948176890075113324019124243587925264563583505239315627860968136466592934731785106550952221832298951226293247693134538489840850654943916259000229708936."); - Aesi512 m28 = "-65617249585297327328508251393997036422913520778457242106590784109016252978629.", m29 = "23459039341164515284507619107084144263124636837365882196031942772413489603228."; - m28 *= m29; EXPECT_EQ(m28, "-1539317639480500977465762141968591129699569296048561920294418753766185418554295102672943385504162019406433941382244365038698207107473204961124578373414412."); - Aesi512 m30 = "72739208296469903651849685330584390758605133752877980517716730723174002466353.", m31 = "3375360766580760249948654642373888369351304164306739214988684025139072983590."; - m30 *= m31; EXPECT_EQ(m30, "245521069876050249877578665893201955272262526840128092248452377697698207120968956936724288291446919528942598497740639536696772796468237988542730296147270."); - Aesi512 m32 = "67436125027786698025884307030146965499927882730130852185690660793318319562951.", m33 = "-67731057362539260401653055744492584042915396200015622354082775546974948534810."; - m32 *= m33; EXPECT_EQ(m32, "-4567520052564390319760152099990124485211867117769261109038861505497841526777599893237258212744724560455102045753182560621381058648626158292076437009824310."); - Aesi512 m34 = "-106878741120554538460808865633832219610277061450942126094667782894877323018652.", m35 = "99218171327841081780368540493167952701161596068798628773395035019804224832421."; - m34 *= m35; EXPECT_EQ(m34, "-10604313247803153920117169255215522309117925130743838290201052711393672188019887497568496986401358315408796352841670052213866090055638655538416490557316492."); - Aesi512 m36 = "-38062824400414632805166908924912595985610840563607092477971706668684885788688.", m37 = "10511672558558273501692639758296052444180008889226485859080393260208312891796."; - m36 *= m37; EXPECT_EQ(m36, "-400103946751060765742051085556227277467312439043500597623587315162297982813357052932229115818919567390892294424655656003481097689095505677799581464803648."); - Aesi512 m38 = "11644074406945081885176738203572545830281686147310393315438083912764873280878.", m39 = "103762702994007637703840699873892114479130848210552399597420784548675396088090."; - m38 *= m39; EXPECT_EQ(m38, "1208220634327968156512422816973249970782234708102490282043174163386131359142243181851282575003262842386608426037706631365958080919224082503013565000543020."); - Aesi512 m40 = "58035709421648291597610776791868077478646981246804573133922860349388348756477.", m41 = "71604962130339705915390078428711779757718814387019066398485577050362362806039."; - m40 *= m41; EXPECT_EQ(m40, "4155644775344525195820510502707319758504827240428218405040105485701894240802185332992462968491838072918695590307706317727636639069360764045579761995964603."); - Aesi512 m42 = "-90997270796795927586640661797948371975815375703512643367911569030642894584670.", m43 = "-111242926582989811985296944864857236358448653083204252672949569722462190290494."; - m42 *= m43; EXPECT_EQ(m42, "10122802714500412202621235865408643822267577230639723915098665884593217778255511676645804139756888204304691239018808651713771431238656570797405646779126980."); - Aesi512 m44 = "73188849928080147370826595072503962377670299143251663506289114402536376359215.", m45 = "-114561412640251833511764028492907882763331951640722617142786846192579044047648."; - m44 *= m45; EXPECT_EQ(m44, "-8384618037276255491040635543697322111161269956952713586101897210341139097355096573812181992682250420958574857874343909738011348251023143423878551223876320."); - Aesi512 m46 = "-1987716296325002738249096982092646315237391641618484802994585679729683588084.", m47 = "9330667150404053524209271797141947614009956660237582595921596605839214396778."; - m46 *= m47; EXPECT_EQ(m46, "-18546719150442512548099216295215459860241724562410396841978076339690172940340949068403110900356197259691561775785049444205862899696816369294720688793352."); - Aesi512 m48 = "64357084676081944457750648820167303204169903118218689239597367346885844774706.", m49 = "112736712501006524430037957392083444215008992509012453300296426902858001664599."; - m48 *= m49; EXPECT_EQ(m48, "7255406152530382776746901233602692055915648223964125084752343022372477347790587485081053396898212164037364078044922899549366607272185130616340074130832894."); - Aesi512 m50 = "-75612864871306336967991795163304831470892502404658843807362102227244106231144.", m51 = "-28718450803463575517537559752976144947507844670922811572052052859199489386653."; - m50 *= m51; EXPECT_EQ(m50, "2171484339915550237522625961692374224810880771431976088291935266715919317906948416630259018838770784337452509364325466331398106477788372019256092006521032."); - Aesi512 m52 = "57943441662748449656705715087868147857725698772411685902347540832251830943384.", m53 = "45518091285346223220320092670396472503737069512889961339884413896107027837689."; - m52 *= m53; EXPECT_EQ(m52, "2637474866992117480435063845014728069682108062062813948807482159638130215783429170738410862736559001208845632944847806963497884193210147802645570500399576."); - Aesi512 m54 = "81814950815413944324414453353594515346550340435328952500830586223575617018414.", m55 = "-106077045361337737047426005807426478614119569448023485610851580859748890885159."; - m54 *= m55; EXPECT_EQ(m54, "-8678688248882280850016542259973692176525587082001100874602547892323341146334361709542143755430972846143623945539459235025709208414210427840515644862317826."); - Aesi512 m56 = "64832850695215069496234307440023753429525792468938665335135878119005138075178.", m57 = "33514453767724059465673298893216513857147393104454974732450097829931572695147."; - m56 *= m57; EXPECT_EQ(m56, "2172837577254542093985690865194481239117933671073532053328884021851124831745615047264520473039101856278261499783116501485151514664556977867596437361761166."); - Aesi512 m58 = "-26079941054614923052485189235517400488426820860439981020603885206783879014023.", m59 = "105304925107301605413907071213898698010787399678017407234128086107750744357599."; - m58 *= m59; EXPECT_EQ(m58, "-2746346239559064920182969835886906507653227443918819500198666571439304733199503008341052552775145518642304582533642197483039640878257707005673034647610777."); - Aesi512 m60 = "6302676360590909706620715838468660362667612544859194466582607743567915474439.", m61 = "-582976075810471997473672860251947465139793963553221661659563575140065897655."; - m60 *= m61; EXPECT_EQ(m60, "-3674309531800715920843359862135800139293442995590667629357495440264060818420232004016871635018414723016399436054842101546186062611402092809463742540545."); - Aesi512 m62 = "12512635270252669167580271702228688287035781914232376824135416546464161783549.", m63 = "-76722598222947052467485493586130075935941982912985047811369788092239318244225."; - m62 *= m63; EXPECT_EQ(m62, "-960001888549872047074787179961472046368568639084456017864844997419887955678760306746718893787678072531483746678375460264065679485095718028433291169254525."); - Aesi512 m64 = "111584718477210146235623592938357869858039334747628790449615654209525982646127.", m65 = "63230999738922331871978496835441162954828182167438238941829795568602846256233."; - m64 *= m65; EXPECT_EQ(m64, "7055613304900196657872935890303154626309023008129783087070126846596832488216903683925683064548310359090023919442190395127074139966071922568894188807059591."); - Aesi512 m66 = "-5881432081579547672666113662778513500921283540474135103300355091058414946954.", m67 = "-66552643072134817726247368976407740471178308049614559211628724929687635935852."; - m66 *= m67; EXPECT_EQ(m66, "391424850078366543534473038167450397677297718271225996987027255451097283187193891831819326030508264208750869901036398109315371932554058255514458726794808."); - Aesi512 m68 = "60562771541601088867106278735905714846551299928029204960758394965478150805838.", m69 = "-105193795198987381550145926715199059242998391753886587765224440149421252566659."; - m68 *= m69; EXPECT_EQ(m68, "-6370827786230246242546055423166476150314651613336539884995736114714287675001458398973067011789985225161204066485404867217578276649565685516006326661355242."); - Aesi512 m70 = "69032526407890815853083740145347561729747923669372228307244936999448556192671.", m71 = "27245314394000404734406337274912635723037726204366900831250723209735876940762."; - m70 *= m71; EXPECT_EQ(m70, "1880812885395120700181019474611773973577553024135560997073271542411372880593505489747519996438703192722891571386115704737008181288411922613299585725555302."); - Aesi512 m72 = "-22873219284744293026644041715019063624644628336381975521219331344619775942885.", m73 = "4572376944916695549622740982188106794156453312069504822037153363612744701267."; - m72 *= m73; EXPECT_EQ(m72, "-104584980513588754694477342096589323095321346561470376602582359096695933275544675426067875104372752125060933287928692068126886528399207710078542579135295."); - Aesi512 m74 = "-36923178647385330336171611850515995807291922808699907546153270847891698355059.", m75 = "-1165157161601989920855171505713269423548987639105462124921913952642824988626."; - m74 *= m75; EXPECT_EQ(m74, "43021306030110692959201744370391247391998193098692334083901511407388669855561021485825873980658726260631491357039935913502282686669020254338624584558934."); - Aesi512 m76 = "91446686149524733414583577904292165310690025164796317953573752944919019065616.", m77 = "99467315435580276193866023310232044249816236528799779005217381833544299883429."; - m76 *= m77; EXPECT_EQ(m76, "9095956376773286568863176375491241738868503653174458198543880103079197378321216041335701955249256791012627003063221744587636652154999020889387817302077264."); - Aesi512 m78 = "-55204746746202188035971529157355885013592916511398804218626049615393936528709.", m79 = "26733370308459086375594361235092529361023352307500871307305345443904852568396."; - m78 *= m79; EXPECT_EQ(m78, "-1475808937550924932504792682490159639118148706852858816021457123987287858163451358172711067183306905306537534572953379369691901918296063270414343240080764."); -} \ No newline at end of file diff --git a/test/arithmetic/multiplication/signed.cpp b/test/arithmetic/multiplication/signed.cpp new file mode 100755 index 0000000..f4b65b8 --- /dev/null +++ b/test/arithmetic/multiplication/signed.cpp @@ -0,0 +1,78 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Multiplication, Basic) { + Aesi128 zero = 0u, one = 1u; + Aesi128 m0 = 10919396u; + EXPECT_EQ(m0 * 0u, 0u); + EXPECT_EQ(0u * m0, 0u); + EXPECT_EQ(m0 * 1u, 10919396u); + EXPECT_EQ(1u * m0, 10919396u); + + EXPECT_EQ(m0 * zero, 0u); + EXPECT_EQ(m0 * +zero, 0u); + EXPECT_EQ(m0 * one, 10919396u); + EXPECT_EQ(m0 * +one, 10919396u); + + EXPECT_EQ(zero * m0, 0u); + EXPECT_EQ(zero * +m0, 0u); + EXPECT_EQ(one * m0, 10919396u); + EXPECT_EQ(one * +m0, 10919396u); + + EXPECT_EQ(+zero * m0, 0u); + EXPECT_EQ(+zero * +m0, 0u); + EXPECT_EQ(+one * m0, 10919396u); + EXPECT_EQ(+one * +m0, 10919396u); + + m0 *= 0u; EXPECT_EQ(m0, 0u); m0 = 10919396u; + m0 *= zero; EXPECT_EQ(m0, 0u); m0 = 10919396u; + m0 *= +zero; EXPECT_EQ(m0, 0u); m0 = 10919396u; + zero *= m0; EXPECT_EQ(zero, 0u); + zero *= +m0; EXPECT_EQ(zero, 0u); + + m0 *= 1u; EXPECT_EQ(m0, 10919396u); + + m0 *= one; EXPECT_EQ(m0, 10919396u); + m0 *= +one; EXPECT_EQ(m0, 10919396u); + one *= m0; EXPECT_EQ(one, 10919396u); one = 1u; + one *= +m0; EXPECT_EQ(one, 10919396u); +} + +TEST(Signed_Multiplication, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + int first = 0, second = 0; + switch(i % 4) { + case 0: + first = 1, second = 1; break; + case 1: + first = -1, second = -1; break; + case 2: + first = -1, second = 1; break; + default: + first = 1, second = -1; + } + const auto l = first * Generation::getRandomWithBits(blocksNumber * 16 - 110), + r = second * Generation::getRandomWithBits(blocksNumber * 16 - 110); + + Aesi lA = l, rA = r; + EXPECT_EQ(lA * rA, l * r); + + lA *= rA; + EXPECT_EQ(lA, l * r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto factor = Generation::getRandom(); + + Aesi aeu = value; + EXPECT_EQ((aeu * factor) * factor, (value * factor) * factor); + + aeu *= factor; aeu *= factor; + EXPECT_EQ(aeu, (value * factor) * factor); + } +} \ No newline at end of file diff --git a/test/arithmetic/multiplication/unsigned.cpp b/test/arithmetic/multiplication/unsigned.cpp new file mode 100755 index 0000000..3a87c59 --- /dev/null +++ b/test/arithmetic/multiplication/unsigned.cpp @@ -0,0 +1,66 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Multiplication, Basic) { + Aeu128 zero = 0u, one = 1u; + Aeu128 m0 = 10919396u; + EXPECT_EQ(m0 * 0u, 0u); + EXPECT_EQ(0u * m0, 0u); + EXPECT_EQ(m0 * 1u, 10919396u); + EXPECT_EQ(1u * m0, 10919396u); + + EXPECT_EQ(m0 * zero, 0u); + EXPECT_EQ(m0 * +zero, 0u); + EXPECT_EQ(m0 * one, 10919396u); + EXPECT_EQ(m0 * +one, 10919396u); + + EXPECT_EQ(zero * m0, 0u); + EXPECT_EQ(zero * +m0, 0u); + EXPECT_EQ(one * m0, 10919396u); + EXPECT_EQ(one * +m0, 10919396u); + + EXPECT_EQ(+zero * m0, 0u); + EXPECT_EQ(+zero * +m0, 0u); + EXPECT_EQ(+one * m0, 10919396u); + EXPECT_EQ(+one * +m0, 10919396u); + + m0 *= 0u; EXPECT_EQ(m0, 0u); m0 = 10919396u; + m0 *= zero; EXPECT_EQ(m0, 0u); m0 = 10919396u; + m0 *= +zero; EXPECT_EQ(m0, 0u); m0 = 10919396u; + zero *= m0; EXPECT_EQ(zero, 0u); + zero *= +m0; EXPECT_EQ(zero, 0u); + + m0 *= 1u; EXPECT_EQ(m0, 10919396u); + + m0 *= one; EXPECT_EQ(m0, 10919396u); + m0 *= +one; EXPECT_EQ(m0, 10919396u); + one *= m0; EXPECT_EQ(one, 10919396u); one = 1u; + one *= +m0; EXPECT_EQ(one, 10919396u); +} + +TEST(Unsigned_Multiplication, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + // for (std::size_t i = 0; i < testsAmount; ++i) { + // const auto l = Generation::getRandomWithBits(blocksNumber * 16 - 10), + // r = Generation::getRandomWithBits(blocksNumber * 16 - 20); + // Aeu lA = l, rA = r; + // EXPECT_EQ(lA * rA, l * r); + // + // lA *= rA; + // EXPECT_EQ(lA, l * r); + // } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto factorU = Generation::getRandom(); + + Aeu aeu = value; + EXPECT_EQ(aeu * factorU, value * factorU); + + aeu *= factorU; + EXPECT_EQ(aeu, value * factorU); + } +} \ No newline at end of file diff --git a/test/arithmetic/odd_even.cpp b/test/arithmetic/odd_even.cpp old mode 100644 new mode 100755 index 818cdea..df5e9ea --- a/test/arithmetic/odd_even.cpp +++ b/test/arithmetic/odd_even.cpp @@ -1,37 +1,28 @@ #include +#include "../../Aeu.h" #include "../../Aesi.h" +#include "../generation.h" -TEST(OddEven, Basic) { - Aesi512 zero = 0; EXPECT_EQ(zero.isOdd(), 0); EXPECT_EQ(zero.isEven(), 1); +TEST(Signed_OddEven, Basic) { + Aesi256 zero = 0u; EXPECT_EQ(zero.isOdd(), 0); EXPECT_EQ(zero.isEven(), 1); - Aesi512 b0 = "1504499442701679703283353229512838841."; EXPECT_EQ(b0.isOdd(), 1); EXPECT_EQ(b0.isEven(), 0); - Aesi512 b1 = "75267792841342609453966921724913298190."; EXPECT_EQ(b1.isOdd(), 0); EXPECT_EQ(b1.isEven(), 1); - Aesi512 b2 = "38290638815437921472293774443707254466."; EXPECT_EQ(b2.isOdd(), 0); EXPECT_EQ(b2.isEven(), 1); - Aesi512 b3 = "13552452474699269705156907470282226627."; EXPECT_EQ(b3.isOdd(), 1); EXPECT_EQ(b3.isEven(), 0); - Aesi512 b4 = "45184158506980729098944635026233443858."; EXPECT_EQ(b4.isOdd(), 0); EXPECT_EQ(b4.isEven(), 1); - Aesi512 b5 = "299185706084650872545649820097877852116."; EXPECT_EQ(b5.isOdd(), 0); EXPECT_EQ(b5.isEven(), 1); - Aesi512 b6 = "183874704277197132364079607322520935602."; EXPECT_EQ(b6.isOdd(), 0); EXPECT_EQ(b6.isEven(), 1); - Aesi512 b7 = "174348415283411390314707588358772230021."; EXPECT_EQ(b7.isOdd(), 1); EXPECT_EQ(b7.isEven(), 0); - Aesi512 b8 = "325876819472454546044757426639448312007."; EXPECT_EQ(b8.isOdd(), 1); EXPECT_EQ(b8.isEven(), 0); - Aesi512 b9 = "109221838854393003832592125856116393346."; EXPECT_EQ(b9.isOdd(), 0); EXPECT_EQ(b9.isEven(), 1); - Aesi512 b10 = "112547311193002832625906577858619967034."; EXPECT_EQ(b10.isOdd(), 0); EXPECT_EQ(b10.isEven(), 1); - Aesi512 b11 = "241386547211306827456995371125296783326."; EXPECT_EQ(b11.isOdd(), 0); EXPECT_EQ(b11.isEven(), 1); - Aesi512 b12 = "167697364924998308974097968842057892600."; EXPECT_EQ(b12.isOdd(), 0); EXPECT_EQ(b12.isEven(), 1); - Aesi512 b13 = "133793363458196345923919805668584007364."; EXPECT_EQ(b13.isOdd(), 0); EXPECT_EQ(b13.isEven(), 1); - Aesi512 b14 = "119925814288609897540256455991489590092."; EXPECT_EQ(b14.isOdd(), 0); EXPECT_EQ(b14.isEven(), 1); - Aesi512 b15 = "201892776470575754296117230658447241997."; EXPECT_EQ(b15.isOdd(), 1); EXPECT_EQ(b15.isEven(), 0); - Aesi512 b16 = "60622111226129611870083723570350722730."; EXPECT_EQ(b16.isOdd(), 0); EXPECT_EQ(b16.isEven(), 1); - Aesi512 b17 = "28104225366523456785814246983632754236."; EXPECT_EQ(b17.isOdd(), 0); EXPECT_EQ(b17.isEven(), 1); - Aesi512 b18 = "66344556399460974016833253266109182468."; EXPECT_EQ(b18.isOdd(), 0); EXPECT_EQ(b18.isEven(), 1); - Aesi512 b19 = "265025883143537362530260946155903888339."; EXPECT_EQ(b19.isOdd(), 1); EXPECT_EQ(b19.isEven(), 0); - Aesi512 b20 = "21355450598210293200196475110049906414."; EXPECT_EQ(b20.isOdd(), 0); EXPECT_EQ(b20.isEven(), 1); - Aesi512 b21 = "31384149886634599848985984892315730890."; EXPECT_EQ(b21.isOdd(), 0); EXPECT_EQ(b21.isEven(), 1); - Aesi512 b22 = "335674895245243943292513476931459054549."; EXPECT_EQ(b22.isOdd(), 1); EXPECT_EQ(b22.isEven(), 0); - Aesi512 b23 = "257796587513314343306387428247480909212."; EXPECT_EQ(b23.isOdd(), 0); EXPECT_EQ(b23.isEven(), 1); - Aesi512 b24 = "101180530727463972101866207961697996453."; EXPECT_EQ(b24.isOdd(), 1); EXPECT_EQ(b24.isEven(), 0); - Aesi512 b25 = "215071716390906651489416811571970955441."; EXPECT_EQ(b25.isOdd(), 1); EXPECT_EQ(b25.isEven(), 0); - Aesi512 b26 = "34105924325919166892756641331604301936."; EXPECT_EQ(b26.isOdd(), 0); EXPECT_EQ(b26.isEven(), 1); - Aesi512 b27 = "58446929804058110604077386122484253003."; EXPECT_EQ(b27.isOdd(), 1); EXPECT_EQ(b27.isEven(), 0); - Aesi512 b28 = "221186673493144611395088919473087294307."; EXPECT_EQ(b28.isOdd(), 1); EXPECT_EQ(b28.isEven(), 0); - Aesi512 b29 = "162251677695606858198966267606861399521."; EXPECT_EQ(b29.isOdd(), 1); EXPECT_EQ(b29.isEven(), 0); + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 10); + Aesi aesi = value; + EXPECT_EQ(value.IsEven(), aesi.isEven()); + EXPECT_EQ(value.IsOdd(), aesi.isOdd()); + } +} + +TEST(Unsigned_OddEven, Basic) { + Aeu256 zero = 0u; EXPECT_EQ(zero.isOdd(), 0); EXPECT_EQ(zero.isEven(), 1); + + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 10); + Aeu aeu = value; + EXPECT_EQ(value.IsEven(), aeu.isEven()); + EXPECT_EQ(value.IsOdd(), aeu.isOdd()); + } } \ No newline at end of file diff --git a/test/arithmetic/power2.cpp b/test/arithmetic/power2.cpp old mode 100644 new mode 100755 index f7d65d8..cbb6091 --- a/test/arithmetic/power2.cpp +++ b/test/arithmetic/power2.cpp @@ -1,529 +1,20 @@ #include +#include "../../Aeu.h" #include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" +#include -TEST(Power2, Power2) { - const auto timeStart = std::chrono::system_clock::now(); +TEST(Signed, Power2) { + for (std::size_t i = 0; i < 511; ++i) { + std::stringstream ss; ss << "0x" << std::hex << CryptoPP::Integer::Power2(i); + EXPECT_EQ(Aesi512::power2(i), ss.str()); + } + EXPECT_EQ(Aesi512::power2(512), 0u); +} - EXPECT_EQ(Aesi512::power2(0), "1."); - EXPECT_EQ(Aesi512::power2(1), "2."); - EXPECT_EQ(Aesi512::power2(2), "4."); - EXPECT_EQ(Aesi512::power2(3), "8."); - EXPECT_EQ(Aesi512::power2(4), "16."); - EXPECT_EQ(Aesi512::power2(5), "32."); - EXPECT_EQ(Aesi512::power2(6), "64."); - EXPECT_EQ(Aesi512::power2(7), "128."); - EXPECT_EQ(Aesi512::power2(8), "256."); - EXPECT_EQ(Aesi512::power2(9), "512."); - EXPECT_EQ(Aesi512::power2(10), "1024."); - EXPECT_EQ(Aesi512::power2(11), "2048."); - EXPECT_EQ(Aesi512::power2(12), "4096."); - EXPECT_EQ(Aesi512::power2(13), "8192."); - EXPECT_EQ(Aesi512::power2(14), "16384."); - EXPECT_EQ(Aesi512::power2(15), "32768."); - EXPECT_EQ(Aesi512::power2(16), "65536."); - EXPECT_EQ(Aesi512::power2(17), "131072."); - EXPECT_EQ(Aesi512::power2(18), "262144."); - EXPECT_EQ(Aesi512::power2(19), "524288."); - EXPECT_EQ(Aesi512::power2(20), "1048576."); - EXPECT_EQ(Aesi512::power2(21), "2097152."); - EXPECT_EQ(Aesi512::power2(22), "4194304."); - EXPECT_EQ(Aesi512::power2(23), "8388608."); - EXPECT_EQ(Aesi512::power2(24), "16777216."); - EXPECT_EQ(Aesi512::power2(25), "33554432."); - EXPECT_EQ(Aesi512::power2(26), "67108864."); - EXPECT_EQ(Aesi512::power2(27), "134217728."); - EXPECT_EQ(Aesi512::power2(28), "268435456."); - EXPECT_EQ(Aesi512::power2(29), "536870912."); - EXPECT_EQ(Aesi512::power2(30), "1073741824."); - EXPECT_EQ(Aesi512::power2(31), "2147483648."); - EXPECT_EQ(Aesi512::power2(32), "4294967296."); - EXPECT_EQ(Aesi512::power2(33), "8589934592."); - EXPECT_EQ(Aesi512::power2(34), "17179869184."); - EXPECT_EQ(Aesi512::power2(35), "34359738368."); - EXPECT_EQ(Aesi512::power2(36), "68719476736."); - EXPECT_EQ(Aesi512::power2(37), "137438953472."); - EXPECT_EQ(Aesi512::power2(38), "274877906944."); - EXPECT_EQ(Aesi512::power2(39), "549755813888."); - EXPECT_EQ(Aesi512::power2(40), "1099511627776."); - EXPECT_EQ(Aesi512::power2(41), "2199023255552."); - EXPECT_EQ(Aesi512::power2(42), "4398046511104."); - EXPECT_EQ(Aesi512::power2(43), "8796093022208."); - EXPECT_EQ(Aesi512::power2(44), "17592186044416."); - EXPECT_EQ(Aesi512::power2(45), "35184372088832."); - EXPECT_EQ(Aesi512::power2(46), "70368744177664."); - EXPECT_EQ(Aesi512::power2(47), "140737488355328."); - EXPECT_EQ(Aesi512::power2(48), "281474976710656."); - EXPECT_EQ(Aesi512::power2(49), "562949953421312."); - EXPECT_EQ(Aesi512::power2(50), "1125899906842624."); - EXPECT_EQ(Aesi512::power2(51), "2251799813685248."); - EXPECT_EQ(Aesi512::power2(52), "4503599627370496."); - EXPECT_EQ(Aesi512::power2(53), "9007199254740992."); - EXPECT_EQ(Aesi512::power2(54), "18014398509481984."); - EXPECT_EQ(Aesi512::power2(55), "36028797018963968."); - EXPECT_EQ(Aesi512::power2(56), "72057594037927936."); - EXPECT_EQ(Aesi512::power2(57), "144115188075855872."); - EXPECT_EQ(Aesi512::power2(58), "288230376151711744."); - EXPECT_EQ(Aesi512::power2(59), "576460752303423488."); - EXPECT_EQ(Aesi512::power2(60), "1152921504606846976."); - EXPECT_EQ(Aesi512::power2(61), "2305843009213693952."); - EXPECT_EQ(Aesi512::power2(62), "4611686018427387904."); - EXPECT_EQ(Aesi512::power2(63), "9223372036854775808."); - EXPECT_EQ(Aesi512::power2(64), "18446744073709551616."); - EXPECT_EQ(Aesi512::power2(65), "36893488147419103232."); - EXPECT_EQ(Aesi512::power2(66), "73786976294838206464."); - EXPECT_EQ(Aesi512::power2(67), "147573952589676412928."); - EXPECT_EQ(Aesi512::power2(68), "295147905179352825856."); - EXPECT_EQ(Aesi512::power2(69), "590295810358705651712."); - EXPECT_EQ(Aesi512::power2(70), "1180591620717411303424."); - EXPECT_EQ(Aesi512::power2(71), "2361183241434822606848."); - EXPECT_EQ(Aesi512::power2(72), "4722366482869645213696."); - EXPECT_EQ(Aesi512::power2(73), "9444732965739290427392."); - EXPECT_EQ(Aesi512::power2(74), "18889465931478580854784."); - EXPECT_EQ(Aesi512::power2(75), "37778931862957161709568."); - EXPECT_EQ(Aesi512::power2(76), "75557863725914323419136."); - EXPECT_EQ(Aesi512::power2(77), "151115727451828646838272."); - EXPECT_EQ(Aesi512::power2(78), "302231454903657293676544."); - EXPECT_EQ(Aesi512::power2(79), "604462909807314587353088."); - EXPECT_EQ(Aesi512::power2(80), "1208925819614629174706176."); - EXPECT_EQ(Aesi512::power2(81), "2417851639229258349412352."); - EXPECT_EQ(Aesi512::power2(82), "4835703278458516698824704."); - EXPECT_EQ(Aesi512::power2(83), "9671406556917033397649408."); - EXPECT_EQ(Aesi512::power2(84), "19342813113834066795298816."); - EXPECT_EQ(Aesi512::power2(85), "38685626227668133590597632."); - EXPECT_EQ(Aesi512::power2(86), "77371252455336267181195264."); - EXPECT_EQ(Aesi512::power2(87), "154742504910672534362390528."); - EXPECT_EQ(Aesi512::power2(88), "309485009821345068724781056."); - EXPECT_EQ(Aesi512::power2(89), "618970019642690137449562112."); - EXPECT_EQ(Aesi512::power2(90), "1237940039285380274899124224."); - EXPECT_EQ(Aesi512::power2(91), "2475880078570760549798248448."); - EXPECT_EQ(Aesi512::power2(92), "4951760157141521099596496896."); - EXPECT_EQ(Aesi512::power2(93), "9903520314283042199192993792."); - EXPECT_EQ(Aesi512::power2(94), "19807040628566084398385987584."); - EXPECT_EQ(Aesi512::power2(95), "39614081257132168796771975168."); - EXPECT_EQ(Aesi512::power2(96), "79228162514264337593543950336."); - EXPECT_EQ(Aesi512::power2(97), "158456325028528675187087900672."); - EXPECT_EQ(Aesi512::power2(98), "316912650057057350374175801344."); - EXPECT_EQ(Aesi512::power2(99), "633825300114114700748351602688."); - EXPECT_EQ(Aesi512::power2(100), "1267650600228229401496703205376."); - EXPECT_EQ(Aesi512::power2(101), "2535301200456458802993406410752."); - EXPECT_EQ(Aesi512::power2(102), "5070602400912917605986812821504."); - EXPECT_EQ(Aesi512::power2(103), "10141204801825835211973625643008."); - EXPECT_EQ(Aesi512::power2(104), "20282409603651670423947251286016."); - EXPECT_EQ(Aesi512::power2(105), "40564819207303340847894502572032."); - EXPECT_EQ(Aesi512::power2(106), "81129638414606681695789005144064."); - EXPECT_EQ(Aesi512::power2(107), "162259276829213363391578010288128."); - EXPECT_EQ(Aesi512::power2(108), "324518553658426726783156020576256."); - EXPECT_EQ(Aesi512::power2(109), "649037107316853453566312041152512."); - EXPECT_EQ(Aesi512::power2(110), "1298074214633706907132624082305024."); - EXPECT_EQ(Aesi512::power2(111), "2596148429267413814265248164610048."); - EXPECT_EQ(Aesi512::power2(112), "5192296858534827628530496329220096."); - EXPECT_EQ(Aesi512::power2(113), "10384593717069655257060992658440192."); - EXPECT_EQ(Aesi512::power2(114), "20769187434139310514121985316880384."); - EXPECT_EQ(Aesi512::power2(115), "41538374868278621028243970633760768."); - EXPECT_EQ(Aesi512::power2(116), "83076749736557242056487941267521536."); - EXPECT_EQ(Aesi512::power2(117), "166153499473114484112975882535043072."); - EXPECT_EQ(Aesi512::power2(118), "332306998946228968225951765070086144."); - EXPECT_EQ(Aesi512::power2(119), "664613997892457936451903530140172288."); - EXPECT_EQ(Aesi512::power2(120), "1329227995784915872903807060280344576."); - EXPECT_EQ(Aesi512::power2(121), "2658455991569831745807614120560689152."); - EXPECT_EQ(Aesi512::power2(122), "5316911983139663491615228241121378304."); - EXPECT_EQ(Aesi512::power2(123), "10633823966279326983230456482242756608."); - EXPECT_EQ(Aesi512::power2(124), "21267647932558653966460912964485513216."); - EXPECT_EQ(Aesi512::power2(125), "42535295865117307932921825928971026432."); - EXPECT_EQ(Aesi512::power2(126), "85070591730234615865843651857942052864."); - EXPECT_EQ(Aesi512::power2(127), "170141183460469231731687303715884105728."); - EXPECT_EQ(Aesi512::power2(128), "340282366920938463463374607431768211456."); - EXPECT_EQ(Aesi512::power2(129), "680564733841876926926749214863536422912."); - EXPECT_EQ(Aesi512::power2(130), "1361129467683753853853498429727072845824."); - EXPECT_EQ(Aesi512::power2(131), "2722258935367507707706996859454145691648."); - EXPECT_EQ(Aesi512::power2(132), "5444517870735015415413993718908291383296."); - EXPECT_EQ(Aesi512::power2(133), "10889035741470030830827987437816582766592."); - EXPECT_EQ(Aesi512::power2(134), "21778071482940061661655974875633165533184."); - EXPECT_EQ(Aesi512::power2(135), "43556142965880123323311949751266331066368."); - EXPECT_EQ(Aesi512::power2(136), "87112285931760246646623899502532662132736."); - EXPECT_EQ(Aesi512::power2(137), "174224571863520493293247799005065324265472."); - EXPECT_EQ(Aesi512::power2(138), "348449143727040986586495598010130648530944."); - EXPECT_EQ(Aesi512::power2(139), "696898287454081973172991196020261297061888."); - EXPECT_EQ(Aesi512::power2(140), "1393796574908163946345982392040522594123776."); - EXPECT_EQ(Aesi512::power2(141), "2787593149816327892691964784081045188247552."); - EXPECT_EQ(Aesi512::power2(142), "5575186299632655785383929568162090376495104."); - EXPECT_EQ(Aesi512::power2(143), "11150372599265311570767859136324180752990208."); - EXPECT_EQ(Aesi512::power2(144), "22300745198530623141535718272648361505980416."); - EXPECT_EQ(Aesi512::power2(145), "44601490397061246283071436545296723011960832."); - EXPECT_EQ(Aesi512::power2(146), "89202980794122492566142873090593446023921664."); - EXPECT_EQ(Aesi512::power2(147), "178405961588244985132285746181186892047843328."); - EXPECT_EQ(Aesi512::power2(148), "356811923176489970264571492362373784095686656."); - EXPECT_EQ(Aesi512::power2(149), "713623846352979940529142984724747568191373312."); - EXPECT_EQ(Aesi512::power2(150), "1427247692705959881058285969449495136382746624."); - EXPECT_EQ(Aesi512::power2(151), "2854495385411919762116571938898990272765493248."); - EXPECT_EQ(Aesi512::power2(152), "5708990770823839524233143877797980545530986496."); - EXPECT_EQ(Aesi512::power2(153), "11417981541647679048466287755595961091061972992."); - EXPECT_EQ(Aesi512::power2(154), "22835963083295358096932575511191922182123945984."); - EXPECT_EQ(Aesi512::power2(155), "45671926166590716193865151022383844364247891968."); - EXPECT_EQ(Aesi512::power2(156), "91343852333181432387730302044767688728495783936."); - EXPECT_EQ(Aesi512::power2(157), "182687704666362864775460604089535377456991567872."); - EXPECT_EQ(Aesi512::power2(158), "365375409332725729550921208179070754913983135744."); - EXPECT_EQ(Aesi512::power2(159), "730750818665451459101842416358141509827966271488."); - EXPECT_EQ(Aesi512::power2(160), "1461501637330902918203684832716283019655932542976."); - EXPECT_EQ(Aesi512::power2(161), "2923003274661805836407369665432566039311865085952."); - EXPECT_EQ(Aesi512::power2(162), "5846006549323611672814739330865132078623730171904."); - EXPECT_EQ(Aesi512::power2(163), "11692013098647223345629478661730264157247460343808."); - EXPECT_EQ(Aesi512::power2(164), "23384026197294446691258957323460528314494920687616."); - EXPECT_EQ(Aesi512::power2(165), "46768052394588893382517914646921056628989841375232."); - EXPECT_EQ(Aesi512::power2(166), "93536104789177786765035829293842113257979682750464."); - EXPECT_EQ(Aesi512::power2(167), "187072209578355573530071658587684226515959365500928."); - EXPECT_EQ(Aesi512::power2(168), "374144419156711147060143317175368453031918731001856."); - EXPECT_EQ(Aesi512::power2(169), "748288838313422294120286634350736906063837462003712."); - EXPECT_EQ(Aesi512::power2(170), "1496577676626844588240573268701473812127674924007424."); - EXPECT_EQ(Aesi512::power2(171), "2993155353253689176481146537402947624255349848014848."); - EXPECT_EQ(Aesi512::power2(172), "5986310706507378352962293074805895248510699696029696."); - EXPECT_EQ(Aesi512::power2(173), "11972621413014756705924586149611790497021399392059392."); - EXPECT_EQ(Aesi512::power2(174), "23945242826029513411849172299223580994042798784118784."); - EXPECT_EQ(Aesi512::power2(175), "47890485652059026823698344598447161988085597568237568."); - EXPECT_EQ(Aesi512::power2(176), "95780971304118053647396689196894323976171195136475136."); - EXPECT_EQ(Aesi512::power2(177), "191561942608236107294793378393788647952342390272950272."); - EXPECT_EQ(Aesi512::power2(178), "383123885216472214589586756787577295904684780545900544."); - EXPECT_EQ(Aesi512::power2(179), "766247770432944429179173513575154591809369561091801088."); - EXPECT_EQ(Aesi512::power2(180), "1532495540865888858358347027150309183618739122183602176."); - EXPECT_EQ(Aesi512::power2(181), "3064991081731777716716694054300618367237478244367204352."); - EXPECT_EQ(Aesi512::power2(182), "6129982163463555433433388108601236734474956488734408704."); - EXPECT_EQ(Aesi512::power2(183), "12259964326927110866866776217202473468949912977468817408."); - EXPECT_EQ(Aesi512::power2(184), "24519928653854221733733552434404946937899825954937634816."); - EXPECT_EQ(Aesi512::power2(185), "49039857307708443467467104868809893875799651909875269632."); - EXPECT_EQ(Aesi512::power2(186), "98079714615416886934934209737619787751599303819750539264."); - EXPECT_EQ(Aesi512::power2(187), "196159429230833773869868419475239575503198607639501078528."); - EXPECT_EQ(Aesi512::power2(188), "392318858461667547739736838950479151006397215279002157056."); - EXPECT_EQ(Aesi512::power2(189), "784637716923335095479473677900958302012794430558004314112."); - EXPECT_EQ(Aesi512::power2(190), "1569275433846670190958947355801916604025588861116008628224."); - EXPECT_EQ(Aesi512::power2(191), "3138550867693340381917894711603833208051177722232017256448."); - EXPECT_EQ(Aesi512::power2(192), "6277101735386680763835789423207666416102355444464034512896."); - EXPECT_EQ(Aesi512::power2(193), "12554203470773361527671578846415332832204710888928069025792."); - EXPECT_EQ(Aesi512::power2(194), "25108406941546723055343157692830665664409421777856138051584."); - EXPECT_EQ(Aesi512::power2(195), "50216813883093446110686315385661331328818843555712276103168."); - EXPECT_EQ(Aesi512::power2(196), "100433627766186892221372630771322662657637687111424552206336."); - EXPECT_EQ(Aesi512::power2(197), "200867255532373784442745261542645325315275374222849104412672."); - EXPECT_EQ(Aesi512::power2(198), "401734511064747568885490523085290650630550748445698208825344."); - EXPECT_EQ(Aesi512::power2(199), "803469022129495137770981046170581301261101496891396417650688."); - EXPECT_EQ(Aesi512::power2(200), "1606938044258990275541962092341162602522202993782792835301376."); - EXPECT_EQ(Aesi512::power2(201), "3213876088517980551083924184682325205044405987565585670602752."); - EXPECT_EQ(Aesi512::power2(202), "6427752177035961102167848369364650410088811975131171341205504."); - EXPECT_EQ(Aesi512::power2(203), "12855504354071922204335696738729300820177623950262342682411008."); - EXPECT_EQ(Aesi512::power2(204), "25711008708143844408671393477458601640355247900524685364822016."); - EXPECT_EQ(Aesi512::power2(205), "51422017416287688817342786954917203280710495801049370729644032."); - EXPECT_EQ(Aesi512::power2(206), "102844034832575377634685573909834406561420991602098741459288064."); - EXPECT_EQ(Aesi512::power2(207), "205688069665150755269371147819668813122841983204197482918576128."); - EXPECT_EQ(Aesi512::power2(208), "411376139330301510538742295639337626245683966408394965837152256."); - EXPECT_EQ(Aesi512::power2(209), "822752278660603021077484591278675252491367932816789931674304512."); - EXPECT_EQ(Aesi512::power2(210), "1645504557321206042154969182557350504982735865633579863348609024."); - EXPECT_EQ(Aesi512::power2(211), "3291009114642412084309938365114701009965471731267159726697218048."); - EXPECT_EQ(Aesi512::power2(212), "6582018229284824168619876730229402019930943462534319453394436096."); - EXPECT_EQ(Aesi512::power2(213), "13164036458569648337239753460458804039861886925068638906788872192."); - EXPECT_EQ(Aesi512::power2(214), "26328072917139296674479506920917608079723773850137277813577744384."); - EXPECT_EQ(Aesi512::power2(215), "52656145834278593348959013841835216159447547700274555627155488768."); - EXPECT_EQ(Aesi512::power2(216), "105312291668557186697918027683670432318895095400549111254310977536."); - EXPECT_EQ(Aesi512::power2(217), "210624583337114373395836055367340864637790190801098222508621955072."); - EXPECT_EQ(Aesi512::power2(218), "421249166674228746791672110734681729275580381602196445017243910144."); - EXPECT_EQ(Aesi512::power2(219), "842498333348457493583344221469363458551160763204392890034487820288."); - EXPECT_EQ(Aesi512::power2(220), "1684996666696914987166688442938726917102321526408785780068975640576."); - EXPECT_EQ(Aesi512::power2(221), "3369993333393829974333376885877453834204643052817571560137951281152."); - EXPECT_EQ(Aesi512::power2(222), "6739986666787659948666753771754907668409286105635143120275902562304."); - EXPECT_EQ(Aesi512::power2(223), "13479973333575319897333507543509815336818572211270286240551805124608."); - EXPECT_EQ(Aesi512::power2(224), "26959946667150639794667015087019630673637144422540572481103610249216."); - EXPECT_EQ(Aesi512::power2(225), "53919893334301279589334030174039261347274288845081144962207220498432."); - EXPECT_EQ(Aesi512::power2(226), "107839786668602559178668060348078522694548577690162289924414440996864."); - EXPECT_EQ(Aesi512::power2(227), "215679573337205118357336120696157045389097155380324579848828881993728."); - EXPECT_EQ(Aesi512::power2(228), "431359146674410236714672241392314090778194310760649159697657763987456."); - EXPECT_EQ(Aesi512::power2(229), "862718293348820473429344482784628181556388621521298319395315527974912."); - EXPECT_EQ(Aesi512::power2(230), "1725436586697640946858688965569256363112777243042596638790631055949824."); - EXPECT_EQ(Aesi512::power2(231), "3450873173395281893717377931138512726225554486085193277581262111899648."); - EXPECT_EQ(Aesi512::power2(232), "6901746346790563787434755862277025452451108972170386555162524223799296."); - EXPECT_EQ(Aesi512::power2(233), "13803492693581127574869511724554050904902217944340773110325048447598592."); - EXPECT_EQ(Aesi512::power2(234), "27606985387162255149739023449108101809804435888681546220650096895197184."); - EXPECT_EQ(Aesi512::power2(235), "55213970774324510299478046898216203619608871777363092441300193790394368."); - EXPECT_EQ(Aesi512::power2(236), "110427941548649020598956093796432407239217743554726184882600387580788736."); - EXPECT_EQ(Aesi512::power2(237), "220855883097298041197912187592864814478435487109452369765200775161577472."); - EXPECT_EQ(Aesi512::power2(238), "441711766194596082395824375185729628956870974218904739530401550323154944."); - EXPECT_EQ(Aesi512::power2(239), "883423532389192164791648750371459257913741948437809479060803100646309888."); - EXPECT_EQ(Aesi512::power2(240), "1766847064778384329583297500742918515827483896875618958121606201292619776."); - EXPECT_EQ(Aesi512::power2(241), "3533694129556768659166595001485837031654967793751237916243212402585239552."); - EXPECT_EQ(Aesi512::power2(242), "7067388259113537318333190002971674063309935587502475832486424805170479104."); - EXPECT_EQ(Aesi512::power2(243), "14134776518227074636666380005943348126619871175004951664972849610340958208."); - EXPECT_EQ(Aesi512::power2(244), "28269553036454149273332760011886696253239742350009903329945699220681916416."); - EXPECT_EQ(Aesi512::power2(245), "56539106072908298546665520023773392506479484700019806659891398441363832832."); - EXPECT_EQ(Aesi512::power2(246), "113078212145816597093331040047546785012958969400039613319782796882727665664."); - EXPECT_EQ(Aesi512::power2(247), "226156424291633194186662080095093570025917938800079226639565593765455331328."); - EXPECT_EQ(Aesi512::power2(248), "452312848583266388373324160190187140051835877600158453279131187530910662656."); - EXPECT_EQ(Aesi512::power2(249), "904625697166532776746648320380374280103671755200316906558262375061821325312."); - EXPECT_EQ(Aesi512::power2(250), "1809251394333065553493296640760748560207343510400633813116524750123642650624."); - EXPECT_EQ(Aesi512::power2(251), "3618502788666131106986593281521497120414687020801267626233049500247285301248."); - EXPECT_EQ(Aesi512::power2(252), "7237005577332262213973186563042994240829374041602535252466099000494570602496."); - EXPECT_EQ(Aesi512::power2(253), "14474011154664524427946373126085988481658748083205070504932198000989141204992."); - EXPECT_EQ(Aesi512::power2(254), "28948022309329048855892746252171976963317496166410141009864396001978282409984."); - EXPECT_EQ(Aesi512::power2(255), "57896044618658097711785492504343953926634992332820282019728792003956564819968."); - EXPECT_EQ(Aesi512::power2(256), "115792089237316195423570985008687907853269984665640564039457584007913129639936."); - EXPECT_EQ(Aesi512::power2(257), "231584178474632390847141970017375815706539969331281128078915168015826259279872."); - EXPECT_EQ(Aesi512::power2(258), "463168356949264781694283940034751631413079938662562256157830336031652518559744."); - EXPECT_EQ(Aesi512::power2(259), "926336713898529563388567880069503262826159877325124512315660672063305037119488."); - EXPECT_EQ(Aesi512::power2(260), "1852673427797059126777135760139006525652319754650249024631321344126610074238976."); - EXPECT_EQ(Aesi512::power2(261), "3705346855594118253554271520278013051304639509300498049262642688253220148477952."); - EXPECT_EQ(Aesi512::power2(262), "7410693711188236507108543040556026102609279018600996098525285376506440296955904."); - EXPECT_EQ(Aesi512::power2(263), "14821387422376473014217086081112052205218558037201992197050570753012880593911808."); - EXPECT_EQ(Aesi512::power2(264), "29642774844752946028434172162224104410437116074403984394101141506025761187823616."); - EXPECT_EQ(Aesi512::power2(265), "59285549689505892056868344324448208820874232148807968788202283012051522375647232."); - EXPECT_EQ(Aesi512::power2(266), "118571099379011784113736688648896417641748464297615937576404566024103044751294464."); - EXPECT_EQ(Aesi512::power2(267), "237142198758023568227473377297792835283496928595231875152809132048206089502588928."); - EXPECT_EQ(Aesi512::power2(268), "474284397516047136454946754595585670566993857190463750305618264096412179005177856."); - EXPECT_EQ(Aesi512::power2(269), "948568795032094272909893509191171341133987714380927500611236528192824358010355712."); - EXPECT_EQ(Aesi512::power2(270), "1897137590064188545819787018382342682267975428761855001222473056385648716020711424."); - EXPECT_EQ(Aesi512::power2(271), "3794275180128377091639574036764685364535950857523710002444946112771297432041422848."); - EXPECT_EQ(Aesi512::power2(272), "7588550360256754183279148073529370729071901715047420004889892225542594864082845696."); - EXPECT_EQ(Aesi512::power2(273), "15177100720513508366558296147058741458143803430094840009779784451085189728165691392."); - EXPECT_EQ(Aesi512::power2(274), "30354201441027016733116592294117482916287606860189680019559568902170379456331382784."); - EXPECT_EQ(Aesi512::power2(275), "60708402882054033466233184588234965832575213720379360039119137804340758912662765568."); - EXPECT_EQ(Aesi512::power2(276), "121416805764108066932466369176469931665150427440758720078238275608681517825325531136."); - EXPECT_EQ(Aesi512::power2(277), "242833611528216133864932738352939863330300854881517440156476551217363035650651062272."); - EXPECT_EQ(Aesi512::power2(278), "485667223056432267729865476705879726660601709763034880312953102434726071301302124544."); - EXPECT_EQ(Aesi512::power2(279), "971334446112864535459730953411759453321203419526069760625906204869452142602604249088."); - EXPECT_EQ(Aesi512::power2(280), "1942668892225729070919461906823518906642406839052139521251812409738904285205208498176."); - EXPECT_EQ(Aesi512::power2(281), "3885337784451458141838923813647037813284813678104279042503624819477808570410416996352."); - EXPECT_EQ(Aesi512::power2(282), "7770675568902916283677847627294075626569627356208558085007249638955617140820833992704."); - EXPECT_EQ(Aesi512::power2(283), "15541351137805832567355695254588151253139254712417116170014499277911234281641667985408."); - EXPECT_EQ(Aesi512::power2(284), "31082702275611665134711390509176302506278509424834232340028998555822468563283335970816."); - EXPECT_EQ(Aesi512::power2(285), "62165404551223330269422781018352605012557018849668464680057997111644937126566671941632."); - EXPECT_EQ(Aesi512::power2(286), "124330809102446660538845562036705210025114037699336929360115994223289874253133343883264."); - EXPECT_EQ(Aesi512::power2(287), "248661618204893321077691124073410420050228075398673858720231988446579748506266687766528."); - EXPECT_EQ(Aesi512::power2(288), "497323236409786642155382248146820840100456150797347717440463976893159497012533375533056."); - EXPECT_EQ(Aesi512::power2(289), "994646472819573284310764496293641680200912301594695434880927953786318994025066751066112."); - EXPECT_EQ(Aesi512::power2(290), "1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224."); - EXPECT_EQ(Aesi512::power2(291), "3978585891278293137243057985174566720803649206378781739523711815145275976100267004264448."); - EXPECT_EQ(Aesi512::power2(292), "7957171782556586274486115970349133441607298412757563479047423630290551952200534008528896."); - EXPECT_EQ(Aesi512::power2(293), "15914343565113172548972231940698266883214596825515126958094847260581103904401068017057792."); - EXPECT_EQ(Aesi512::power2(294), "31828687130226345097944463881396533766429193651030253916189694521162207808802136034115584."); - EXPECT_EQ(Aesi512::power2(295), "63657374260452690195888927762793067532858387302060507832379389042324415617604272068231168."); - EXPECT_EQ(Aesi512::power2(296), "127314748520905380391777855525586135065716774604121015664758778084648831235208544136462336."); - EXPECT_EQ(Aesi512::power2(297), "254629497041810760783555711051172270131433549208242031329517556169297662470417088272924672."); - EXPECT_EQ(Aesi512::power2(298), "509258994083621521567111422102344540262867098416484062659035112338595324940834176545849344."); - EXPECT_EQ(Aesi512::power2(299), "1018517988167243043134222844204689080525734196832968125318070224677190649881668353091698688."); - EXPECT_EQ(Aesi512::power2(300), "2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376."); - EXPECT_EQ(Aesi512::power2(301), "4074071952668972172536891376818756322102936787331872501272280898708762599526673412366794752."); - EXPECT_EQ(Aesi512::power2(302), "8148143905337944345073782753637512644205873574663745002544561797417525199053346824733589504."); - EXPECT_EQ(Aesi512::power2(303), "16296287810675888690147565507275025288411747149327490005089123594835050398106693649467179008."); - EXPECT_EQ(Aesi512::power2(304), "32592575621351777380295131014550050576823494298654980010178247189670100796213387298934358016."); - EXPECT_EQ(Aesi512::power2(305), "65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716032."); - EXPECT_EQ(Aesi512::power2(306), "130370302485407109521180524058200202307293977194619920040712988758680403184853549195737432064."); - EXPECT_EQ(Aesi512::power2(307), "260740604970814219042361048116400404614587954389239840081425977517360806369707098391474864128."); - EXPECT_EQ(Aesi512::power2(308), "521481209941628438084722096232800809229175908778479680162851955034721612739414196782949728256."); - EXPECT_EQ(Aesi512::power2(309), "1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512."); - EXPECT_EQ(Aesi512::power2(310), "2085924839766513752338888384931203236916703635113918720651407820138886450957656787131798913024."); - EXPECT_EQ(Aesi512::power2(311), "4171849679533027504677776769862406473833407270227837441302815640277772901915313574263597826048."); - EXPECT_EQ(Aesi512::power2(312), "8343699359066055009355553539724812947666814540455674882605631280555545803830627148527195652096."); - EXPECT_EQ(Aesi512::power2(313), "16687398718132110018711107079449625895333629080911349765211262561111091607661254297054391304192."); - EXPECT_EQ(Aesi512::power2(314), "33374797436264220037422214158899251790667258161822699530422525122222183215322508594108782608384."); - EXPECT_EQ(Aesi512::power2(315), "66749594872528440074844428317798503581334516323645399060845050244444366430645017188217565216768."); - EXPECT_EQ(Aesi512::power2(316), "133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433536."); - EXPECT_EQ(Aesi512::power2(317), "266998379490113760299377713271194014325338065294581596243380200977777465722580068752870260867072."); - EXPECT_EQ(Aesi512::power2(318), "533996758980227520598755426542388028650676130589163192486760401955554931445160137505740521734144."); - EXPECT_EQ(Aesi512::power2(319), "1067993517960455041197510853084776057301352261178326384973520803911109862890320275011481043468288."); - EXPECT_EQ(Aesi512::power2(320), "2135987035920910082395021706169552114602704522356652769947041607822219725780640550022962086936576."); - EXPECT_EQ(Aesi512::power2(321), "4271974071841820164790043412339104229205409044713305539894083215644439451561281100045924173873152."); - EXPECT_EQ(Aesi512::power2(322), "8543948143683640329580086824678208458410818089426611079788166431288878903122562200091848347746304."); - EXPECT_EQ(Aesi512::power2(323), "17087896287367280659160173649356416916821636178853222159576332862577757806245124400183696695492608."); - EXPECT_EQ(Aesi512::power2(324), "34175792574734561318320347298712833833643272357706444319152665725155515612490248800367393390985216."); - EXPECT_EQ(Aesi512::power2(325), "68351585149469122636640694597425667667286544715412888638305331450311031224980497600734786781970432."); - EXPECT_EQ(Aesi512::power2(326), "136703170298938245273281389194851335334573089430825777276610662900622062449960995201469573563940864."); - EXPECT_EQ(Aesi512::power2(327), "273406340597876490546562778389702670669146178861651554553221325801244124899921990402939147127881728."); - EXPECT_EQ(Aesi512::power2(328), "546812681195752981093125556779405341338292357723303109106442651602488249799843980805878294255763456."); - EXPECT_EQ(Aesi512::power2(329), "1093625362391505962186251113558810682676584715446606218212885303204976499599687961611756588511526912."); - EXPECT_EQ(Aesi512::power2(330), "2187250724783011924372502227117621365353169430893212436425770606409952999199375923223513177023053824."); - EXPECT_EQ(Aesi512::power2(331), "4374501449566023848745004454235242730706338861786424872851541212819905998398751846447026354046107648."); - EXPECT_EQ(Aesi512::power2(332), "8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296."); - EXPECT_EQ(Aesi512::power2(333), "17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592."); - EXPECT_EQ(Aesi512::power2(334), "34996011596528190789960035633881941845650710894291398982812329702559247987190014771576210832368861184."); - EXPECT_EQ(Aesi512::power2(335), "69992023193056381579920071267763883691301421788582797965624659405118495974380029543152421664737722368."); - EXPECT_EQ(Aesi512::power2(336), "139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444736."); - EXPECT_EQ(Aesi512::power2(337), "279968092772225526319680285071055534765205687154331191862498637620473983897520118172609686658950889472."); - EXPECT_EQ(Aesi512::power2(338), "559936185544451052639360570142111069530411374308662383724997275240947967795040236345219373317901778944."); - EXPECT_EQ(Aesi512::power2(339), "1119872371088902105278721140284222139060822748617324767449994550481895935590080472690438746635803557888."); - EXPECT_EQ(Aesi512::power2(340), "2239744742177804210557442280568444278121645497234649534899989100963791871180160945380877493271607115776."); - EXPECT_EQ(Aesi512::power2(341), "4479489484355608421114884561136888556243290994469299069799978201927583742360321890761754986543214231552."); - EXPECT_EQ(Aesi512::power2(342), "8958978968711216842229769122273777112486581988938598139599956403855167484720643781523509973086428463104."); - EXPECT_EQ(Aesi512::power2(343), "17917957937422433684459538244547554224973163977877196279199912807710334969441287563047019946172856926208."); - EXPECT_EQ(Aesi512::power2(344), "35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852416."); - EXPECT_EQ(Aesi512::power2(345), "71671831749689734737838152978190216899892655911508785116799651230841339877765150252188079784691427704832."); - EXPECT_EQ(Aesi512::power2(346), "143343663499379469475676305956380433799785311823017570233599302461682679755530300504376159569382855409664."); - EXPECT_EQ(Aesi512::power2(347), "286687326998758938951352611912760867599570623646035140467198604923365359511060601008752319138765710819328."); - EXPECT_EQ(Aesi512::power2(348), "573374653997517877902705223825521735199141247292070280934397209846730719022121202017504638277531421638656."); - EXPECT_EQ(Aesi512::power2(349), "1146749307995035755805410447651043470398282494584140561868794419693461438044242404035009276555062843277312."); - EXPECT_EQ(Aesi512::power2(350), "2293498615990071511610820895302086940796564989168281123737588839386922876088484808070018553110125686554624."); - EXPECT_EQ(Aesi512::power2(351), "4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109248."); - EXPECT_EQ(Aesi512::power2(352), "9173994463960286046443283581208347763186259956673124494950355357547691504353939232280074212440502746218496."); - EXPECT_EQ(Aesi512::power2(353), "18347988927920572092886567162416695526372519913346248989900710715095383008707878464560148424881005492436992."); - EXPECT_EQ(Aesi512::power2(354), "36695977855841144185773134324833391052745039826692497979801421430190766017415756929120296849762010984873984."); - EXPECT_EQ(Aesi512::power2(355), "73391955711682288371546268649666782105490079653384995959602842860381532034831513858240593699524021969747968."); - EXPECT_EQ(Aesi512::power2(356), "146783911423364576743092537299333564210980159306769991919205685720763064069663027716481187399048043939495936."); - EXPECT_EQ(Aesi512::power2(357), "293567822846729153486185074598667128421960318613539983838411371441526128139326055432962374798096087878991872."); - EXPECT_EQ(Aesi512::power2(358), "587135645693458306972370149197334256843920637227079967676822742883052256278652110865924749596192175757983744."); - EXPECT_EQ(Aesi512::power2(359), "1174271291386916613944740298394668513687841274454159935353645485766104512557304221731849499192384351515967488."); - EXPECT_EQ(Aesi512::power2(360), "2348542582773833227889480596789337027375682548908319870707290971532209025114608443463698998384768703031934976."); - EXPECT_EQ(Aesi512::power2(361), "4697085165547666455778961193578674054751365097816639741414581943064418050229216886927397996769537406063869952."); - EXPECT_EQ(Aesi512::power2(362), "9394170331095332911557922387157348109502730195633279482829163886128836100458433773854795993539074812127739904."); - EXPECT_EQ(Aesi512::power2(363), "18788340662190665823115844774314696219005460391266558965658327772257672200916867547709591987078149624255479808."); - EXPECT_EQ(Aesi512::power2(364), "37576681324381331646231689548629392438010920782533117931316655544515344401833735095419183974156299248510959616."); - EXPECT_EQ(Aesi512::power2(365), "75153362648762663292463379097258784876021841565066235862633311089030688803667470190838367948312598497021919232."); - EXPECT_EQ(Aesi512::power2(366), "150306725297525326584926758194517569752043683130132471725266622178061377607334940381676735896625196994043838464."); - EXPECT_EQ(Aesi512::power2(367), "300613450595050653169853516389035139504087366260264943450533244356122755214669880763353471793250393988087676928."); - EXPECT_EQ(Aesi512::power2(368), "601226901190101306339707032778070279008174732520529886901066488712245510429339761526706943586500787976175353856."); - EXPECT_EQ(Aesi512::power2(369), "1202453802380202612679414065556140558016349465041059773802132977424491020858679523053413887173001575952350707712."); - EXPECT_EQ(Aesi512::power2(370), "2404907604760405225358828131112281116032698930082119547604265954848982041717359046106827774346003151904701415424."); - EXPECT_EQ(Aesi512::power2(371), "4809815209520810450717656262224562232065397860164239095208531909697964083434718092213655548692006303809402830848."); - EXPECT_EQ(Aesi512::power2(372), "9619630419041620901435312524449124464130795720328478190417063819395928166869436184427311097384012607618805661696."); - EXPECT_EQ(Aesi512::power2(373), "19239260838083241802870625048898248928261591440656956380834127638791856333738872368854622194768025215237611323392."); - EXPECT_EQ(Aesi512::power2(374), "38478521676166483605741250097796497856523182881313912761668255277583712667477744737709244389536050430475222646784."); - EXPECT_EQ(Aesi512::power2(375), "76957043352332967211482500195592995713046365762627825523336510555167425334955489475418488779072100860950445293568."); - EXPECT_EQ(Aesi512::power2(376), "153914086704665934422965000391185991426092731525255651046673021110334850669910978950836977558144201721900890587136."); - EXPECT_EQ(Aesi512::power2(377), "307828173409331868845930000782371982852185463050511302093346042220669701339821957901673955116288403443801781174272."); - EXPECT_EQ(Aesi512::power2(378), "615656346818663737691860001564743965704370926101022604186692084441339402679643915803347910232576806887603562348544."); - EXPECT_EQ(Aesi512::power2(379), "1231312693637327475383720003129487931408741852202045208373384168882678805359287831606695820465153613775207124697088."); - EXPECT_EQ(Aesi512::power2(380), "2462625387274654950767440006258975862817483704404090416746768337765357610718575663213391640930307227550414249394176."); - EXPECT_EQ(Aesi512::power2(381), "4925250774549309901534880012517951725634967408808180833493536675530715221437151326426783281860614455100828498788352."); - EXPECT_EQ(Aesi512::power2(382), "9850501549098619803069760025035903451269934817616361666987073351061430442874302652853566563721228910201656997576704."); - EXPECT_EQ(Aesi512::power2(383), "19701003098197239606139520050071806902539869635232723333974146702122860885748605305707133127442457820403313995153408."); - EXPECT_EQ(Aesi512::power2(384), "39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306816."); - EXPECT_EQ(Aesi512::power2(385), "78804012392788958424558080200287227610159478540930893335896586808491443542994421222828532509769831281613255980613632."); - EXPECT_EQ(Aesi512::power2(386), "157608024785577916849116160400574455220318957081861786671793173616982887085988842445657065019539662563226511961227264."); - EXPECT_EQ(Aesi512::power2(387), "315216049571155833698232320801148910440637914163723573343586347233965774171977684891314130039079325126453023922454528."); - EXPECT_EQ(Aesi512::power2(388), "630432099142311667396464641602297820881275828327447146687172694467931548343955369782628260078158650252906047844909056."); - EXPECT_EQ(Aesi512::power2(389), "1260864198284623334792929283204595641762551656654894293374345388935863096687910739565256520156317300505812095689818112."); - EXPECT_EQ(Aesi512::power2(390), "2521728396569246669585858566409191283525103313309788586748690777871726193375821479130513040312634601011624191379636224."); - EXPECT_EQ(Aesi512::power2(391), "5043456793138493339171717132818382567050206626619577173497381555743452386751642958261026080625269202023248382759272448."); - EXPECT_EQ(Aesi512::power2(392), "10086913586276986678343434265636765134100413253239154346994763111486904773503285916522052161250538404046496765518544896."); - EXPECT_EQ(Aesi512::power2(393), "20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792."); - EXPECT_EQ(Aesi512::power2(394), "40347654345107946713373737062547060536401653012956617387979052445947619094013143666088208645002153616185987062074179584."); - EXPECT_EQ(Aesi512::power2(395), "80695308690215893426747474125094121072803306025913234775958104891895238188026287332176417290004307232371974124148359168."); - EXPECT_EQ(Aesi512::power2(396), "161390617380431786853494948250188242145606612051826469551916209783790476376052574664352834580008614464743948248296718336."); - EXPECT_EQ(Aesi512::power2(397), "322781234760863573706989896500376484291213224103652939103832419567580952752105149328705669160017228929487896496593436672."); - EXPECT_EQ(Aesi512::power2(398), "645562469521727147413979793000752968582426448207305878207664839135161905504210298657411338320034457858975792993186873344."); - EXPECT_EQ(Aesi512::power2(399), "1291124939043454294827959586001505937164852896414611756415329678270323811008420597314822676640068915717951585986373746688."); - EXPECT_EQ(Aesi512::power2(400), "2582249878086908589655919172003011874329705792829223512830659356540647622016841194629645353280137831435903171972747493376."); - EXPECT_EQ(Aesi512::power2(401), "5164499756173817179311838344006023748659411585658447025661318713081295244033682389259290706560275662871806343945494986752."); - EXPECT_EQ(Aesi512::power2(402), "10328999512347634358623676688012047497318823171316894051322637426162590488067364778518581413120551325743612687890989973504."); - EXPECT_EQ(Aesi512::power2(403), "20657999024695268717247353376024094994637646342633788102645274852325180976134729557037162826241102651487225375781979947008."); - EXPECT_EQ(Aesi512::power2(404), "41315998049390537434494706752048189989275292685267576205290549704650361952269459114074325652482205302974450751563959894016."); - EXPECT_EQ(Aesi512::power2(405), "82631996098781074868989413504096379978550585370535152410581099409300723904538918228148651304964410605948901503127919788032."); - EXPECT_EQ(Aesi512::power2(406), "165263992197562149737978827008192759957101170741070304821162198818601447809077836456297302609928821211897803006255839576064."); - EXPECT_EQ(Aesi512::power2(407), "330527984395124299475957654016385519914202341482140609642324397637202895618155672912594605219857642423795606012511679152128."); - EXPECT_EQ(Aesi512::power2(408), "661055968790248598951915308032771039828404682964281219284648795274405791236311345825189210439715284847591212025023358304256."); - EXPECT_EQ(Aesi512::power2(409), "1322111937580497197903830616065542079656809365928562438569297590548811582472622691650378420879430569695182424050046716608512."); - EXPECT_EQ(Aesi512::power2(410), "2644223875160994395807661232131084159313618731857124877138595181097623164945245383300756841758861139390364848100093433217024."); - EXPECT_EQ(Aesi512::power2(411), "5288447750321988791615322464262168318627237463714249754277190362195246329890490766601513683517722278780729696200186866434048."); - EXPECT_EQ(Aesi512::power2(412), "10576895500643977583230644928524336637254474927428499508554380724390492659780981533203027367035444557561459392400373732868096."); - EXPECT_EQ(Aesi512::power2(413), "21153791001287955166461289857048673274508949854856999017108761448780985319561963066406054734070889115122918784800747465736192."); - EXPECT_EQ(Aesi512::power2(414), "42307582002575910332922579714097346549017899709713998034217522897561970639123926132812109468141778230245837569601494931472384."); - EXPECT_EQ(Aesi512::power2(415), "84615164005151820665845159428194693098035799419427996068435045795123941278247852265624218936283556460491675139202989862944768."); - EXPECT_EQ(Aesi512::power2(416), "169230328010303641331690318856389386196071598838855992136870091590247882556495704531248437872567112920983350278405979725889536."); - EXPECT_EQ(Aesi512::power2(417), "338460656020607282663380637712778772392143197677711984273740183180495765112991409062496875745134225841966700556811959451779072."); - EXPECT_EQ(Aesi512::power2(418), "676921312041214565326761275425557544784286395355423968547480366360991530225982818124993751490268451683933401113623918903558144."); - EXPECT_EQ(Aesi512::power2(419), "1353842624082429130653522550851115089568572790710847937094960732721983060451965636249987502980536903367866802227247837807116288."); - EXPECT_EQ(Aesi512::power2(420), "2707685248164858261307045101702230179137145581421695874189921465443966120903931272499975005961073806735733604454495675614232576."); - EXPECT_EQ(Aesi512::power2(421), "5415370496329716522614090203404460358274291162843391748379842930887932241807862544999950011922147613471467208908991351228465152."); - EXPECT_EQ(Aesi512::power2(422), "10830740992659433045228180406808920716548582325686783496759685861775864483615725089999900023844295226942934417817982702456930304."); - EXPECT_EQ(Aesi512::power2(423), "21661481985318866090456360813617841433097164651373566993519371723551728967231450179999800047688590453885868835635965404913860608."); - EXPECT_EQ(Aesi512::power2(424), "43322963970637732180912721627235682866194329302747133987038743447103457934462900359999600095377180907771737671271930809827721216."); - EXPECT_EQ(Aesi512::power2(425), "86645927941275464361825443254471365732388658605494267974077486894206915868925800719999200190754361815543475342543861619655442432."); - EXPECT_EQ(Aesi512::power2(426), "173291855882550928723650886508942731464777317210988535948154973788413831737851601439998400381508723631086950685087723239310884864."); - EXPECT_EQ(Aesi512::power2(427), "346583711765101857447301773017885462929554634421977071896309947576827663475703202879996800763017447262173901370175446478621769728."); - EXPECT_EQ(Aesi512::power2(428), "693167423530203714894603546035770925859109268843954143792619895153655326951406405759993601526034894524347802740350892957243539456."); - EXPECT_EQ(Aesi512::power2(429), "1386334847060407429789207092071541851718218537687908287585239790307310653902812811519987203052069789048695605480701785914487078912."); - EXPECT_EQ(Aesi512::power2(430), "2772669694120814859578414184143083703436437075375816575170479580614621307805625623039974406104139578097391210961403571828974157824."); - EXPECT_EQ(Aesi512::power2(431), "5545339388241629719156828368286167406872874150751633150340959161229242615611251246079948812208279156194782421922807143657948315648."); - EXPECT_EQ(Aesi512::power2(432), "11090678776483259438313656736572334813745748301503266300681918322458485231222502492159897624416558312389564843845614287315896631296."); - EXPECT_EQ(Aesi512::power2(433), "22181357552966518876627313473144669627491496603006532601363836644916970462445004984319795248833116624779129687691228574631793262592."); - EXPECT_EQ(Aesi512::power2(434), "44362715105933037753254626946289339254982993206013065202727673289833940924890009968639590497666233249558259375382457149263586525184."); - EXPECT_EQ(Aesi512::power2(435), "88725430211866075506509253892578678509965986412026130405455346579667881849780019937279180995332466499116518750764914298527173050368."); - EXPECT_EQ(Aesi512::power2(436), "177450860423732151013018507785157357019931972824052260810910693159335763699560039874558361990664932998233037501529828597054346100736."); - EXPECT_EQ(Aesi512::power2(437), "354901720847464302026037015570314714039863945648104521621821386318671527399120079749116723981329865996466075003059657194108692201472."); - EXPECT_EQ(Aesi512::power2(438), "709803441694928604052074031140629428079727891296209043243642772637343054798240159498233447962659731992932150006119314388217384402944."); - EXPECT_EQ(Aesi512::power2(439), "1419606883389857208104148062281258856159455782592418086487285545274686109596480318996466895925319463985864300012238628776434768805888."); - EXPECT_EQ(Aesi512::power2(440), "2839213766779714416208296124562517712318911565184836172974571090549372219192960637992933791850638927971728600024477257552869537611776."); - EXPECT_EQ(Aesi512::power2(441), "5678427533559428832416592249125035424637823130369672345949142181098744438385921275985867583701277855943457200048954515105739075223552."); - EXPECT_EQ(Aesi512::power2(442), "11356855067118857664833184498250070849275646260739344691898284362197488876771842551971735167402555711886914400097909030211478150447104."); - EXPECT_EQ(Aesi512::power2(443), "22713710134237715329666368996500141698551292521478689383796568724394977753543685103943470334805111423773828800195818060422956300894208."); - EXPECT_EQ(Aesi512::power2(444), "45427420268475430659332737993000283397102585042957378767593137448789955507087370207886940669610222847547657600391636120845912601788416."); - EXPECT_EQ(Aesi512::power2(445), "90854840536950861318665475986000566794205170085914757535186274897579911014174740415773881339220445695095315200783272241691825203576832."); - EXPECT_EQ(Aesi512::power2(446), "181709681073901722637330951972001133588410340171829515070372549795159822028349480831547762678440891390190630401566544483383650407153664."); - EXPECT_EQ(Aesi512::power2(447), "363419362147803445274661903944002267176820680343659030140745099590319644056698961663095525356881782780381260803133088966767300814307328."); - EXPECT_EQ(Aesi512::power2(448), "726838724295606890549323807888004534353641360687318060281490199180639288113397923326191050713763565560762521606266177933534601628614656."); - EXPECT_EQ(Aesi512::power2(449), "1453677448591213781098647615776009068707282721374636120562980398361278576226795846652382101427527131121525043212532355867069203257229312."); - EXPECT_EQ(Aesi512::power2(450), "2907354897182427562197295231552018137414565442749272241125960796722557152453591693304764202855054262243050086425064711734138406514458624."); - EXPECT_EQ(Aesi512::power2(451), "5814709794364855124394590463104036274829130885498544482251921593445114304907183386609528405710108524486100172850129423468276813028917248."); - EXPECT_EQ(Aesi512::power2(452), "11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496."); - EXPECT_EQ(Aesi512::power2(453), "23258839177459420497578361852416145099316523541994177929007686373780457219628733546438113622840434097944400691400517693873107252115668992."); - EXPECT_EQ(Aesi512::power2(454), "46517678354918840995156723704832290198633047083988355858015372747560914439257467092876227245680868195888801382801035387746214504231337984."); - EXPECT_EQ(Aesi512::power2(455), "93035356709837681990313447409664580397266094167976711716030745495121828878514934185752454491361736391777602765602070775492429008462675968."); - EXPECT_EQ(Aesi512::power2(456), "186070713419675363980626894819329160794532188335953423432061490990243657757029868371504908982723472783555205531204141550984858016925351936."); - EXPECT_EQ(Aesi512::power2(457), "372141426839350727961253789638658321589064376671906846864122981980487315514059736743009817965446945567110411062408283101969716033850703872."); - EXPECT_EQ(Aesi512::power2(458), "744282853678701455922507579277316643178128753343813693728245963960974631028119473486019635930893891134220822124816566203939432067701407744."); - EXPECT_EQ(Aesi512::power2(459), "1488565707357402911845015158554633286356257506687627387456491927921949262056238946972039271861787782268441644249633132407878864135402815488."); - EXPECT_EQ(Aesi512::power2(460), "2977131414714805823690030317109266572712515013375254774912983855843898524112477893944078543723575564536883288499266264815757728270805630976."); - EXPECT_EQ(Aesi512::power2(461), "5954262829429611647380060634218533145425030026750509549825967711687797048224955787888157087447151129073766576998532529631515456541611261952."); - EXPECT_EQ(Aesi512::power2(462), "11908525658859223294760121268437066290850060053501019099651935423375594096449911575776314174894302258147533153997065059263030913083222523904."); - EXPECT_EQ(Aesi512::power2(463), "23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808."); - EXPECT_EQ(Aesi512::power2(464), "47634102635436893179040485073748265163400240214004076398607741693502376385799646303105256699577209032590132615988260237052123652332890095616."); - EXPECT_EQ(Aesi512::power2(465), "95268205270873786358080970147496530326800480428008152797215483387004752771599292606210513399154418065180265231976520474104247304665780191232."); - EXPECT_EQ(Aesi512::power2(466), "190536410541747572716161940294993060653600960856016305594430966774009505543198585212421026798308836130360530463953040948208494609331560382464."); - EXPECT_EQ(Aesi512::power2(467), "381072821083495145432323880589986121307201921712032611188861933548019011086397170424842053596617672260721060927906081896416989218663120764928."); - EXPECT_EQ(Aesi512::power2(468), "762145642166990290864647761179972242614403843424065222377723867096038022172794340849684107193235344521442121855812163792833978437326241529856."); - EXPECT_EQ(Aesi512::power2(469), "1524291284333980581729295522359944485228807686848130444755447734192076044345588681699368214386470689042884243711624327585667956874652483059712."); - EXPECT_EQ(Aesi512::power2(470), "3048582568667961163458591044719888970457615373696260889510895468384152088691177363398736428772941378085768487423248655171335913749304966119424."); - EXPECT_EQ(Aesi512::power2(471), "6097165137335922326917182089439777940915230747392521779021790936768304177382354726797472857545882756171536974846497310342671827498609932238848."); - EXPECT_EQ(Aesi512::power2(472), "12194330274671844653834364178879555881830461494785043558043581873536608354764709453594945715091765512343073949692994620685343654997219864477696."); - EXPECT_EQ(Aesi512::power2(473), "24388660549343689307668728357759111763660922989570087116087163747073216709529418907189891430183531024686147899385989241370687309994439728955392."); - EXPECT_EQ(Aesi512::power2(474), "48777321098687378615337456715518223527321845979140174232174327494146433419058837814379782860367062049372295798771978482741374619988879457910784."); - EXPECT_EQ(Aesi512::power2(475), "97554642197374757230674913431036447054643691958280348464348654988292866838117675628759565720734124098744591597543956965482749239977758915821568."); - EXPECT_EQ(Aesi512::power2(476), "195109284394749514461349826862072894109287383916560696928697309976585733676235351257519131441468248197489183195087913930965498479955517831643136."); - EXPECT_EQ(Aesi512::power2(477), "390218568789499028922699653724145788218574767833121393857394619953171467352470702515038262882936496394978366390175827861930996959911035663286272."); - EXPECT_EQ(Aesi512::power2(478), "780437137578998057845399307448291576437149535666242787714789239906342934704941405030076525765872992789956732780351655723861993919822071326572544."); - EXPECT_EQ(Aesi512::power2(479), "1560874275157996115690798614896583152874299071332485575429578479812685869409882810060153051531745985579913465560703311447723987839644142653145088."); - EXPECT_EQ(Aesi512::power2(480), "3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176."); - EXPECT_EQ(Aesi512::power2(481), "6243497100631984462763194459586332611497196285329942301718313919250743477639531240240612206126983942319653862242813245790895951358576570612580352."); - EXPECT_EQ(Aesi512::power2(482), "12486994201263968925526388919172665222994392570659884603436627838501486955279062480481224412253967884639307724485626491581791902717153141225160704."); - EXPECT_EQ(Aesi512::power2(483), "24973988402527937851052777838345330445988785141319769206873255677002973910558124960962448824507935769278615448971252983163583805434306282450321408."); - EXPECT_EQ(Aesi512::power2(484), "49947976805055875702105555676690660891977570282639538413746511354005947821116249921924897649015871538557230897942505966327167610868612564900642816."); - EXPECT_EQ(Aesi512::power2(485), "99895953610111751404211111353381321783955140565279076827493022708011895642232499843849795298031743077114461795885011932654335221737225129801285632."); - EXPECT_EQ(Aesi512::power2(486), "199791907220223502808422222706762643567910281130558153654986045416023791284464999687699590596063486154228923591770023865308670443474450259602571264."); - EXPECT_EQ(Aesi512::power2(487), "399583814440447005616844445413525287135820562261116307309972090832047582568929999375399181192126972308457847183540047730617340886948900519205142528."); - EXPECT_EQ(Aesi512::power2(488), "799167628880894011233688890827050574271641124522232614619944181664095165137859998750798362384253944616915694367080095461234681773897801038410285056."); - EXPECT_EQ(Aesi512::power2(489), "1598335257761788022467377781654101148543282249044465229239888363328190330275719997501596724768507889233831388734160190922469363547795602076820570112."); - EXPECT_EQ(Aesi512::power2(490), "3196670515523576044934755563308202297086564498088930458479776726656380660551439995003193449537015778467662777468320381844938727095591204153641140224."); - EXPECT_EQ(Aesi512::power2(491), "6393341031047152089869511126616404594173128996177860916959553453312761321102879990006386899074031556935325554936640763689877454191182408307282280448."); - EXPECT_EQ(Aesi512::power2(492), "12786682062094304179739022253232809188346257992355721833919106906625522642205759980012773798148063113870651109873281527379754908382364816614564560896."); - EXPECT_EQ(Aesi512::power2(493), "25573364124188608359478044506465618376692515984711443667838213813251045284411519960025547596296126227741302219746563054759509816764729633229129121792."); - EXPECT_EQ(Aesi512::power2(494), "51146728248377216718956089012931236753385031969422887335676427626502090568823039920051095192592252455482604439493126109519019633529459266458258243584."); - EXPECT_EQ(Aesi512::power2(495), "102293456496754433437912178025862473506770063938845774671352855253004181137646079840102190385184504910965208878986252219038039267058918532916516487168."); - EXPECT_EQ(Aesi512::power2(496), "204586912993508866875824356051724947013540127877691549342705710506008362275292159680204380770369009821930417757972504438076078534117837065833032974336."); - EXPECT_EQ(Aesi512::power2(497), "409173825987017733751648712103449894027080255755383098685411421012016724550584319360408761540738019643860835515945008876152157068235674131666065948672."); - EXPECT_EQ(Aesi512::power2(498), "818347651974035467503297424206899788054160511510766197370822842024033449101168638720817523081476039287721671031890017752304314136471348263332131897344."); - EXPECT_EQ(Aesi512::power2(499), "1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688."); - EXPECT_EQ(Aesi512::power2(500), "3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376."); - EXPECT_EQ(Aesi512::power2(501), "6546781215792283740026379393655198304433284092086129578966582736192267592809349109766540184651808314301773368255120142018434513091770786106657055178752."); - EXPECT_EQ(Aesi512::power2(502), "13093562431584567480052758787310396608866568184172259157933165472384535185618698219533080369303616628603546736510240284036869026183541572213314110357504."); - EXPECT_EQ(Aesi512::power2(503), "26187124863169134960105517574620793217733136368344518315866330944769070371237396439066160738607233257207093473020480568073738052367083144426628220715008."); - EXPECT_EQ(Aesi512::power2(504), "52374249726338269920211035149241586435466272736689036631732661889538140742474792878132321477214466514414186946040961136147476104734166288853256441430016."); - EXPECT_EQ(Aesi512::power2(505), "104748499452676539840422070298483172870932545473378073263465323779076281484949585756264642954428933028828373892081922272294952209468332577706512882860032."); - EXPECT_EQ(Aesi512::power2(506), "209496998905353079680844140596966345741865090946756146526930647558152562969899171512529285908857866057656747784163844544589904418936665155413025765720064."); - EXPECT_EQ(Aesi512::power2(507), "418993997810706159361688281193932691483730181893512293053861295116305125939798343025058571817715732115313495568327689089179808837873330310826051531440128."); - EXPECT_EQ(Aesi512::power2(508), "837987995621412318723376562387865382967460363787024586107722590232610251879596686050117143635431464230626991136655378178359617675746660621652103062880256."); - EXPECT_EQ(Aesi512::power2(509), "1675975991242824637446753124775730765934920727574049172215445180465220503759193372100234287270862928461253982273310756356719235351493321243304206125760512."); - EXPECT_EQ(Aesi512::power2(510), "3351951982485649274893506249551461531869841455148098344430890360930441007518386744200468574541725856922507964546621512713438470702986642486608412251521024."); - EXPECT_EQ(Aesi512::power2(511), "6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503042048."); - EXPECT_EQ(Aesi512::power2(512), 0); - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file +TEST(Unsigned, Power2) { + for (std::size_t i = 0; i < 511; ++i) { + std::stringstream ss; ss << "0x" << std::hex << CryptoPP::Integer::Power2(i); + EXPECT_EQ(Aeu512::power2(i), ss.str()); + } + EXPECT_EQ(Aeu512::power2(512), 0u); +} diff --git a/test/arithmetic/square-root.cpp b/test/arithmetic/square-root.cpp old mode 100644 new mode 100755 index 0f348a3..c2a6336 --- a/test/arithmetic/square-root.cpp +++ b/test/arithmetic/square-root.cpp @@ -1,97 +1,29 @@ #include +#include "../../Aeu.h" #include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" +#include "../generation.h" -TEST(SquareRoot, SquareRoot) { - const auto timeStart = std::chrono::system_clock::now(); +TEST(Signed_SquareRoot, SquareRoot) { + constexpr auto testsAmount = 2, bitness = 2048; + for (unsigned i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(bitness - 20); + const Aesi m = value; + if(i % 2 == 0) + EXPECT_EQ(m.squareRoot(), value.SquareRoot()); + else EXPECT_EQ(m.squareRoot(), 0u); + } + Aesi zero = 0u; + EXPECT_EQ(zero.squareRoot(), 0u); +} - Aesi512 m; - m = "6090725157803385683847790262910475439880944489553750045786895303294805776058380471608951628613013763332789951290275640362243141926540167423390151885627587."; - EXPECT_EQ(m.squareRoot(), "78043098079224056927951137119052045281574520557910376004565433003118507400052."); - m = "2198442897630760572542562253325024201444903498242188983498631852277766153592956295915984611974235359574640385959965624634128999962215308936301754007314365."; - EXPECT_EQ(m.squareRoot(), "46887555893123290123289121097017676390793073607338116350101514251747344152489."); - m = "1000283845438290419274324071760371197829217155422774112552376012708071485480283317843508475952441540071339503030773495309949929024012496228467055607230714."; - EXPECT_EQ(m.squareRoot(), "31627264273697312931717788894381088477651234284028816841918262368868920653167."); - m = "5835842694952909670019084191754362899884006062455030963065539151628101657144547117594407067421860388116505599752641932950422365837720731631815673944069745."; - EXPECT_EQ(m.squareRoot(), "76392687444237158935595699183775595821743466989589796103628214600066114393611."); - m = "3866404964809678884590261330471673378078414493316607179993947370598745698299238770431759940921769523654634371169220092627980180440637824026990197581713503."; - EXPECT_EQ(m.squareRoot(), "62180422681175776039199472366607895973369526220983402320405142036733505240891."); - m = "4560826394957611895281972689889828032619002380362353086899085752881078711579845744276935344290289683784503719672535533487574429157729131595128407383550127."; - EXPECT_EQ(m.squareRoot(), "67533890713904614302701757348795319406033598443471427415486041122600729967809."); - m = "3585126669048102094266502527182152113821800075415948154904611795480102030967683616483309824775786369945457886415807076849176955188808905018411674112744866."; - EXPECT_EQ(m.squareRoot(), "59875927291759766902170390985122877245929448508816120373305077519115166470064."); - m = "195432114288329197216777722466904127138981632626371213320685733903863966967954168812482349483814468962135873701539352896103173226813264512374360865490203."; - EXPECT_EQ(m.squareRoot(), "13979703655239949227726320742062170323174505178595123308382537469230355248984."); - m = "4885509786573540813014271044300328939442823484053161179977119277898839990932508382188884747708651211077918132443443944721575404160937901109543098897192323."; - EXPECT_EQ(m.squareRoot(), "69896421843850782437988692032562040550970659647609725782619203272587444407377."); - m = "5585838662982006159561231182315944605990032602869142805481013882371552431835678855360566804500930632508690837392418040312217246485178364193757989985028150."; - EXPECT_EQ(m.squareRoot(), "74738468428126128945198936220600870524261980512835819749878936880910218598326."); - m = "3974800749371025941688149434350317847651389369795419901011348466760296085075163008194828993428420960869579459802914702306076517313500317878238285523270583."; - EXPECT_EQ(m.squareRoot(), "63046020884517572713684487895050254752951548754790221637178476070995379084647."); - m = "2273897147379510952670903435983726478426446351306817064325493127253999928114620214087767336326374159343743840960901825211724186393724969928264343687801857."; - EXPECT_EQ(m.squareRoot(), "47685397632603536387498977789929936366899731244291373598733992037978793182194."); - m = "6058733199744491524750070639631005770149157505468511458447374326702852864729386502860578270470905464654036198444571649876873696811448222867190503890802073."; - EXPECT_EQ(m.squareRoot(), "77837864820050732971467883500691147356859079793940498398075568852368431562477."); - m = "1825181170929106117784121032396530262014382942214885327452078008994423651970599468513800657419183302097109018524170571049692861695737305378276276238961246."; - EXPECT_EQ(m.squareRoot(), "42722139119303309035519517007000251493949478040923615801467678859254838920089."); - m = "6075764831927944734820358370247697303865549504951499992047158748628379282483018278526389001427598630984046440443262928410428428718042635113579647593538861."; - EXPECT_EQ(m.squareRoot(), "77947192585287795821166684446105483156513686295271884067163466213004011047624."); - m = "4004830024434636953260534689014481794638697852388914654101458283982418871832780024500880693024698136721203259468218443457509515483024781849151540382579844."; - EXPECT_EQ(m.squareRoot(), "63283726379177743180646267299797936437730074348079395258824842775083793841745."); - m = "6285638845584197260933539177937109311654195998315458005442998568340285309085303150318584626944224585756114797146644007556131054207450258513243196878208005."; - EXPECT_EQ(m.squareRoot(), "79282020947905946155306439097732368208323476687623652536644717329208169174849."); - m = "1591715254732792046271554151254011707271523857378421070227426743657664509115521914378597439975038082693302574409843611930659905532648217572134988783972202."; - EXPECT_EQ(m.squareRoot(), "39896306279313528027576127123679783731457438661317537258160347888633455098208."); - m = "4152123138537748208119491567993802001922490996344574352904852554639792876794903343267214470467358724211881863139604808366854129862547449532439586991839781."; - EXPECT_EQ(m.squareRoot(), "64436970277456001819589426863815839347838931575823365304411747368127005854777."); - m = "3247953627286684745970952994405009249179276055815782700408132310818135548301596000101696199401789814574488352005606473492556320207228117525708252348438228."; - EXPECT_EQ(m.squareRoot(), "56990820552845918345554104705511630299390699694280194924355838722665971148650."); - m = "4879775319652791718435483278790393331977921874866324265671557515774794409920640048547316003137999878012169906596949392776285882401633843252266642302322220."; - EXPECT_EQ(m.squareRoot(), "69855388622874267983903615010388442530873933382033428082803065074289210057526."); - m = "525803053338669671361834125505778223635092169276267065659380173232895761190177502285921574438173914942888511016152214630374157699165671809810946680866173."; - EXPECT_EQ(m.squareRoot(), "22930395839118645083125118415231829992844557819387390757172245849880332114817."); - m = "4334290803334574924774563383778114592040008942935142759360740416894321011553534421329973775435676474326522198140183596669676711667493513252710889597311071."; - EXPECT_EQ(m.squareRoot(), "65835330965482165826606708393068129703573908303472335630320393544299914361365."); - m = "4494330897373086601741336539164891478106093875984641278376170467081308860649526546425730529688361230199738125538355893634422638784156646016107466222780002."; - EXPECT_EQ(m.squareRoot(), "67039771012236360425452587112083879727352832026664715817865354531219320762856."); - m = "4909510064291890007986701314959525545085343439669677637524745730528601969117283762582438181258785487159761082768699492288861101615356412408593052549486905."; - EXPECT_EQ(m.squareRoot(), "70067896102936400412185908830070038094171381020525736544627701873950301457751."); - m = "4309049860317095930345932817895929869158824714777420937049291489804408232553991632400000046593886407203130406067551835015280609170269107469747222587657575."; - EXPECT_EQ(m.squareRoot(), "65643353512119533778839084743587241350254146984599233979995995828880625948728."); - m = "2815183315959571534328333003798938203992295790601303864349480258693322749533160295492522791249654065813587711866285995434966581656634932226191180498298887."; - EXPECT_EQ(m.squareRoot(), "53058301103216370645516088373866164223784123497457847471308939067872641642125."); - m = "4184860263603606187505821657132333624811545808661814236148222750233758380867808991661648584399968418659227868360294455960518442603673931161268026915012004."; - EXPECT_EQ(m.squareRoot(), "64690495929491885350008967512291554906930240598671190466110126164525773366383."); - m = "3626179759665635710024894729908975749929310670913138437843697802717405269318753497101352884994201707580987493633460658245393661537089901470476706585576636."; - EXPECT_EQ(m.squareRoot(), "60217769467704760793090420382288205284909086897093775532775991407068572475902."); - m = "1210412217259070228850414662144211880122237220938898411592655648252451736373500486335107930995793797685095207365686273369950811799215724156756984295918621."; - EXPECT_EQ(m.squareRoot(), "34790978963792758282821680720425169316397664924467261128155497854070715310641."); - m = "5304183900049677899434155872940835545001908862281144467394746404718288247305566418344505514638218320360739860741811447449909599229045321155974023091798730."; - EXPECT_EQ(m.squareRoot(), "72829828367569821559420558783391366244804688716707570395943155683543681885445."); - m = "3640585299333987128710539656247326601027384236906409606719943101559261518050830948964339951529015129486869923842545631907069889461277512779785277993208500."; - EXPECT_EQ(m.squareRoot(), "60337262942016081549376915367861634870082502555913772148331064200251220185180."); - m = "3322370697186985694789513400287270387301112233930212545202925835983912017769594900335591947550245455892079786111000094962594255136285982280844343511192695."; - EXPECT_EQ(m.squareRoot(), "57640009517582365635109531157872118327321192156029885084868676476655818355537."); - m = "363784768752142937563532516802248023200783991735884641019640603853335279495874238171768858622548171987239433433940329270027707838693346134632383823341935."; - EXPECT_EQ(m.squareRoot(), "19073142602941523059626261036079470804203755080099072645277917290890123925763."); - m = "6573219637626330602027647709989350575004966449566640867406801913893816685114013865954636777879975709920815941414116164213346809608268977636961264397247984."; - EXPECT_EQ(m.squareRoot(), "81075394773175977437905239306818533094686679307548108118687932991147134727933."); - m = "2651697164253891110974861916707961800399415237006671427054906096036127767551025689184240443309042522935877367416817011482578545456921736574292175068578268."; - EXPECT_EQ(m.squareRoot(), "51494632382937652261828149358433557173471303538112140869567269588752896291463."); - m = "747574725367714742179421620118183706234552472659906649927272598397868687230961900721483170976277920481053460135612564397505407018863990352790291461172926."; - EXPECT_EQ(m.squareRoot(), "27341812766671392415294159584452864674807851989798208193274217983842152820397."); - m = "1386941192648168135929395522078905161709959773925029007669200584596632075854980700020366355221969540218767669166559150892077370741807280531484664981086514."; - EXPECT_EQ(m.squareRoot(), "37241659370229035699777185636279191613762937271489308117700674762048976617383."); - m = "5621106178103901219344046536326204325148496347375026526085835464563757533577400230588398787642778757593635030148118674346481873791016817115783785604037128."; - EXPECT_EQ(m.squareRoot(), "74974036693404078836937829975059038773972455949610022517963046206798417449826."); - m = "5955813785675588109518975395472748958137987074475981158876199212009943507928308334573693535545462979243470395215093466596560400578633978166204064517715396."; - EXPECT_EQ(m.squareRoot(), "77173919076820169671684270220139975015863766388260649610600962754358359900654."); +TEST(Unsigned_SquareRoot, SquareRoot) { + constexpr auto testsAmount = 2048, bitness = 2048; + for (unsigned i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(bitness - 20); + const Aeu m = value; + EXPECT_EQ(m.squareRoot(), value.SquareRoot()); + } -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ + Aeu zero = 0u; + EXPECT_EQ(zero.squareRoot(), 0u); } \ No newline at end of file diff --git a/test/arithmetic/subtraction.cpp b/test/arithmetic/subtraction.cpp deleted file mode 100644 index 96b8b18..0000000 --- a/test/arithmetic/subtraction.cpp +++ /dev/null @@ -1,545 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Subtraction, Zero) { - Aesi512 zero = 0; - Aesi512 m0 = 14377898; - EXPECT_EQ(m0 - 0, 14377898); - EXPECT_EQ(0 - m0, -14377898); - EXPECT_EQ(m0 + 0, 14377898); - EXPECT_EQ(m0 + zero, 14377898); - EXPECT_EQ(m0 - zero, 14377898); - EXPECT_EQ(m0 + -zero, 14377898); - EXPECT_EQ(m0 + +zero, 14377898); - EXPECT_EQ(m0 - +zero, 14377898); - EXPECT_EQ(m0 - -zero, 14377898); - EXPECT_EQ(zero - m0, -14377898); - EXPECT_EQ(+zero - m0, -14377898); - EXPECT_EQ(-zero - m0, -14377898); - m0 -= 0; EXPECT_EQ(m0, 14377898); - m0 -= zero; EXPECT_EQ(m0, 14377898); - m0 -= -zero; EXPECT_EQ(m0, 14377898); - m0 -= +zero; EXPECT_EQ(m0, 14377898); - - Aesi512 m1 = 42824647; - EXPECT_EQ(m1 - 0, 42824647); - EXPECT_EQ(0 - m1, -42824647); - EXPECT_EQ(m1 + 0, 42824647); - EXPECT_EQ(m1 + zero, 42824647); - EXPECT_EQ(m1 - zero, 42824647); - EXPECT_EQ(m1 + -zero, 42824647); - EXPECT_EQ(m1 + +zero, 42824647); - EXPECT_EQ(m1 - +zero, 42824647); - EXPECT_EQ(m1 - -zero, 42824647); - EXPECT_EQ(zero - m1, -42824647); - EXPECT_EQ(+zero - m1, -42824647); - EXPECT_EQ(-zero - m1, -42824647); - m1 -= 0; EXPECT_EQ(m1, 42824647); - m1 -= zero; EXPECT_EQ(m1, 42824647); - m1 -= -zero; EXPECT_EQ(m1, 42824647); - m1 -= +zero; EXPECT_EQ(m1, 42824647); - - Aesi512 m2 = 56407773; - EXPECT_EQ(m2 - 0, 56407773); - EXPECT_EQ(0 - m2, -56407773); - EXPECT_EQ(m2 + 0, 56407773); - EXPECT_EQ(m2 + zero, 56407773); - EXPECT_EQ(m2 - zero, 56407773); - EXPECT_EQ(m2 + -zero, 56407773); - EXPECT_EQ(m2 + +zero, 56407773); - EXPECT_EQ(m2 - +zero, 56407773); - EXPECT_EQ(m2 - -zero, 56407773); - EXPECT_EQ(zero - m2, -56407773); - EXPECT_EQ(+zero - m2, -56407773); - EXPECT_EQ(-zero - m2, -56407773); - m2 -= 0; EXPECT_EQ(m2, 56407773); - m2 -= zero; EXPECT_EQ(m2, 56407773); - m2 -= -zero; EXPECT_EQ(m2, 56407773); - m2 -= +zero; EXPECT_EQ(m2, 56407773); -} - -TEST(Subtraction, SmallPositive) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small2 - small4, 1920); - EXPECT_EQ(small3 - small1, 7814); - EXPECT_EQ(small2 - small1, 12735); - EXPECT_EQ(small2 - small3, 4921); -} - -TEST(Subtraction, SmallNegative) { - Aesi512 small1 = -8492, small2 = 4243, small3 = -678, small4 = 2323; - EXPECT_EQ(small1 - small2, -12735); - EXPECT_EQ(small3 - small2, -4921); - EXPECT_EQ(small4 - small2, -1920); - EXPECT_EQ(small1 - small3, -7814); -} - -TEST(Subtraction, Decrement) { - Aesi512 m0 = -33924914; - --m0; m0--; m0--; --m0; m0--; m0--; - EXPECT_EQ(m0, -33924920); - Aesi512 t0 = m0--, u0 = --m0; - EXPECT_EQ(t0, -33924920); EXPECT_EQ(u0, -33924922); EXPECT_EQ(m0, -33924922); - - Aesi512 m1 = 28310193; - --m1; --m1; --m1; m1--; --m1; m1--; --m1; m1--; --m1; --m1; --m1; - EXPECT_EQ(m1, 28310182); - Aesi512 t1 = m1--, u1 = --m1; - EXPECT_EQ(t1, 28310182); EXPECT_EQ(u1, 28310180); EXPECT_EQ(m1, 28310180); - - Aesi512 m2 = 57075809; - --m2; m2--; m2--; m2--; m2--; --m2; --m2; --m2; --m2; - EXPECT_EQ(m2, 57075800); - Aesi512 t2 = m2--, u2 = --m2; - EXPECT_EQ(t2, 57075800); EXPECT_EQ(u2, 57075798); EXPECT_EQ(m2, 57075798); - - Aesi512 m3 = -2900339; - m3--; --m3; m3--; m3--; m3--; m3--; --m3; m3--; m3--; m3--; m3--; --m3; --m3; m3--; - EXPECT_EQ(m3, -2900353); - Aesi512 t3 = m3--, u3 = --m3; - EXPECT_EQ(t3, -2900353); EXPECT_EQ(u3, -2900355); EXPECT_EQ(m3, -2900355); - - Aesi512 m4 = -12687358; - --m4; --m4; --m4; --m4; --m4; m4--; m4--; --m4; --m4; m4--; m4--; m4--; m4--; - EXPECT_EQ(m4, -12687371); - Aesi512 t4 = m4--, u4 = --m4; - EXPECT_EQ(t4, -12687371); EXPECT_EQ(u4, -12687373); EXPECT_EQ(m4, -12687373); -} - -TEST(Subtraction, MixedSubtraction) { - Aesi512 m0 = -78795448765594211, m1 = 48701305384651798; - EXPECT_EQ(m0 - m1, -127496754150246009); - Aesi512 m2 = 67574064564830699, m3 = -91803406528648461; - EXPECT_EQ(m2 - m3, 159377471093479160); - Aesi512 m4 = -96016808488224510, m5 = 250370865835895; - EXPECT_EQ(m4 - m5, -96267179354060405); - Aesi512 m6 = -41074518047002314, m7 = 95579003191734993; - EXPECT_EQ(m6 - m7, -136653521238737307); - Aesi512 m8 = -29705744161350641, m9 = 80392893348344206; - EXPECT_EQ(m8 - m9, -110098637509694847); - Aesi512 m10 = 46806496601606081, m11 = -91563580387805963; - EXPECT_EQ(m10 - m11, 138370076989412044); - Aesi512 m12 = -36224949170869920, m13 = 94125420376985567; - EXPECT_EQ(m12 - m13, -130350369547855487); - Aesi512 m14 = 56826716379651150, m15 = -3945619004625386; - EXPECT_EQ(m14 - m15, 60772335384276536); - Aesi512 m16 = 70075148666243867, m17 = 41028685512594215; - EXPECT_EQ(m16 - m17, 29046463153649652); - Aesi512 m18 = 9684075024490575, m19 = -94275562315467831; - EXPECT_EQ(m18 - m19, 103959637339958406); - Aesi512 m20 = -19394083460764198, m21 = 4598882134566940; - EXPECT_EQ(m20 - m21, -23992965595331138); - Aesi512 m22 = -59638329813822567, m23 = 39620622567810820; - EXPECT_EQ(m22 - m23, -99258952381633387); - Aesi512 m24 = 10481374612533748, m25 = -45690246001184389; - EXPECT_EQ(m24 - m25, 56171620613718137); - Aesi512 m26 = -39861901704867459, m27 = -71363004984618855; - EXPECT_EQ(m26 - m27, 31501103279751396); - Aesi512 m28 = 57092377547587484, m29 = 47047741340310546; - EXPECT_EQ(m28 - m29, 10044636207276938); - Aesi512 m30 = -60473701642492004, m31 = 36953318815595088; - EXPECT_EQ(m30 - m31, -97427020458087092); - Aesi512 m32 = -78684568025867499, m33 = 39474612379303263; - EXPECT_EQ(m32 - m33, -118159180405170762); - Aesi512 m34 = -59708830071153936, m35 = -24987753064694161; - EXPECT_EQ(m34 - m35, -34721077006459775); - Aesi512 m36 = -61431982293008665, m37 = -93223158394351966; - EXPECT_EQ(m36 - m37, 31791176101343301); - Aesi512 m38 = -77616429233373210, m39 = -56564296394666424; - EXPECT_EQ(m38 - m39, -21052132838706786); - Aesi512 m40 = -62011231426006983, m41 = -32675741172931378; - EXPECT_EQ(m40 - m41, -29335490253075605); - Aesi512 m42 = -36932046954643746, m43 = -6581413634276615; - EXPECT_EQ(m42 - m43, -30350633320367131); - Aesi512 m44 = -63308462008430376, m45 = -30568052971566789; - EXPECT_EQ(m44 - m45, -32740409036863587); - Aesi512 m46 = -3761885636924116, m47 = -51334343669010520; - EXPECT_EQ(m46 - m47, 47572458032086404); - Aesi512 m48 = 29643032223799847, m49 = -8815829513288304; - EXPECT_EQ(m48 - m49, 38458861737088151); - Aesi512 m50 = -63790459687888788, m51 = 56482071741526173; - EXPECT_EQ(m50 - m51, -120272531429414961); - Aesi512 m52 = 44052929832619500, m53 = 94503788809467804; - EXPECT_EQ(m52 - m53, -50450858976848304); - Aesi512 m54 = 75262871827916165, m55 = 75116929302625443; - EXPECT_EQ(m54 - m55, 145942525290722); - Aesi512 m56 = 42012563671870421, m57 = -39551471801647037; - EXPECT_EQ(m56 - m57, 81564035473517458); - Aesi512 m58 = -58094893884533034, m59 = -89603604140659081; - EXPECT_EQ(m58 - m59, 31508710256126047); - Aesi512 m60 = -15491398282947126, m61 = 75124171238430754; - EXPECT_EQ(m60 - m61, -90615569521377880); - Aesi512 m62 = -15279473212308778, m63 = -25214196246095585; - EXPECT_EQ(m62 - m63, 9934723033786807); - Aesi512 m64 = -15459700611573614, m65 = 61544035971577530; - EXPECT_EQ(m64 - m65, -77003736583151144); - Aesi512 m66 = -88407578525560434, m67 = 70572399006127154; - EXPECT_EQ(m66 - m67, -158979977531687588); - Aesi512 m68 = -76673284026197188, m69 = -42838723021411352; - EXPECT_EQ(m68 - m69, -33834561004785836); - Aesi512 m70 = -77534335981039599, m71 = -2575361264407743; - EXPECT_EQ(m70 - m71, -74958974716631856); - Aesi512 m72 = 14336673228002761, m73 = -63399735148346295; - EXPECT_EQ(m72 - m73, 77736408376349056); - Aesi512 m74 = -45220785989975054, m75 = -88657223135591669; - EXPECT_EQ(m74 - m75, 43436437145616615); - Aesi512 m76 = -3750032932034014, m77 = -3079274694736935; - EXPECT_EQ(m76 - m77, -670758237297079); - Aesi512 m78 = -57879783190606075, m79 = 30582080660739954; - EXPECT_EQ(m78 - m79, -88461863851346029); -} - -TEST(Subtraction, MixedSubtractionAssignment) { - Aesi512 m0 = 76497282207537392, m1 = -81483767496064665; - m0 -= m1; EXPECT_EQ(m0, 157981049703602057); - Aesi512 m2 = 52766273087594876, m3 = -45464959271515713; - m2 -= m3; EXPECT_EQ(m2, 98231232359110589); - Aesi512 m4 = -39866035793358885, m5 = -74561994540740578; - m4 -= m5; EXPECT_EQ(m4, 34695958747381693); - Aesi512 m6 = -32310239597891199, m7 = 38858227484763400; - m6 -= m7; EXPECT_EQ(m6, -71168467082654599); - Aesi512 m8 = 83600373085209769, m9 = -4676747027315379; - m8 -= m9; EXPECT_EQ(m8, 88277120112525148); - Aesi512 m10 = 26800952209504502, m11 = -81901349566193950; - m10 -= m11; EXPECT_EQ(m10, 108702301775698452); - Aesi512 m12 = -22980648057789418, m13 = -62890011667727509; - m12 -= m13; EXPECT_EQ(m12, 39909363609938091); - Aesi512 m14 = -30243185699710800, m15 = 85196747975255772; - m14 -= m15; EXPECT_EQ(m14, -115439933674966572); - Aesi512 m16 = 88575636175295575, m17 = 5058788936387072; - m16 -= m17; EXPECT_EQ(m16, 83516847238908503); - Aesi512 m18 = -8627149227965893, m19 = -51145930004297782; - m18 -= m19; EXPECT_EQ(m18, 42518780776331889); - Aesi512 m20 = -61641748360877573, m21 = 1347982179977643; - m20 -= m21; EXPECT_EQ(m20, -62989730540855216); - Aesi512 m22 = -76812276267570764, m23 = -66388565315430388; - m22 -= m23; EXPECT_EQ(m22, -10423710952140376); - Aesi512 m24 = -22413217680403760, m25 = 20776822720647242; - m24 -= m25; EXPECT_EQ(m24, -43190040401051002); - Aesi512 m26 = 60501229183601977, m27 = -97208132801489513; - m26 -= m27; EXPECT_EQ(m26, 157709361985091490); - Aesi512 m28 = -90717506923312883, m29 = 80581288039243653; - m28 -= m29; EXPECT_EQ(m28, -171298794962556536); - Aesi512 m30 = -1434671774297789, m31 = -48788207733204515; - m30 -= m31; EXPECT_EQ(m30, 47353535958906726); - Aesi512 m32 = 98636409838290088, m33 = -24858988765114797; - m32 -= m33; EXPECT_EQ(m32, 123495398603404885); - Aesi512 m34 = 32698890626094304, m35 = -95452487538418616; - m34 -= m35; EXPECT_EQ(m34, 128151378164512920); - Aesi512 m36 = 54592571715348901, m37 = 27499032134617746; - m36 -= m37; EXPECT_EQ(m36, 27093539580731155); - Aesi512 m38 = -34229390668287600, m39 = 70527679356389759; - m38 -= m39; EXPECT_EQ(m38, -104757070024677359); - Aesi512 m40 = 38082671719287318, m41 = 90080041129782021; - m40 -= m41; EXPECT_EQ(m40, -51997369410494703); - Aesi512 m42 = -26471635935191754, m43 = -11535551530392665; - m42 -= m43; EXPECT_EQ(m42, -14936084404799089); - Aesi512 m44 = 45091999474176387, m45 = -33228319472241331; - m44 -= m45; EXPECT_EQ(m44, 78320318946417718); - Aesi512 m46 = -91842884207028021, m47 = 51904091210877915; - m46 -= m47; EXPECT_EQ(m46, -143746975417905936); - Aesi512 m48 = -5357775061339009, m49 = -25273398031638359; - m48 -= m49; EXPECT_EQ(m48, 19915622970299350); - Aesi512 m50 = -14905275244784635, m51 = -94021456037974671; - m50 -= m51; EXPECT_EQ(m50, 79116180793190036); - Aesi512 m52 = -13576279815222827, m53 = -42123086873941691; - m52 -= m53; EXPECT_EQ(m52, 28546807058718864); - Aesi512 m54 = -52554401815218966, m55 = 99184114388707534; - m54 -= m55; EXPECT_EQ(m54, -151738516203926500); - Aesi512 m56 = -3883942059250462, m57 = -34609928360199472; - m56 -= m57; EXPECT_EQ(m56, 30725986300949010); - Aesi512 m58 = 14175824081074887, m59 = 1435953275620283; - m58 -= m59; EXPECT_EQ(m58, 12739870805454604); - Aesi512 m60 = -60149276957042841, m61 = -76721648621066592; - m60 -= m61; EXPECT_EQ(m60, 16572371664023751); - Aesi512 m62 = 61326832747483284, m63 = 46379655301271614; - m62 -= m63; EXPECT_EQ(m62, 14947177446211670); - Aesi512 m64 = 21854645686000102, m65 = 45002361665513639; - m64 -= m65; EXPECT_EQ(m64, -23147715979513537); - Aesi512 m66 = 33091273075346782, m67 = 321895524121470; - m66 -= m67; EXPECT_EQ(m66, 32769377551225312); - Aesi512 m68 = -51174023236882378, m69 = 66903075876437798; - m68 -= m69; EXPECT_EQ(m68, -118077099113320176); - Aesi512 m70 = -24801419283802435, m71 = -14207322058971261; - m70 -= m71; EXPECT_EQ(m70, -10594097224831174); - Aesi512 m72 = -92599999116779629, m73 = 90215441005269707; - m72 -= m73; EXPECT_EQ(m72, -182815440122049336); - Aesi512 m74 = 73877826268355011, m75 = 65420173307826179; - m74 -= m75; EXPECT_EQ(m74, 8457652960528832); - Aesi512 m76 = 19586642362468978, m77 = -65885160582015983; - m76 -= m77; EXPECT_EQ(m76, 85471802944484961); - Aesi512 m78 = 7573797785526040, m79 = -17722295466379071; - m78 -= m79; EXPECT_EQ(m78, 25296093251905111); - -} - -TEST(Subtraction, DifferentPrecision) { - { - Aesi < 448 > first = 62809965279956307; // Aesi<14 blocks> - Aesi < 448 > second = 39080556778759957; // Aesi<14 blocks> - EXPECT_EQ(first - second, 23729408501196350); - - Aesi < 192 > third = 45398660613732434; // Aesi<6 blocks> - Aesi < 352 > forth = -53004642661804844; // Aesi<11 blocks> - forth -= third; EXPECT_EQ(forth, -98403303275537278); - } - { - Aesi < 320 > first = 18374689440060232; // Aesi<10 blocks> - Aesi < 288 > second = -53557241983505081; // Aesi<9 blocks> - EXPECT_EQ(first - second, 71931931423565313); - - Aesi < 256 > third = 71440960238152095; // Aesi<8 blocks> - Aesi < 448 > forth = 27627026332533578; // Aesi<14 blocks> - forth -= third; EXPECT_EQ(forth, -43813933905618517); - } - { - Aesi < 320 > first = -58860382348449740; // Aesi<10 blocks> - Aesi < 448 > second = -51106271527231455; // Aesi<14 blocks> - EXPECT_EQ(first - second, -7754110821218285); - - Aesi < 320 > third = -26435995134335414; // Aesi<10 blocks> - Aesi < 416 > forth = 6966067345525782; // Aesi<13 blocks> - forth -= third; EXPECT_EQ(forth, 33402062479861196); - } - { - Aesi < 224 > first = 26949994938035307; // Aesi<7 blocks> - Aesi < 320 > second = -57345460147331841; // Aesi<10 blocks> - EXPECT_EQ(first - second, 84295455085367148); - - Aesi < 320 > third = 40115210446714256; // Aesi<10 blocks> - Aesi < 416 > forth = 19929757054766530; // Aesi<13 blocks> - forth -= third; EXPECT_EQ(forth, -20185453391947726); - } - { - Aesi < 480 > first = 43936342115046018; // Aesi<15 blocks> - Aesi < 480 > second = -10279600786446307; // Aesi<15 blocks> - EXPECT_EQ(first - second, 54215942901492325); - - Aesi < 256 > third = -22316375566079840; // Aesi<8 blocks> - Aesi < 480 > forth = 76005949847059604; // Aesi<15 blocks> - forth -= third; EXPECT_EQ(forth, 98322325413139444); - } - { - Aesi < 192 > first = -93657206214492841; // Aesi<6 blocks> - Aesi < 256 > second = -71486982985505092; // Aesi<8 blocks> - EXPECT_EQ(first - second, -22170223228987749); - - Aesi < 320 > third = -66846726585288343; // Aesi<10 blocks> - Aesi < 416 > forth = 94957726168621779; // Aesi<13 blocks> - forth -= third; EXPECT_EQ(forth, 161804452753910122); - } - { - Aesi < 192 > first = -62005162619173997; // Aesi<6 blocks> - Aesi < 224 > second = 10671564912426240; // Aesi<7 blocks> - EXPECT_EQ(first - second, -72676727531600237); - - Aesi < 224 > third = -30028516325007256; // Aesi<7 blocks> - Aesi < 416 > forth = -38572290747742216; // Aesi<13 blocks> - forth -= third; EXPECT_EQ(forth, -8543774422734960); - } - { - Aesi < 320 > first = -58940891305080103; // Aesi<10 blocks> - Aesi < 320 > second = -57959309993606272; // Aesi<10 blocks> - EXPECT_EQ(first - second, -981581311473831); - - Aesi < 224 > third = 30782639550732749; // Aesi<7 blocks> - Aesi < 416 > forth = -14578762817130093; // Aesi<13 blocks> - forth -= third; EXPECT_EQ(forth, -45361402367862842); - } - { - Aesi < 480 > first = 51699864098074373; // Aesi<15 blocks> - Aesi < 448 > second = -48065639687773956; // Aesi<14 blocks> - EXPECT_EQ(first - second, 99765503785848329); - - Aesi < 320 > third = 10097273671316052; // Aesi<10 blocks> - Aesi < 384 > forth = 90189328318453908; // Aesi<12 blocks> - forth -= third; EXPECT_EQ(forth, 80092054647137856); - } - { - Aesi < 416 > first = -10287965013816677; // Aesi<13 blocks> - Aesi < 448 > second = -86849365490800050; // Aesi<14 blocks> - EXPECT_EQ(first - second, 76561400476983373); - - Aesi < 288 > third = -92327403515448960; // Aesi<9 blocks> - Aesi < 480 > forth = -33125917700155649; // Aesi<15 blocks> - forth -= third; EXPECT_EQ(forth, 59201485815293311); - } -} - -TEST(Subtraction, Huge) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = "33222596524985513709662952543563830144665033768843521976647267647208461019340.", m1 = "38164587188950119838788779223640089081210824113434762269236295652677101782847."; - EXPECT_EQ(m0 - m1, "-4941990663964606129125826680076258936545790344591240292589028005468640763507."); - Aesi512 m2 = "-20655758169036112271685620846052214614763131315690731014041641003605056720634.", m3 = "59199224584144892366883614712316743122019635122733897184093806569587153761359."; - EXPECT_EQ(m2 - m3, "-79854982753181004638569235558368957736782766438424628198135447573192210481993."); - Aesi512 m4 = "26958868127252037114576940803541315851501818694925913710169209014144090575221.", m5 = "-56690160172817430971857821372203806609205243229668824848471807171498249879318."; - EXPECT_EQ(m4 - m5, "83649028300069468086434762175745122460707061924594738558641016185642340454539."); - Aesi512 m6 = "62271417650077980871661978474505797628609067899109204694570720181432917537155.", m7 = "37893123994206120771871620930908678086437541807476235392480822787464692298836."; - EXPECT_EQ(m6 - m7, "24378293655871860099790357543597119542171526091632969302089897393968225238319."); - Aesi512 m8 = "29119125820549207989533872126988773973336509273086275931307116309627663872764.", m9 = "103422645015979300874351532976096329446015089824804268157728527112508361966955."; - EXPECT_EQ(m8 - m9, "-74303519195430092884817660849107555472678580551717992226421410802880698094191."); - Aesi512 m10 = "50685555657005502622459560104926025111811051971013153345984376288752108540188.", m11 = "11843150404386388672920897470954408372302381204169961052664707905647933686837."; - EXPECT_EQ(m10 - m11, "38842405252619113949538662633971616739508670766843192293319668383104174853351."); - Aesi512 m12 = "-30900015346017600139138533552783308255981128442348425033319973544038485573472.", m13 = "-77992754162449513537054313689747133344104862431700888956875859760399783240435."; - EXPECT_EQ(m12 - m13, "47092738816431913397915780136963825088123733989352463923555886216361297666963."); - Aesi512 m14 = "65082877906485644797721502363270835120492034138725085010689320321661912760737.", m15 = "-38969237421470469438500362894082110662786709839661076629850200418243852223388."; - EXPECT_EQ(m14 - m15, "104052115327956114236221865257352945783278743978386161640539520739905764984125."); - Aesi512 m16 = "61212903975196419295571316677874168511942655895870466644870726328349386664897.", m17 = "92619071253884935168968518756355928446184177736323740507835354552468063275534."; - EXPECT_EQ(m16 - m17, "-31406167278688515873397202078481759934241521840453273862964628224118676610637."); - Aesi512 m18 = "-109423328323685337223243585746549977936151472435030868767338269334030245780476.", m19 = "106980979290762696136437657186082334204905776714683848866090958404411158872201."; - EXPECT_EQ(m18 - m19, "-216404307614448033359681242932632312141057249149714717633429227738441404652677."); - Aesi512 m20 = "63552600707916277817720537500363942441908285110796788213427780401436510185750.", m21 = "48949257653219171838097393706614389785635520588763819977555147498680754785689."; - EXPECT_EQ(m20 - m21, "14603343054697105979623143793749552656272764522032968235872632902755755400061."); - Aesi512 m22 = "80954485105355033282884478790513874455581515000409570871000175336925361642696.", m23 = "-15491903030310570779840793986611440289534185668407172861515710596746544596406."; - EXPECT_EQ(m22 - m23, "96446388135665604062725272777125314745115700668816743732515885933671906239102."); - Aesi512 m24 = "-100691731824186068764968826464574719708400095616997195584756451515329304133617.", m25 = "-100046691375446418738112774473177013367893295657206102959213724682429093090171."; - EXPECT_EQ(m24 - m25, "-645040448739650026856051991397706340506799959791092625542726832900211043446."); - Aesi512 m26 = "69907242277614666400287666286616049218777988280380023239870563976484469658330.", m27 = "-5078726041238874192253951761215504716450449736385389877662725507693927853612."; - EXPECT_EQ(m26 - m27, "74985968318853540592541618047831553935228438016765413117533289484178397511942."); - Aesi512 m28 = "-72064544621693023707170549905448391811193918132072455068924098586410745176963.", m29 = "-112788947572031669352390148660909930700043267816392846193686326130634540416853."; - EXPECT_EQ(m28 - m29, "40724402950338645645219598755461538888849349684320391124762227544223795239890."); - Aesi512 m30 = "-40882820628165474745984965016509801758293621338996271988397807746014654142440.", m31 = "99198140551075478590383016971471611901720362790536512975762861418717025064819."; - EXPECT_EQ(m30 - m31, "-140080961179240953336367981987981413660013984129532784964160669164731679207259."); - Aesi512 m32 = "-109111989092615602121419552227361347083553546992868639722304979612312773895105.", m33 = "55010922565031645146809449116768001661722824418643628244820717827722058872985."; - EXPECT_EQ(m32 - m33, "-164122911657647247268229001344129348745276371411512267967125697440034832768090."); - Aesi512 m34 = "19898073490294501319621680853914831631426239624483851397515427093512533545708.", m35 = "-90310803675666748770044729156579955271304420605016556659379137084668790990990."; - EXPECT_EQ(m34 - m35, "110208877165961250089666410010494786902730660229500408056894564178181324536698."); - Aesi512 m36 = "88138684465567652012578510190024346729952426116694926616788015677014776782038.", m37 = "-110466946002425997027566594215278641859585678157602102095618335328528575825477."; - EXPECT_EQ(m36 - m37, "198605630467993649040145104405302988589538104274297028712406351005543352607515."); - Aesi512 m38 = "71577173473491035814151216394314316595642112940484353409863250980259338066239.", m39 = "92108652034337674738354989171228951131762735929308425410841512173070831672258."; - EXPECT_EQ(m38 - m39, "-20531478560846638924203772776914634536120622988824072000978261192811493606019."); - Aesi512 m40 = "-63440691425172217479898559816235529686305091157362335875809085576110842892885.", m41 = "-63795520363725445401562797099751089065569801197474521515790205559435009961491."; - EXPECT_EQ(m40 - m41, "354828938553227921664237283515559379264710040112185639981119983324167068606."); - Aesi512 m42 = "-115517095520320949983186900947191662095928727331133077531986466168009664912659.", m43 = "3352973153240526402924981556162601221294988986607230953214012744254070043780."; - EXPECT_EQ(m42 - m43, "-118870068673561476386111882503354263317223716317740308485200478912263734956439."); - Aesi512 m44 = "2610559525592840142842762222198043612825996352965818891304756511547357142734.", m45 = "-6913485315335810525181676495765444329548153996277518112500092852513311852208."; - EXPECT_EQ(m44 - m45, "9524044840928650668024438717963487942374150349243337003804849364060668994942."); - Aesi512 m46 = "-97500706297397923462646489702631558452903335381260841190219325763941162928018.", m47 = "-48123377138634807747887134902683167588223745154696969320323977098955092175384."; - EXPECT_EQ(m46 - m47, "-49377329158763115714759354799948390864679590226563871869895348664986070752634."); - Aesi512 m48 = "56566630587882601367005167971293714803349239427453170990236600295437467804981.", m49 = "-14081756289437455587948835268927184363729806121020471512803317601227492241866."; - EXPECT_EQ(m48 - m49, "70648386877320056954954003240220899167079045548473642503039917896664960046847."); - Aesi512 m50 = "91618056312627750469926223893568929342270887199062050930564853327442406953224.", m51 = "-51278692377129304162219307711464762510159987983897482063537371187421125065709."; - EXPECT_EQ(m50 - m51, "142896748689757054632145531605033691852430875182959532994102224514863532018933."); - Aesi512 m52 = "-46964633813664458685977109998658517280889777396567992359752624956120962922996.", m53 = "90483707431967222703100777943282422615209102912420617113405312520509476610175."; - EXPECT_EQ(m52 - m53, "-137448341245631681389077887941940939896098880308988609473157937476630439533171."); - Aesi512 m54 = "38371228225280602355561278455922897623434967881107610292980950563105223837019.", m55 = "51683884607355301333473325338787671840047111115965832452345954636683990449438."; - EXPECT_EQ(m54 - m55, "-13312656382074698977912046882864774216612143234858222159365004073578766612419."); - Aesi512 m56 = "-74988399562281635378306461552451389784621304264353654752806865918711343715010.", m57 = "-51368118090333402494971347143142457785617585182764002742063450153089155471016."; - EXPECT_EQ(m56 - m57, "-23620281471948232883335114409308931999003719081589652010743415765622188243994."); - Aesi512 m58 = "-57783930614347594204895765322618734671756211340787021508887237149528342051331.", m59 = "38252465199386292022020899509508093778744442175770614003544480075636467549885."; - EXPECT_EQ(m58 - m59, "-96036395813733886226916664832126828450500653516557635512431717225164809601216."); - Aesi512 m60 = "-105037808863071143136280567390912600661668417381384029445606346583600447575944.", m61 = "-10100265705668152253869959230893731182489495739946840904675099276961328919038."; - EXPECT_EQ(m60 - m61, "-94937543157402990882410608160018869479178921641437188540931247306639118656906."); - Aesi512 m62 = "-77342544119066042052356221357567298013829096789933634129435013375234756068107.", m63 = "57982276766897717870621647321953113025674790001544682187764646062150591427706."; - EXPECT_EQ(m62 - m63, "-135324820885963759922977868679520411039503886791478316317199659437385347495813."); - Aesi512 m64 = "82109627665560004436006227203118823278537980902639624995656993122237864704661.", m65 = "-37476366201541662693700238424140425499396005834257551217865668727677027299764."; - EXPECT_EQ(m64 - m65, "119585993867101667129706465627259248777933986736897176213522661849914892004425."); - Aesi512 m66 = "94746145757664330736331789598219169709676747254675537796541093495564575547629.", m67 = "-80295723245701713883941051502993562885914257770957092316351549290528802228953."; - EXPECT_EQ(m66 - m67, "175041869003366044620272841101212732595591005025632630112892642786093377776582."); - Aesi512 m68 = "-62205219590368656517373653537566334278125361061944704007095355398852388685777.", m69 = "-69759521213814445854358269773975450616308875639642050020152001773009074525222."; - EXPECT_EQ(m68 - m69, "7554301623445789336984616236409116338183514577697346013056646374156685839445."); - Aesi512 m70 = "-52018008406009027204400038295771181434823032854961801629435980574369930405617.", m71 = "48258637967364684888731426454671140030000400847227823814582874801529824079683."; - EXPECT_EQ(m70 - m71, "-100276646373373712093131464750442321464823433702189625444018855375899754485300."); - Aesi512 m72 = "-62332885183385243844058787080310280067520965771691909531189028120991339869389.", m73 = "6348735979717991983972369426504079154461583860760946738495267090664006456532."; - EXPECT_EQ(m72 - m73, "-68681621163103235828031156506814359221982549632452856269684295211655346325921."); - Aesi512 m74 = "52071012593060623602408189450573668951427299770652626616894658222191313153941.", m75 = "-57699409424083664658784369543357837130473765455970762985223614494324479962207."; - EXPECT_EQ(m74 - m75, "109770422017144288261192558993931506081901065226623389602118272716515793116148."); - Aesi512 m76 = "-13425517474516487808633030437360462889284209510408099377905980719718376754044.", m77 = "93176027713798714455781005592937632137607759249583290215549115952808316378365."; - EXPECT_EQ(m76 - m77, "-106601545188315202264414036030298095026891968759991389593455096672526693132409."); - Aesi512 m78 = "-34000990628541689650586425967236449811962489573399592518797616588764678311522.", m79 = "112735151533921799285028979146314326415142765594527880905828573317748052289962."; - EXPECT_EQ(m78 - m79, "-146736142162463488935615405113550776227105255167927473424626189906512730601484."); - -#ifdef NDEBUG - Logging::addRecord("Subtraction", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Subtraction, HugeAssignment) { - Aesi512 m0 = "5021555443161350435343743466255338443131530915074558960926318256228994680600.", m1 = "-85719994781587882332412559153868900916066423953219741217892093915831882842556."; - m0 -= m1; EXPECT_EQ(m0, "90741550224749232767756302620124239359197954868294300178818412172060877523156."); - Aesi512 m2 = "100174169972639146960615775553170901369115376387076814088869992592912560747942.", m3 = "-107282235675435932023120015659323681095907719806543822097032890721520985982185."; - m2 -= m3; EXPECT_EQ(m2, "207456405648075078983735791212494582465023096193620636185902883314433546730127."); - Aesi512 m4 = "78170546042698907611504653697393424536359162898692773353321953155209900336276.", m5 = "33391044965348871365767888030959759172966142607881492709732146581928527463824."; - m4 -= m5; EXPECT_EQ(m4, "44779501077350036245736765666433665363393020290811280643589806573281372872452."); - Aesi512 m6 = "-76772143453561056040336653671233185724352013908042045937046372435857610514469.", m7 = "106538021746428492311940413586930292977538122001651765863508273971115125034854."; - m6 -= m7; EXPECT_EQ(m6, "-183310165199989548352277067258163478701890135909693811800554646406972735549323."); - Aesi512 m8 = "-72909603898537174930313271244616509170259578923036163595525269688866859747391.", m9 = "-7161285656105994165115509152016523761505204352824209448800869579914110209376."; - m8 -= m9; EXPECT_EQ(m8, "-65748318242431180765197762092599985408754374570211954146724400108952749538015."); - Aesi512 m10 = "-62074166724638544455462042777391615251163788981404737367134026707641286643377.", m11 = "51891915800062421620211998790809812694505190596100009103570331826417400308306."; - m10 -= m11; EXPECT_EQ(m10, "-113966082524700966075674041568201427945668979577504746470704358534058686951683."); - Aesi512 m12 = "-78838559842638677581481243364460864462920735575476913773490453140857869228067.", m13 = "72054345108634957913094627915215443033478417265748089236055132491429623674536."; - m12 -= m13; EXPECT_EQ(m12, "-150892904951273635494575871279676307496399152841225003009545585632287492902603."); - Aesi512 m14 = "13120017110616461521468402741923338436805343638174725979449023759617349909327.", m15 = "86370881378439920118427473446906964233064368723456931476794828628913591082063."; - m14 -= m15; EXPECT_EQ(m14, "-73250864267823458596959070704983625796259025085282205497345804869296241172736."); - Aesi512 m16 = "-16366068998741025550681011261248680804279944015243250885351640763747667151899.", m17 = "87344149565387928799748768897997250540172474987632300948155020153403583110709."; - m16 -= m17; EXPECT_EQ(m16, "-103710218564128954350429780159245931344452419002875551833506660917151250262608."); - Aesi512 m18 = "-58084358663068189820812032067498711418847237464830769448383290180213063238795.", m19 = "-100908642605357358870811382857458300720257976353711833968167959110953704075383."; - m18 -= m19; EXPECT_EQ(m18, "42824283942289169049999350789959589301410738888881064519784668930740640836588."); - Aesi512 m20 = "-32296842873527547016394011159127688649248769704473660817110653309011429809011.", m21 = "58741619996974314605642126958257743442074701487008508282213403393893875209795."; - m20 -= m21; EXPECT_EQ(m20, "-91038462870501861622036138117385432091323471191482169099324056702905305018806."); - Aesi512 m22 = "69952890721640886203345873414192222462131750911900292126704810227750463299569.", m23 = "77765114689911367868124690868160095110439973660097708139491179259149672441509."; - m22 -= m23; EXPECT_EQ(m22, "-7812223968270481664778817453967872648308222748197416012786369031399209141940."); - Aesi512 m24 = "-57434957991165694932357631911927294084164742710665673700680380621655356115258.", m25 = "-99242518361371508596912840723392881501561210574474351911315699982046737543148."; - m24 -= m25; EXPECT_EQ(m24, "41807560370205813664555208811465587417396467863808678210635319360391381427890."); - Aesi512 m26 = "98300901471094315699137535710731778426103127590682675692706430144952233318738.", m27 = "50665380962851170484179954762230592410525206707887496708187096121745418857880."; - m26 -= m27; EXPECT_EQ(m26, "47635520508243145214957580948501186015577920882795178984519334023206814460858."); - Aesi512 m28 = "-37262100675873190464709698573910438869431367036756776170790211319724914252595.", m29 = "88105005638323380203447508117966163572906597468717203121967776454306733825534."; - m28 -= m29; EXPECT_EQ(m28, "-125367106314196570668157206691876602442337964505473979292757987774031648078129."); - Aesi512 m30 = "-29160040964356647095935341485209761437320701128473337125858639317988878745620.", m31 = "40760471294051373574794477932449977872859372440492853896959611986643098090155."; - m30 -= m31; EXPECT_EQ(m30, "-69920512258408020670729819417659739310180073568966191022818251304631976835775."); - Aesi512 m32 = "115260870051118666139680610682460318662883697012724246593045751444401739915425.", m33 = "68648461719212012941966995282240730938272126367987370046704949536973842216035."; - m32 -= m33; EXPECT_EQ(m32, "46612408331906653197713615400219587724611570644736876546340801907427897699390."); - Aesi512 m34 = "-20472243798489170668021409476885179297791906929515162423853828877842849481713.", m35 = "24265084003520114121360496014746041034674747980825690699673158176731210307066."; - m34 -= m35; EXPECT_EQ(m34, "-44737327802009284789381905491631220332466654910340853123526987054574059788779."); - Aesi512 m36 = "41543475181796934565690901519770293897106009882112351387455297776944705820170.", m37 = "-93585670921380344371068727435006167375534726206829832897147712963754914621889."; - m36 -= m37; EXPECT_EQ(m36, "135129146103177278936759628954776461272640736088942184284603010740699620442059."); - Aesi512 m38 = "-98506985554776878159552161904228269867232216231420463309051809269530856201685.", m39 = "-112691126129771387457033382401927262496027568447660174954910910095983161964222."; - m38 -= m39; EXPECT_EQ(m38, "14184140574994509297481220497698992628795352216239711645859100826452305762537."); - Aesi512 m40 = "-83573290255470326837494352855586503055523612683267269144532423399236956037170.", m41 = "-93293665856845919222690230815308558714558784150496407686250481213781443775807."; - m40 -= m41; EXPECT_EQ(m40, "9720375601375592385195877959722055659035171467229138541718057814544487738637."); - Aesi512 m42 = "115736705052455902015170052380765113841591402561081435865534805962808903803577.", m43 = "-69362873228450408138138038011840889227959890201724211999236878273327744368401."; - m42 -= m43; EXPECT_EQ(m42, "185099578280906310153308090392606003069551292762805647864771684236136648171978."); - Aesi512 m44 = "-92041150441778688018380433000712930295741784470520060861235898363172151503236.", m45 = "26640931763196499571358520008314012344119967661893355372393447072665104846697."; - m44 -= m45; EXPECT_EQ(m44, "-118682082204975187589738953009026942639861752132413416233629345435837256349933."); - Aesi512 m46 = "83164599375251949336647029143904637187736455547770279849122073052477836658486.", m47 = "100829938528882531123194721142045871042353459839907687665404611540318550811032."; - m46 -= m47; EXPECT_EQ(m46, "-17665339153630581786547691998141233854617004292137407816282538487840714152546."); - Aesi512 m48 = "64397034661334920608981229356154434766390562210766362157947938037470391337555.", m49 = "-99452608157324203948530089340727010008283153265111618280108930853928742194952."; - m48 -= m49; EXPECT_EQ(m48, "163849642818659124557511318696881444774673715475877980438056868891399133532507."); - Aesi512 m50 = "-101802292697160746098320302085320082731653198392002449628120797527487021322973.", m51 = "113238395804062725428280415833707973379877830791046802294629188978325240854014."; - m50 -= m51; EXPECT_EQ(m50, "-215040688501223471526600717919028056111531029183049251922749986505812262176987."); - Aesi512 m52 = "-62354430202370183310097428643792474961347670458820451941873413306672299557963.", m53 = "13883937916034789931044202285429614805677985953799268972582788138900734285183."; - m52 -= m53; EXPECT_EQ(m52, "-76238368118404973241141630929222089767025656412619720914456201445573033843146."); - Aesi512 m54 = "-4706728942432637809323697163341267476111674518715021316049976737971200076606.", m55 = "-10289531615886953666206020808850415873890361732224059583394996004236684695977."; - m54 -= m55; EXPECT_EQ(m54, "5582802673454315856882323645509148397778687213509038267345019266265484619371."); - Aesi512 m56 = "71675571155438292917540158677559422953350594240337761843913406150616377346080.", m57 = "78329763029119095884303716556478766957353928555860692953380824487016867457001."; - m56 -= m57; EXPECT_EQ(m56, "-6654191873680802966763557878919344004003334315522931109467418336400490110921."); - Aesi512 m58 = "-65789803601350742614767579169501919344154678175719851395735904600018437215262.", m59 = "99675718461673344653333232346196148081073494030400220651697711351816092305699."; - m58 -= m59; EXPECT_EQ(m58, "-165465522063024087268100811515698067425228172206120072047433615951834529520961."); - Aesi512 m60 = "17823391170127178430703079062051812880373802357725835159096763661843952555084.", m61 = "68347209285830506654335804472177585730343417137924985149090773639759172343152."; - m60 -= m61; EXPECT_EQ(m60, "-50523818115703328223632725410125772849969614780199149989994009977915219788068."); - Aesi512 m62 = "-50106258275167560080663580607352658701756970754448143607737617004311348794021.", m63 = "106755461937546681456481021878035738686412999223470518436782266676807562479530."; - m62 -= m63; EXPECT_EQ(m62, "-156861720212714241537144602485388397388169969977918662044519883681118911273551."); - Aesi512 m64 = "-26094572908207019398426614685466857901876990662475050234875246097344379677949.", m65 = "-29469109930553188358351949965388705192776244994087476080671425638841184498138."; - m64 -= m65; EXPECT_EQ(m64, "3374537022346168959925335279921847290899254331612425845796179541496804820189."); - Aesi512 m66 = "-102671191736207284417171960689609739505759033564715946371473625373278619812273.", m67 = "18574825673741365049190432931203328581864336132838842380751688345498734335593."; - m66 -= m67; EXPECT_EQ(m66, "-121246017409948649466362393620813068087623369697554788752225313718777354147866."); - Aesi512 m68 = "-28588934748771361054703458891108520546571710103309879891123257760282836351820.", m69 = "38317614963296817761991032641682468042338090966753032824119892661065560584182."; - m68 -= m69; EXPECT_EQ(m68, "-66906549712068178816694491532790988588909801070062912715243150421348396936002."); - Aesi512 m70 = "104751260809620197087710213227699839954718704706094715829189659308239442081389.", m71 = "-30577062896415400829896865979726946733195826494809281546945483678475139287379."; - m70 -= m71; EXPECT_EQ(m70, "135328323706035597917607079207426786687914531200903997376135142986714581368768."); - Aesi512 m72 = "-64754456137351490197496525693211096774427006972150534587761930850411620759755.", m73 = "-103604251144844696762839812014277871829301458338671135722787422614354301684212."; - m72 -= m73; EXPECT_EQ(m72, "38849795007493206565343286321066775054874451366520601135025491763942680924457."); - Aesi512 m74 = "96645170846776034136605091215289554998380547861502778082978677827325308912576.", m75 = "-94116540293770744347128118072873539610557537023032970587815042390811862439404."; - m74 -= m75; EXPECT_EQ(m74, "190761711140546778483733209288163094608938084884535748670793720218137171351980."); - Aesi512 m76 = "-98410801330254651903836359454252629145536768157058994755130545667289501962590.", m77 = "30938974986841686767445921277148681991908188507875838430222173971702496279766."; - m76 -= m77; EXPECT_EQ(m76, "-129349776317096338671282280731401311137444956664934833185352719638991998242356."); - Aesi512 m78 = "-59101614662735099695616215039060178192442022297580333710825038350486946014934.", m79 = "-49928955047523282066604479622960500311543004097546657058268120760593434751728."; - m78 -= m79; EXPECT_EQ(m78, "-9172659615211817629011735416099677880899018200033676652556917589893511263206."); -} \ No newline at end of file diff --git a/test/arithmetic/subtraction/signed.cpp b/test/arithmetic/subtraction/signed.cpp new file mode 100755 index 0000000..7cf8603 --- /dev/null +++ b/test/arithmetic/subtraction/signed.cpp @@ -0,0 +1,102 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Subtraction, Basic) { + Aesi128 zero = 0l; + Aesi128 m0 = 14377898l; + EXPECT_EQ(m0 - 0u, 14377898l); + EXPECT_EQ(m0 + 0u, 14377898l); + EXPECT_EQ(m0 + zero, 14377898l); + EXPECT_EQ(m0 - zero, 14377898l); + EXPECT_EQ(m0 + +zero, 14377898l); + EXPECT_EQ(m0 - +zero, 14377898l); + m0 -= 0u; EXPECT_EQ(m0, 14377898l); + m0 -= zero; EXPECT_EQ(m0, 14377898l); + m0 -= -zero; EXPECT_EQ(m0, 14377898l); + m0 -= +zero; EXPECT_EQ(m0, 14377898l); + + Aesi128 m1 = -42824647l; + EXPECT_EQ(m1 - 0u, -42824647l); + EXPECT_EQ(m1 + 0u, -42824647l); + EXPECT_EQ(m1 + zero, -42824647l); + EXPECT_EQ(m1 - zero, -42824647l); + EXPECT_EQ(m1 + +zero, -42824647l); + EXPECT_EQ(m1 - +zero, -42824647l); + m1 -= 0u; EXPECT_EQ(m1, -42824647l); + m1 -= zero; EXPECT_EQ(m1, -42824647l); + m1 -= +zero; EXPECT_EQ(m1, -42824647l); +} + +TEST(Signed_Subtraction, Huge) { + constexpr auto testsAmount = 2, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + int first = 0, second = 0; + switch(i % 4) { + case 0: + first = 1, second = 1; break; + case 1: + first = -1, second = -1; break; + case 2: + first = -1, second = 1; break; + default: + first = 1, second = -1; + } + const auto l = first * Generation::getRandomWithBits(blocksNumber * 32 - 110), + r = second * Generation::getRandomWithBits(blocksNumber * 32 - 110); + + Aesi lA = l, rA = r; + EXPECT_EQ(lA - rA, l - r); + + lA -= rA; + EXPECT_EQ(lA, l - r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 200); + const auto sub = Generation::getRandom(); + + Aesi aeu = value; + EXPECT_EQ((aeu - sub) - sub, (value - sub) - sub); + + aeu -= sub; aeu -= sub; + EXPECT_EQ(aeu, (value - sub) - sub); + } +} + +TEST(Signed_Subtraction, Decrement) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 110); + Aesi value = l; + + const std::size_t decrements = rand() % 100; + for (std::size_t j = 0; j < decrements * 2; j += 2) { + EXPECT_EQ(value--, l - j); + EXPECT_EQ(--value, l - j - 2); + } + EXPECT_EQ(value, l - decrements * 2); + } + + Aesi test = 0; --test; + EXPECT_EQ(test, -1); + EXPECT_FALSE(test.isZero()); + EXPECT_LT(test, 0); + + test = 0; test--; + EXPECT_EQ(test, -1); + EXPECT_FALSE(test.isZero()); + EXPECT_LT(test, 0); + + test = 1; --test; + EXPECT_EQ(test, 0); + EXPECT_TRUE(test.isZero()); + EXPECT_LT(test, 1); + + test = 1; test--; + EXPECT_EQ(test, 0); + EXPECT_TRUE(test.isZero()); + EXPECT_LT(test, 1); +} \ No newline at end of file diff --git a/test/arithmetic/subtraction/unsigned.cpp b/test/arithmetic/subtraction/unsigned.cpp new file mode 100755 index 0000000..afa5afc --- /dev/null +++ b/test/arithmetic/subtraction/unsigned.cpp @@ -0,0 +1,84 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Subtraction, Basic) { + Aeu128 zero = 0u; + Aeu128 m0 = 14377898u; + EXPECT_EQ(m0 - 0u, 14377898u); + EXPECT_EQ(m0 + 0u, 14377898u); + EXPECT_EQ(m0 + zero, 14377898u); + EXPECT_EQ(m0 - zero, 14377898u); + EXPECT_EQ(m0 + +zero, 14377898u); + EXPECT_EQ(m0 - +zero, 14377898u); + m0 -= 0u; EXPECT_EQ(m0, 14377898u); + m0 -= zero; EXPECT_EQ(m0, 14377898u); + m0 -= -zero; EXPECT_EQ(m0, 14377898u); + m0 -= +zero; EXPECT_EQ(m0, 14377898u); + + Aeu128 m1 = 42824647u; + EXPECT_EQ(m1 - 0u, 42824647u); + EXPECT_EQ(m1 + 0u, 42824647u); + EXPECT_EQ(m1 + zero, 42824647u); + EXPECT_EQ(m1 - zero, 42824647u); + EXPECT_EQ(m1 + +zero, 42824647u); + EXPECT_EQ(m1 - +zero, 42824647u); + m1 -= 0u; EXPECT_EQ(m1, 42824647u); + m1 -= zero; EXPECT_EQ(m1, 42824647u); + m1 -= +zero; EXPECT_EQ(m1, 42824647u); +} + +TEST(Unsigned_Subtraction, Huge) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + /* Composite numbers. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 5), + r = Generation::getRandomWithBits(blocksNumber * 32 - 32); + + Aeu lA = l, rA = r; + EXPECT_EQ(lA - rA, l - r); + + lA -= rA; + EXPECT_EQ(lA, l - r); + } + + /* Built-in types. */ + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 10); + const auto subU = Generation::getRandom(); + + Aeu aeu = value; + EXPECT_EQ(aeu - subU, value - subU); + + aeu -= subU; + EXPECT_EQ(aeu, value - subU); + } +} + +TEST(Unsigned_Subtraction, Decrement) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 110); + Aeu value = l; + + const std::size_t decrements = rand() % 100; + for (std::size_t j = 0; j < decrements * 2; j += 2) { + EXPECT_EQ(value--, l - j); + EXPECT_EQ(--value, l - j - 2); + } + EXPECT_EQ(value, l - decrements * 2); + } + + Aeu test = 1u; --test; + EXPECT_EQ(test, 0u); + EXPECT_TRUE(test.isZero()); + EXPECT_LT(test, 1u); + + test = 1u; test--; + EXPECT_EQ(test, 0u); + EXPECT_TRUE(test.isZero()); + EXPECT_LT(test, 1u); + + Aeu<4 * 32> test2 = "0x0000_0001'0000_0000'0000_0000'0000_0000"; + EXPECT_EQ(--test2, "0x0000_0000'FFFF_FFFF'FFFF_FFFF'FFFF_FFFF"); +} \ No newline at end of file diff --git a/test/benchmarks/benchmarks.h b/test/benchmarks/benchmarks.h deleted file mode 100644 index d9baec1..0000000 --- a/test/benchmarks/benchmarks.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef AESIMULTIPRECISION_BENCHMARKS_H -#define AESIMULTIPRECISION_BENCHMARKS_H - -#include -#include -#include - -namespace Logging { - class DatabaseInterface final { - sqlite3* db = nullptr; - - class DatabaseMessage final { - char* message = nullptr; - public: - DatabaseMessage() = default; - operator char* () { return message; } - operator char** () { return &message; } - ~DatabaseMessage() { sqlite3_free(message); } - }; - - public: - DatabaseInterface() = delete; - - DatabaseInterface(const std::filesystem::path& dbLocation) { - if(sqlite3_open(dbLocation.c_str(), &db) != SQLITE_OK) - throw std::runtime_error("Failed to open database"); - } - - void exec(const std::string& query) { - DatabaseMessage message {}; - if (sqlite3_exec(db, query.c_str(), nullptr, nullptr, message) != SQLITE_OK) - throw std::runtime_error(std::string("Query failed: ") + message.operator char *()); - } - - ~DatabaseInterface() { - if(sqlite3_close(db) != SQLITE_OK) - std::cerr << "Failed to close database connection." << std::endl; - } - }; - - static std::filesystem::path getTimeDbLocation() { -#define TimeDatabase "measures.db" - return std::filesystem::path(__FILE__).parent_path() / TimeDatabase; - } - - static void addRecord(const std::string &table, std::time_t date, std::size_t timeMs) { - using namespace std::string_literals; - - std::tm *timeInfo = std::localtime(&date); - char buffer[20]{}; - std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo); - - try { - DatabaseInterface db(getTimeDbLocation()); - db.exec("CREATE TABLE IF NOT EXISTS "s + table + - "(test_date DATETIME PRIMARY KEY NOT NULL, time_ms INTEGER NOT NULL);"); - db.exec("INSERT INTO "s + table + "(test_date, time_ms) VALUES ('" + buffer + "', " + - std::to_string(timeMs) + ");"); - } catch (const std::exception &e) { - std::cout << "Add time measurement for " << table << " failed: " << e.what() << "." << std::endl; - } - } -} - -#endif //AESIMULTIPRECISION_BENCHMARKS_H diff --git a/test/benchmarks/measures.db b/test/benchmarks/measures.db deleted file mode 100644 index 0104ee5..0000000 Binary files a/test/benchmarks/measures.db and /dev/null differ diff --git a/test/bitwise/CMakeLists.txt b/test/bitwise/CMakeLists.txt old mode 100644 new mode 100755 index 9ad5740..ed89769 --- a/test/bitwise/CMakeLists.txt +++ b/test/bitwise/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB BitwiseTests *.cpp) +file(GLOB BitwiseTests *.cpp and/*.cpp manipulations/*.cpp or/*.cpp xor/*.cpp shift/*.cpp) target_sources(AesiMultiprecision PRIVATE ${BitwiseTests}) \ No newline at end of file diff --git a/test/bitwise/and.cpp b/test/bitwise/and.cpp new file mode 100755 index 0000000..e645633 --- /dev/null +++ b/test/bitwise/and.cpp @@ -0,0 +1,18 @@ +#include +#include "../../Aeu.h" +#include "../generation.h" + +TEST(Unsigned_Bitwise, AND) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + Aeu left = l, right = r; + EXPECT_EQ(left & right, l & r); + + l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + left = l, right = r; left &= right; + EXPECT_EQ(left, l & r); + } +} \ No newline at end of file diff --git a/test/bitwise/bitwise_and.cpp b/test/bitwise/bitwise_and.cpp deleted file mode 100644 index 4522a8c..0000000 --- a/test/bitwise/bitwise_and.cpp +++ /dev/null @@ -1,420 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, AND) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi < 96 > m0 = 807495886205862545ULL, m1 = 1699422046959474079ULL; - EXPECT_EQ(m0 & m1, 221957416007270545); - Aesi < 96 > m2 = 6020843877211540190ULL, m3 = 2820365921155811108ULL; - EXPECT_EQ(m2 & m3, 216825446434865668); - Aesi < 96 > m4 = 496287893612905849ULL, m5 = 5537849818418819518ULL; - EXPECT_EQ(m4 & m5, 342872881284284728); - Aesi < 96 > m6 = 165318749836852092ULL, m7 = 8926412243518722244ULL; - EXPECT_EQ(m6 & m7, 162222513246474308); - Aesi < 96 > m8 = 5264123772951786426ULL, m9 = 2852134561985560693ULL; - EXPECT_EQ(m8 & m9, 73394618703708208); - Aesi < 96 > m10 = 4205707638274056784ULL, m11 = 1984793449478590286ULL; - EXPECT_EQ(m10 & m11, 1876070303540478528); - Aesi < 96 > m12 = 9010636561450167420ULL, m13 = 3553584763672728327ULL; - EXPECT_EQ(m12 & m13, 3530846306868133892); - Aesi < 96 > m14 = 7253126117003635320ULL, m15 = 5828253018003978680ULL; - EXPECT_EQ(m14 & m15, 4656727529491015736); - Aesi < 96 > m16 = 5594942297097490178ULL, m17 = 3233208432597169874ULL; - EXPECT_EQ(m16 & m17, 901890218922100226); - Aesi < 96 > m18 = 2440701276938964359ULL, m19 = 5097711526480249732ULL; - EXPECT_EQ(m18 & m19, 44495591782220164); - Aesi < 96 > m20 = 4961542391997891365ULL, m21 = 8957960641716920054ULL; - EXPECT_EQ(m20 & m21, 4922452551855735332); - Aesi < 96 > m22 = 4772516690168967743ULL, m23 = 6418922195999336602ULL; - EXPECT_EQ(m22 & m23, 4616192505617063962); - Aesi < 96 > m24 = 4879230276091144715ULL, m25 = 578663735221075192ULL; - EXPECT_EQ(m24 & m25, 1831862171346952); - Aesi < 96 > m26 = 8051937268484037076ULL, m27 = 6554740396428438499ULL; - EXPECT_EQ(m26 & m27, 5383516828817426880); - Aesi < 96 > m28 = 1305644231050943800ULL, m29 = 150888236037976121ULL; - EXPECT_EQ(m28 & m29, 150888179985289272); - Aesi < 96 > m30 = 7826866948865614259ULL, m31 = 5886922966844117361ULL; - EXPECT_EQ(m30 & m31, 4652935318167683377); - Aesi < 96 > m32 = 5066295933064978557ULL, m33 = 5341944783702619361ULL; - EXPECT_EQ(m32 & m33, 4756364474424238177); - Aesi < 96 > m34 = 3825298084329337048ULL, m35 = 7308700973399774971ULL; - EXPECT_EQ(m34 & m35, 2667309961348550872); - Aesi < 96 > m36 = 3150148350274398294ULL, m37 = 565366596855016744ULL; - EXPECT_EQ(m36 & m37, 256864782519511040); - Aesi < 96 > m38 = 6815390237134941828ULL, m39 = 2482521022620068152ULL; - EXPECT_EQ(m38 & m39, 148936578777311232); - - Aesi < 96 > r0 = 4344279557358000924ULL, r1 = 3724904829868641935ULL; - r0 &= r1; EXPECT_EQ(r0, 3459188053502855692); - Aesi < 96 > r2 = 1112834019237028400ULL, r3 = 3625059836849560394ULL; - r2 &= r3; EXPECT_EQ(r2, 162275426907193856); - Aesi < 96 > r4 = 4335728930570490046ULL, r5 = 8093173946221350096ULL; - r4 &= r5; EXPECT_EQ(r4, 3458934186923540624); - Aesi < 96 > r6 = 1822629055601206922ULL, r7 = 146367862301361490ULL; - r6 &= r7; EXPECT_EQ(r6, 2252109051331586); - Aesi < 96 > r8 = 7297995515302880473ULL, r9 = 2998472088715638536ULL; - r8 &= r9; EXPECT_EQ(r8, 2379220292686947336); - Aesi < 96 > r10 = 5710777460057741934ULL, r11 = 1838971091260172745ULL; - r10 &= r11; EXPECT_EQ(r10, 648589087707760712); - Aesi < 96 > r12 = 1815093428787458358ULL, r13 = 6410954302032519131ULL; - r12 &= r13; EXPECT_EQ(r12, 1742893983790600466); - Aesi < 96 > r14 = 875664792203268108ULL, r15 = 7995211383371396853ULL; - r14 &= r15; EXPECT_EQ(r14, 875018171160104964); - Aesi < 96 > r16 = 9023990112834530628ULL, r17 = 2214624467228169116ULL; - r16 &= r17; EXPECT_EQ(r16, 2034401282399273220); - Aesi < 96 > r18 = 5713056118405738636ULL, r19 = 5675644662191157970ULL; - r18 &= r19; EXPECT_EQ(r18, 5638735454455083136); - Aesi < 96 > r20 = 2359788090022102190ULL, r21 = 7785696910268559981ULL; - r20 &= r21; EXPECT_EQ(r20, 2309222920311865388); - Aesi < 96 > r22 = 7370909568331285304ULL, r23 = 4014661568115332139ULL; - r22 &= r23; EXPECT_EQ(r22, 2738946274675392552); - Aesi < 96 > r24 = 5955384016749281757ULL, r25 = 8864715236630449151ULL; - r24 &= r25; EXPECT_EQ(r24, 5910343392629440989); - Aesi < 96 > r26 = 1256363509734577876ULL, r27 = 3140580802002726154ULL; - r26 &= r27; EXPECT_EQ(r26, 73488679326712832); - Aesi < 96 > r28 = 4818806868701803866ULL, r29 = 2102472921918857446ULL; - r28 &= r29; EXPECT_EQ(r28, 3750780444663874); - Aesi < 96 > r30 = 4315386286410443642ULL, r31 = 2453081287190472343ULL; - r30 &= r31; EXPECT_EQ(r30, 2450820652626878994); - Aesi < 96 > r32 = 7020035880803699723ULL, r33 = 7392799005541845695ULL; - r32 &= r33; EXPECT_EQ(r32, 6919830308045719563); - Aesi < 96 > r34 = 717042233482679795ULL, r35 = 2358561338398651631ULL; - r34 &= r35; EXPECT_EQ(r34, 50456625176122595); - Aesi < 96 > r36 = 1699264370831645387ULL, r37 = 2269418300545444664ULL; - r36 &= r37; EXPECT_EQ(r36, 1663121155613002248); - Aesi < 96 > r38 = 8415579626477377023ULL, r39 = 1758383484602008231ULL; - r38 &= r39; EXPECT_EQ(r38, 1171498939003748519); - - Aesi512 y0 = 4889091353405609314; EXPECT_EQ(y0 & 0, 0); Aesi512 y1 = -5651070512456491307; EXPECT_EQ(y1 & 0, 0); - Aesi512 y2 = 8716999149386587222; EXPECT_EQ(y2 & 0, 0); Aesi512 y3 = 3990093180733831391; EXPECT_EQ(y3 & 0, 0); - Aesi512 y4 = -600115849107061037; EXPECT_EQ(y4 & 0, 0); Aesi512 y5 = 5971190278122453016; EXPECT_EQ(y5 & 0, 0); - Aesi512 y6 = 3882719951867855839; EXPECT_EQ(y6 & 0, 0); Aesi512 y7 = 3455443969755678518; EXPECT_EQ(y7 & 0, 0); - Aesi512 y8 = -3766894349432610843; EXPECT_EQ(y8 & 0, 0); Aesi512 y9 = -5791857218894865903; EXPECT_EQ(y9 & 0, 0); - Aesi512 y10 = -338534766738000611; EXPECT_EQ(y10 & 0, 0); Aesi512 y11 = 5102817375810074387; EXPECT_EQ(y11 & 0, 0); - Aesi512 y12 = 5476206818927814191; EXPECT_EQ(y12 & 0, 0); Aesi512 y13 = -947360454527944509; EXPECT_EQ(y13 & 0, 0); - Aesi512 y14 = 7367263158822837235; EXPECT_EQ(y14 & 0, 0); Aesi512 y15 = 7983868794538809353; EXPECT_EQ(y15 & 0, 0); - Aesi512 y16 = 4964001329143328906; EXPECT_EQ(y16 & 0, 0); Aesi512 y17 = -2083543087607023197; EXPECT_EQ(y17 & 0, 0); - Aesi512 y18 = 4767057428498046618; EXPECT_EQ(y18 & 0, 0); Aesi512 y19 = 7093268892832568583; EXPECT_EQ(y19 & 0, 0); - Aesi512 y20 = 4932144590764335822; EXPECT_EQ(y20 & 0, 0); Aesi512 y21 = 2129523306274277923; EXPECT_EQ(y21 & 0, 0); - Aesi512 y22 = 8744895838014776233; EXPECT_EQ(y22 & 0, 0); Aesi512 y23 = 6357409700796211810; EXPECT_EQ(y23 & 0, 0); - Aesi512 y24 = -1568025427859683472; EXPECT_EQ(y24 & 0, 0); Aesi512 y25 = 1955290413378850634; EXPECT_EQ(y25 & 0, 0); - Aesi512 y26 = -3467502238642711691; EXPECT_EQ(y26 & 0, 0); Aesi512 y27 = -3814588671259119772; EXPECT_EQ(y27 & 0, 0); - Aesi512 y28 = 4824738721222873185; EXPECT_EQ(y28 & 0, 0); Aesi512 y29 = -1835318120755538411; EXPECT_EQ(y29 & 0, 0); - Aesi512 y30 = 2147927829914714909; EXPECT_EQ(y30 & 0, 0); Aesi512 y31 = 3200786312241374990; EXPECT_EQ(y31 & 0, 0); - Aesi512 y32 = -483873791020330186; EXPECT_EQ(y32 & 0, 0); Aesi512 y33 = -7999797217494852664; EXPECT_EQ(y33 & 0, 0); - Aesi512 y34 = 5436292966102924275; EXPECT_EQ(y34 & 0, 0); Aesi512 y35 = 607615924805583424; EXPECT_EQ(y35 & 0, 0); - Aesi512 y36 = 2856731699000776584; EXPECT_EQ(y36 & 0, 0); Aesi512 y37 = -2976940612831152377; EXPECT_EQ(y37 & 0, 0); - Aesi512 y38 = -4552915678136467928; EXPECT_EQ(y38 & 0, 0); Aesi512 y39 = -5371039465969672271; EXPECT_EQ(y39 & 0, 0); - Aesi512 y40 = 1530606965224422562; EXPECT_EQ(y40 & 0, 0); Aesi512 y41 = -995241498352202847; EXPECT_EQ(y41 & 0, 0); - Aesi512 y42 = -1895238691991552268; EXPECT_EQ(y42 & 0, 0); Aesi512 y43 = -2386612473149815406; EXPECT_EQ(y43 & 0, 0); - Aesi512 y44 = -7381958681118134228; EXPECT_EQ(y44 & 0, 0); Aesi512 y45 = 4752526470796438865; EXPECT_EQ(y45 & 0, 0); - Aesi512 y46 = 3193989889132937698; EXPECT_EQ(y46 & 0, 0); Aesi512 y47 = 8118840548867685223; EXPECT_EQ(y47 & 0, 0); - Aesi512 y48 = -1634236269771840043; EXPECT_EQ(y48 & 0, 0); Aesi512 y49 = 5152688280230008107; EXPECT_EQ(y49 & 0, 0); - Aesi512 y50 = 4740142746211585342; EXPECT_EQ(y50 & 0, 0); Aesi512 y51 = 3445462967643173198; EXPECT_EQ(y51 & 0, 0); - Aesi512 y52 = 7794992459357947569; EXPECT_EQ(y52 & 0, 0); Aesi512 y53 = 2683466666324270632; EXPECT_EQ(y53 & 0, 0); - Aesi512 y54 = 531129792006888313; EXPECT_EQ(y54 & 0, 0); Aesi512 y55 = -1866077217373908775; EXPECT_EQ(y55 & 0, 0); - Aesi512 y56 = 6039725184101265805; EXPECT_EQ(y56 & 0, 0); Aesi512 y57 = 2310906701521457706; EXPECT_EQ(y57 & 0, 0); - Aesi512 y58 = 5729261014028876522; EXPECT_EQ(y58 & 0, 0); Aesi512 y59 = -7400848010369953160; EXPECT_EQ(y59 & 0, 0); - -#ifdef NDEBUG - Logging::addRecord("Bitwise_AND", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Bitwise, DifferentPrecisionAND) { - { - Aesi < 352 > first = "47918100704688271616510892901896495939684775967819086025692665489843469630154."; - Aesi < 320 > second = "1246552767469185488369315672782586803099001260876365595544."; - EXPECT_EQ(first & second, "63265630511398538051734786837389409541781770448454812296."); - - Aesi < 416 > third = "-2712851849813795876473894203693216551277095849299267883186805995876570769508."; - Aesi < 256 > forth = "5025966419100860005186510584140202319139378932746821186817."; - third &= forth; EXPECT_EQ(third, "-298887574535333987425999962481295589067152285831190159360."); - } - { - Aesi < 384 > first = "105689775021334539029195604294427772358806783597527347021279626311430725746130."; - Aesi < 320 > second = "-1631521213519025852066033495069405659373463412438537445362."; - EXPECT_EQ(first & second, "1581559343782919440241933793567337675701557326122863599058."); - - Aesi < 352 > third = "19034654236501506123513786949783827171264394879250262350363731658589247763920."; - Aesi < 256 > forth = "-4414172728114580253539739258458339423549599096611792912540."; - third &= forth; EXPECT_EQ(third, "392902908919218238822468993607183072496345732303252652176."); - } - { - Aesi < 384 > first = "-84601016485426487739925962922940945815535545137227910708808420562114153037588."; - Aesi < 192 > second = "-3464688745883777214034285435041296070915645502287961668979."; - EXPECT_EQ(first & second, "-3366605476056886819127484728032187940147031520987705523472."); - - Aesi < 384 > third = "108118680767685688562843398718740146420063556415732209120137282391084644790871."; - Aesi < 288 > forth = "-5529032125927241912301850904493029165794752815639114171854."; - third &= forth; EXPECT_EQ(third, "3933536206295635546627998214098606375213419654447764619334."); - } - { - Aesi < 320 > first = "-67509776649795157188660631535110358750394376915431790825321351771739107527957."; - Aesi < 224 > second = "-2213557262838202074326927147373647149025569000266088879778."; - EXPECT_EQ(first & second, "-2011209461152208123689227222089466985165405348512418792448."); - - Aesi < 384 > third = "65438625985710669262697939685956891818011588441239673117535833347144814626671."; - Aesi < 224 > forth = "3682188877200957459492935829206756325800850357550041510976."; - third &= forth; EXPECT_EQ(third, "3681997250933693682306856878753849700853037708337211966528."); - } - { - Aesi < 384 > first = "-37257822860769724606225738303392242180057489338626540569259345063498606546129."; - Aesi < 192 > second = "-1440529728381926639720985030204862109300160503508639160062."; - EXPECT_EQ(first & second, "-789337352373235078486699373507142888376180361078080799952."); - - Aesi < 448 > third = "-92821781271558589773119897427398601081733781940175193740840686434077912020277."; - Aesi < 288 > forth = "-2676019274780722228107991584349383345440866391990445273155."; - third &= forth; EXPECT_EQ(third, "-1106731633009921877637651851909530365583302839742610747393."); - } - { - Aesi < 352 > first = "-50221359586948519268772494943479422668311690401449706396443758444411087502202."; - Aesi < 320 > second = "3282523773774765745973185086498432584871668212590080799630."; - EXPECT_EQ(first & second, "-98379619957997473845648921270248959460534222091502760714."); - - Aesi < 384 > third = "-98198345264946009435878554953523130237579202734093938844499018012422336900343."; - Aesi < 224 > forth = "416585764281262209084031404546097587034620052703898806171."; - third &= forth; EXPECT_EQ(third, "-413034688714698520435133109171535898435961398649867478163."); - } - { - Aesi < 448 > first = "38542268969937762826851131190776405138594118569845981982694650437595070404120."; - Aesi < 224 > second = "712441078972935800139869505114493064713200842286161734351."; - EXPECT_EQ(first & second, "613779546184717713828956316071533399647873101527272915464."); - - Aesi < 320 > third = "41722077260148894980558097965984980617691903138025686784063041478662126743670."; - Aesi < 288 > forth = "4079548630199993313050097413096753032133548726675113241097."; - third &= forth; EXPECT_EQ(third, "885800796628795282998417618891841484558089015938956042240."); - } - { - Aesi < 416 > first = "45911340345284579518991929572019091752773134460354321078504831685471947114890."; - Aesi < 192 > second = "-1818681171027481454013217559300426296142280285035232124508."; - EXPECT_EQ(first & second, "1815280092925572317511613731494917783534300150274407417864."); - - Aesi < 384 > third = "49473334202021664511587251403196331015570878326964652378559643231216400669114."; - Aesi < 288 > forth = "-75122063562294682864730618937406489749441843544833415362."; - third &= forth; EXPECT_EQ(third, "49067207324660443346820996810044768949864825622794868866."); - } - { - Aesi < 448 > first = "51294030613108634854052804803705843847076166182401598946609448284341465954919."; - Aesi < 320 > second = "-2081723393253515649328037322837460448496015994150341342226."; - EXPECT_EQ(first & second, "1575423562060944917596640935041711348435626106680348258306."); - - Aesi < 320 > third = "-109389735426376347932832859561501325961864971642185139672794339019652576084193."; - Aesi < 192 > forth = "-2351297191690001114275664903136885731371654977550022945526."; - third &= forth; EXPECT_EQ(third, "-1930992330492500772815558885300877416570416527517052829920."); - } - { - Aesi < 384 > first = "-82413493836841549880117956307447858969283724024600198764027186247485603140552."; - Aesi < 224 > second = "1261873714108351833035903180633921464683585059020547679902."; - EXPECT_EQ(first & second, "-844453868921079441815735690587356633135927166878807048840."); - - Aesi < 352 > third = "-21383830021428991813827809231471254738390656126845676422412161555155418639632."; - Aesi < 256 > forth = "378880439662357519929810762300639904269578399243660665210."; - third &= forth; EXPECT_EQ(third, "-347895195011833460416231068086266025464442015733478596880."); - } - { - Aesi < 448 > first = "-79463395220194836053826252472558279914418114963630238448902899027697282197346."; - Aesi < 256 > second = "1216754089330787086607093457501812205489442501126726940270."; - EXPECT_EQ(first & second, "-392797763318188234715994627891179737885814558254388225634."); - - Aesi < 320 > third = "56939419921400168601016848755477578465010247155913845065666025352636236584283."; - Aesi < 320 > forth = "1880848215078270187519762824467884928019848504358400891590."; - third &= forth; EXPECT_EQ(third, "1866968731140226013208588864741620472855610117267191238722."); - } - { - Aesi < 448 > first = "-17849347383402428789475560117571637457045014172071324146450499611055944154885."; - Aesi < 288 > second = "-3852950874685553075143401173095133485864404565889824526514."; - EXPECT_EQ(first & second, "-3337970218208110657612074077013487238735514098785621905408."); - - Aesi < 352 > third = "-89752570023646226700089363826862133905342108835203509706478066121629750091034."; - Aesi < 224 > forth = "-5021025872533538710191027677610890478035487430153760254335."; - third &= forth; EXPECT_EQ(third, "-208480941159676606301757820326543696016271038150746376474."); - } - { - Aesi < 384 > first = "-22323002559781857228837920231933006163622656011698609229845986828760741579970."; - Aesi < 256 > second = "4197650786545086540356432376437493269687484658707542271981."; - EXPECT_EQ(first & second, "-1056034692438801217923341867267318618056619626269955327168."); - - Aesi < 384 > third = "-44674558432232823844747613511413837308621151784209847901477114572513525778077."; - Aesi < 256 > forth = "634932354100174305549250609997329990563136521432970647770."; - third &= forth; EXPECT_EQ(third, "-226905217485744841463151383741998606072412624335315681432."); - } - { - Aesi < 384 > first = "-110002050308947325686560854877496002561424299121388594994176774778361413724661."; - Aesi < 256 > second = "208529564990531101273927871794422799867893262907088597983."; - EXPECT_EQ(first & second, "-12260882562813238136875156499862298602758508996606845397."); - - Aesi < 448 > third = "-95882301126832309625005128705245833917770528683490683056591142284885794301119."; - Aesi < 320 > forth = "-2637066144399550196769988546408691762995900994090263185592."; - third &= forth; EXPECT_EQ(third, "-1815240974118692496516828178944608072700587744693691416760."); - } - { - Aesi < 416 > first = "-37731464298969353133548956105861579521055328378966063741740021521685865871499."; - Aesi < 320 > second = "2507126156020374815996230928137593221549566183483123463792."; - EXPECT_EQ(first & second, "-3363652254855208811452227557051153357170282512331583488."); - - Aesi < 448 > third = "51235953368549643076577927155787255121131602682559303696508116230963853883070."; - Aesi < 224 > forth = "-2757286696776502987271129606230339063954874944288950848494."; - third &= forth; EXPECT_EQ(third, "786361985097117130201858527718902325002528432166668337838."); - } - { - Aesi < 384 > first = "-105892387669655328748297154316416796420554234488429034257526871129446444747278."; - Aesi < 192 > second = "-210594235726726690346662589540488144452174687971154013758."; - EXPECT_EQ(first & second, "-384748003887796250529362353915543702097824438513830414."); - - Aesi < 320 > third = "-107663473678837006180730182357817240541503195620598917979448645866748217912522."; - Aesi < 192 > forth = "1076543692599487298259765300601266136382032443868972546499."; - third &= forth; EXPECT_EQ(third, "-263925953519310168179646696008268755740982729462962677954."); - } - { - Aesi < 384 > first = "-97979719617225906839366739512176258016508169547015918670737810122697032292262."; - Aesi < 224 > second = "-2094526337318026918473758475391214001939393351288679025396."; - EXPECT_EQ(first & second, "-24663623725783116533641412516037038754514355014283248292."); - - Aesi < 320 > third = "-16975463927955372950525781660713754825739423905518055876496789238035500170686."; - Aesi < 256 > forth = "-1776472503085616115741720066674060019716012941753755756970."; - third &= forth; EXPECT_EQ(third, "-199329559296694101193082043691953324223741480444609227178."); - } - { - Aesi < 352 > first = "56981023644176702212904856734018944131943119924454229897128333982206466902619."; - Aesi < 224 > second = "-4987398728872412154555955771781763782522352492979666260819."; - EXPECT_EQ(first & second, "4953250099941140139910983778612727848772957216090471170643."); - - Aesi < 320 > third = "-63106215304914219828892761794328853201275560828619796747820810801403523284859."; - Aesi < 288 > forth = "-5282528241520076464263745941971656685511974093667037923634."; - third &= forth; EXPECT_EQ(third, "-59768098133805154855528146537242129420439767288575723826."); - } - { - Aesi < 416 > first = "-93304861739042168668748785581211856923917794986141155363533136311129188366643."; - Aesi < 288 > second = "-118125677427854462020143501606534917982669770757700043387."; - EXPECT_EQ(first & second, "-110339679451121704481724470079515862731828647856523722803."); - - Aesi < 416 > third = "-74879503734724583837274125050082256621623554050652062268760606352177515366856."; - Aesi < 288 > forth = "4464275899671659153811481946505732472685313017570285581072."; - third &= forth; EXPECT_EQ(third, "-4022916809754901485440490100467899870640989758662608584960."); - } - { - Aesi < 384 > first = "96276672247544313028184126350003821491591180041835675621297822318342179143124."; - Aesi < 320 > second = "-2331796987614690954188238015926374024063789726729470521752."; - EXPECT_EQ(first & second, "1988514923061861252996978413450367729642767110759789113744."); - - Aesi < 448 > third = "-25115953466959048608730398050794310170478098650770723615583944308380113724326."; - Aesi < 256 > forth = "4073867819628966114550082046476785816185418797081467973406."; - third &= forth; EXPECT_EQ(third, "-49052578586223602690389424410365517650694046036747510534."); - } - { - Aesi < 416 > first = "5789711046003643371625812702497167362315689835104734122298893419945047957361."; - Aesi < 192 > second = "-3464428060163340890515439424609412792916378453241656327447."; - EXPECT_EQ(first & second, "25286192870510546249450053573609174837279947419660131601."); - - Aesi < 416 > third = "-76760021751027117829407530215789889573448236392359997436332047310762913504333."; - Aesi < 288 > forth = "-3830319129684490175529452211068034947756070561201510512513."; - third &= forth; EXPECT_EQ(third, "-3664195443549055657725435981887790074822402590824797185."); - } - { - Aesi < 352 > first = "66172201904036700526713848286785598855249544535061337380424854198059455044033."; - Aesi < 192 > second = "-4921123832430635255452260808929699445420271037896726974597."; - EXPECT_EQ(first & second, "1586174059693448327548429964032361675105902795044549824641."); - - Aesi < 448 > third = "37222797790107559627047344626582537389590119155325681151298732702912220506224."; - Aesi < 192 > forth = "-3072721876046445665452010231768230489571207699782240454198."; - third &= forth; EXPECT_EQ(third, "882778253534421622415033413525665415212248939481121423408."); - } - { - Aesi < 352 > first = "-101499263946954621926025869474050270367160146620289011967672455236138736269185."; - Aesi < 224 > second = "2068363414486860101481221438815197642443386900537878609716."; - EXPECT_EQ(first & second, "-393288847234706404925500911979564037195482481643975948032."); - - Aesi < 448 > third = "19789671140157935530422512023086262717333413605127911535384136547842929484176."; - Aesi < 288 > forth = "204213153683526017580965211898914781532828000131466762970."; - third &= forth; EXPECT_EQ(third, "383551576774829127002266402522732230735218139690696848."); - } - { - Aesi < 416 > first = "36033088664716395164666829632668426995528527616231984518249135299245490747022."; - Aesi < 224 > second = "-512445070158205515056046273867124718570766139429308191640."; - EXPECT_EQ(first & second, "3453003781280681553594263995308565749734766513380692616."); - - Aesi < 416 > third = "106154794577112535930634099025913920648267910773172789904350793753369798461517."; - Aesi < 320 > forth = "3758133084626239406320082985953440635800046079598414456045."; - third &= forth; EXPECT_EQ(third, "3537397856444826687894233109523446693238406115289863438413."); - } - { - Aesi < 416 > first = "-68660434717136150433166886871609102662531419246846874219677596658762930468606."; - Aesi < 320 > second = "-2202404425567285315052512373947216183792432841504162792370."; - EXPECT_EQ(first & second, "-424697438097361133285167934520620908609497872165497209522."); - - Aesi < 448 > third = "83717630034623670158946173045053787786765441255214038219775204244647061281856."; - Aesi < 192 > forth = "4827688692558350435323998155882641576814171543070080119999."; - third &= forth; EXPECT_EQ(third, "1673608481375159414424565064202407153580543737890087113728."); - } - { - Aesi < 352 > first = "87089390724780776813131121773195706571278451625955341086322972437307953451284."; - Aesi < 192 > second = "1069530734378560673953868426822431164195931341171270639084."; - EXPECT_EQ(first & second, "37359069284231079140864473669079352437947499827781964036."); - - Aesi < 320 > third = "104969460739188799823877255664656439343641607917594117503105738173097010643497."; - Aesi < 320 > forth = "-4338367399983010197286166012836530283440783904230913759189."; - third &= forth; EXPECT_EQ(third, "1181183752757143641183464639426081015617789214468958339585."); - } - { - Aesi < 448 > first = "75490924465571206915457216258531074118166670874351650793045321631612979756984."; - Aesi < 320 > second = "1591687666104783793792758603763972004513869083433645214844."; - EXPECT_EQ(first & second, "6139714442738671360905803039513296024973548070216502328."); - - Aesi < 320 > third = "-45118910226324835966965797516274421302205341821738945051946685591723858353224."; - Aesi < 192 > forth = "-4529823143340174117859043586754598558383688291967801036379."; - third &= forth; EXPECT_EQ(third, "-788951626562497105232946176752445670076415608615399066696."); - } - { - Aesi < 416 > first = "-27707355879758217522842571717713059278408110584998416481317943900577009671975."; - Aesi < 288 > second = "5253356959755269581532558820339778879947495962367164991581."; - EXPECT_EQ(first & second, "-5104982477806357963631225409258768875283683506365355034629."); - - Aesi < 416 > third = "-65874483377331441743321660903193061110615260418304367117330197036676832896532."; - Aesi < 192 > forth = "-1909222207259960248245653277533820868867225514266672256728."; - third &= forth; EXPECT_EQ(third, "-1869752548762350774517239120297029219594880804876571379216."); - } - { - Aesi < 352 > first = "55211295588562166413959046875763778374239473947246846133256433726169238345827."; - Aesi < 224 > second = "-4528242700886012004098604446011202200089790685914072081739."; - EXPECT_EQ(first & second, "396152812813136951968146082183843591656926905548550307907."); - - Aesi < 448 > third = "3081237158384780676865233056986186531836975543163659693672585781883002133315."; - Aesi < 192 > forth = "-1557583863276090391864226942396892107519359460725791284816."; - third &= forth; EXPECT_EQ(third, "1262934638831282027271836959488821526262935084915278092864."); - } - { - Aesi < 448 > first = "87230983241131468262114743563753199627230365560140627278063059130596461261525."; - Aesi < 288 > second = "6059266373722966892217373368395881121525432217434248566167."; - EXPECT_EQ(first & second, "2110312308652405712612179766794608178441148630381333844117."); - - Aesi < 416 > third = "-55200902786437836100484611784964857287349908321789410306581440320304886575362."; - Aesi < 224 > forth = "3994511592266628589108618082829858954583495766848434018745."; - third &= forth; EXPECT_EQ(third, "-806142076864969233537497721419869690255346664157269922048."); - } - { - Aesi < 416 > first = "-81751953531248694672106227909874904981473044126447633325576372303529417923087."; - Aesi < 224 > second = "5300009780677188802458635130360659580116273785786623866968."; - EXPECT_EQ(first & second, "-5100161625399158139400773231882611681259237309597911095304."); - - Aesi < 352 > third = "-110255999870415664120066103808003375005303461197788115024420314963594281576259."; - Aesi < 256 > forth = "-1281376071911565902610331007994813307834152264211537692919."; - third &= forth; EXPECT_EQ(third, "-790779678010960826580149752320404569099817778312523350083."); - } - { - Aesi < 352 > first = "75240416277633848520383416748999163106923261850528535441562827013689460793351."; - Aesi < 320 > second = "4066240883021209687463892161847847237736326564141594161953."; - EXPECT_EQ(first & second, "3181894753315444530002527182113945211941137488818027896833."); - - Aesi < 416 > third = "76328788700576384388893631895951770259192432100039399699330482105576810537943."; - Aesi < 256 > forth = "-883536891438642056374758468819179063487474794367972133623."; - third &= forth; EXPECT_EQ(third, "785456404834202969542835029110694244187192261467363656407."); - } -} \ No newline at end of file diff --git a/test/bitwise/bitwise_manipulations.cpp b/test/bitwise/bitwise_manipulations.cpp deleted file mode 100644 index 9d165ce..0000000 --- a/test/bitwise/bitwise_manipulations.cpp +++ /dev/null @@ -1,1132 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, GetSetBit) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = "72705387953193747615171521307121358171."; - m0.setBit(126, true); EXPECT_EQ(m0, "157775979683428363481015173165063411035."); - Aesi512 m1 = "245785293645359766049968031280770229918."; - m1.setBit(73, false); EXPECT_EQ(m1, "245785293645359766049968031280770229918."); - Aesi512 m2 = "40858198912689051933487804650601349382."; - m2.setBit(50, true); EXPECT_EQ(m2, "40858198912689051933487804650601349382."); - Aesi512 m3 = "54847862086374059183251323410557990283."; - m3.setBit(121, false); EXPECT_EQ(m3, "54847862086374059183251323410557990283."); - Aesi512 m4 = "110865429160911119237136997258727998569."; - m4.setBit(31, true); EXPECT_EQ(m4, "110865429160911119237136997258727998569."); - Aesi512 m5 = "187782640071050878679583809146823278321."; - m5.setBit(128, true); EXPECT_EQ(m5, "528065006991989342142958416578591489777."); - Aesi512 m6 = "295314379921377398364225673808278353050."; - m6.setBit(15, true); EXPECT_EQ(m6, "295314379921377398364225673808278385818."); - Aesi512 m7 = "3178747094108352161326739593823524879."; - m7.setBit(71, false); EXPECT_EQ(m7, "3178747094108352161326739593823524879."); - Aesi512 m8 = "86494165169548119678449182549238377356."; - m8.setBit(76, true); EXPECT_EQ(m8, "86494165169548119678449182549238377356."); - Aesi512 m9 = "32567167322927313851856437531751981177."; - m9.setBit(40, true); EXPECT_EQ(m9, "32567167322927313851856437531751981177."); - Aesi512 m10 = "172530118786257976509377267953319712204."; - m10.setBit(20, true); EXPECT_EQ(m10, "172530118786257976509377267953319712204."); - Aesi512 m11 = "172559365867210208688264944029949150686."; - m11.setBit(99, true); EXPECT_EQ(m11, "172559365867210208688264944029949150686."); - Aesi512 m12 = "78529106901055941434084997135871639427."; - m12.setBit(10, true); EXPECT_EQ(m12, "78529106901055941434084997135871639427."); - Aesi512 m13 = "207303494278178530702609902345571888268."; - m13.setBit(69, true); EXPECT_EQ(m13, "207303494278178530702609902345571888268."); - Aesi512 m14 = "75647073125004035230985916463405072523."; - m14.setBit(3, false); EXPECT_EQ(m14, "75647073125004035230985916463405072515."); - Aesi512 m15 = "222723315237755082168376048193872639645."; - m15.setBit(107, true); EXPECT_EQ(m15, "222723477497031911381739439771882927773."); - Aesi512 m16 = "193675621579885645481372969626118961567."; - m16.setBit(33, false); EXPECT_EQ(m16, "193675621579885645481372969617529026975."); - Aesi512 m17 = "184830840876535640520166369784004708864."; - m17.setBit(94, true); EXPECT_EQ(m17, "184830840896342681148732454182390696448."); - Aesi512 m18 = "184781425874546653782780922198149710463."; - m18.setBit(123, true); EXPECT_EQ(m18, "184781425874546653782780922198149710463."); - Aesi512 m19 = "143111532682479361522938570020545208955."; - m19.setBit(47, false); EXPECT_EQ(m19, "143111532682479361522938429283056853627."); - Aesi512 m20 = "271575289760478049691481842232695651446."; - m20.setBit(11, false); EXPECT_EQ(m20, "271575289760478049691481842232695649398."); - Aesi512 m21 = "187912626417229430413829117802893310299."; - m21.setBit(68, false); EXPECT_EQ(m21, "187912626417229430413829117802893310299."); - Aesi512 m22 = "158932010648066253535888104656448665002."; - m22.setBit(79, true); EXPECT_EQ(m22, "158932010648066253535888104656448665002."); - Aesi512 m23 = "109487819811077581867635815837691548334."; - m23.setBit(113, true); EXPECT_EQ(m23, "109487819811077581867635815837691548334."); - Aesi512 m24 = "47379343172205350263905530302298557228."; - m24.setBit(61, false); EXPECT_EQ(m24, "47379343172205350263905530302298557228."); - Aesi512 m25 = "158911198835109948520770291433578090947."; - m25.setBit(50, false); EXPECT_EQ(m25, "158911198835109948520770291433578090947."); - Aesi512 m26 = "248326728370153648748027863303163864728."; - m26.setBit(91, false); EXPECT_EQ(m26, "248326728367677768669457102753365616280."); - Aesi512 m27 = "176392199758157475536173991226043128119."; - m27.setBit(42, true); EXPECT_EQ(m27, "176392199758157475536173991226043128119."); - Aesi512 m28 = "238588105982679173784425043462049184726."; - m28.setBit(105, false); EXPECT_EQ(m28, "238588105982679173784425043462049184726."); - Aesi512 m29 = "150346354478535467451721603451021909402."; - m29.setBit(107, true); EXPECT_EQ(m29, "150346516737812296665084995029032197530."); - Aesi512 m30 = "273819485712316995631595319491380561223."; - m30.setBit(114, false); EXPECT_EQ(m30, "273798716524882856321081197506063680839."); - Aesi512 m31 = "9465809177493504473582186962123883962."; - m31.setBit(52, false); EXPECT_EQ(m31, "9465809177493504473582186962123883962."); - Aesi512 m32 = "328749017563933875762256624294091022769."; - m32.setBit(82, false); EXPECT_EQ(m32, "328749017563929040058978165777392198065."); - Aesi512 m33 = "187349705948370703926994252284122213259."; - m33.setBit(21, false); EXPECT_EQ(m33, "187349705948370703926994252284122213259."); - Aesi512 m34 = "95199700526301209891562846305547693713."; - m34.setBit(46, false); EXPECT_EQ(m34, "95199700526301209891562846305547693713."); - Aesi512 m35 = "103655044468308507172810437786291934566."; - m35.setBit(51, true); EXPECT_EQ(m35, "103655044468308507172810437786291934566."); - Aesi512 m36 = "62548752160102009726032985107282388037."; - m36.setBit(71, true); EXPECT_EQ(m36, "62548752160102009726032985107282388037."); - Aesi512 m37 = "114713660827724670972157050548957340052."; - m37.setBit(82, true); EXPECT_EQ(m37, "114713660827724670972157050548957340052."); - Aesi512 m38 = "298233052050341589489614113949082900217."; - m38.setBit(77, false); EXPECT_EQ(m38, "298233052050341589489614113949082900217."); - Aesi512 m39 = "244677446963714695792063603125629139705."; - m39.setBit(52, true); EXPECT_EQ(m39, "244677446963714695792063603125629139705."); - Aesi512 u0 = "183266889657794562429184270028014133994."; - EXPECT_EQ(u0.getBit(0), false); - EXPECT_EQ(u0.getBit(1), true); EXPECT_EQ(u0.getBit(2), false); EXPECT_EQ(u0.getBit(3), true); EXPECT_EQ(u0.getBit(4), false); EXPECT_EQ(u0.getBit(5), true); EXPECT_EQ(u0.getBit(6), true); EXPECT_EQ(u0.getBit(7), true); EXPECT_EQ(u0.getBit(8), false); EXPECT_EQ(u0.getBit(9), true); - EXPECT_EQ(u0.getBit(10), false); EXPECT_EQ(u0.getBit(11), false); EXPECT_EQ(u0.getBit(12), false); EXPECT_EQ(u0.getBit(13), true); EXPECT_EQ(u0.getBit(14), false); EXPECT_EQ(u0.getBit(15), true); EXPECT_EQ(u0.getBit(16), false); EXPECT_EQ(u0.getBit(17), false); EXPECT_EQ(u0.getBit(18), true); - EXPECT_EQ(u0.getBit(19), true); EXPECT_EQ(u0.getBit(20), true); EXPECT_EQ(u0.getBit(21), false); EXPECT_EQ(u0.getBit(22), true); EXPECT_EQ(u0.getBit(23), false); EXPECT_EQ(u0.getBit(24), false); EXPECT_EQ(u0.getBit(25), true); EXPECT_EQ(u0.getBit(26), false); EXPECT_EQ(u0.getBit(27), true); - EXPECT_EQ(u0.getBit(28), true); EXPECT_EQ(u0.getBit(29), true); EXPECT_EQ(u0.getBit(30), true); EXPECT_EQ(u0.getBit(31), false); EXPECT_EQ(u0.getBit(32), false); EXPECT_EQ(u0.getBit(33), false); EXPECT_EQ(u0.getBit(34), false); EXPECT_EQ(u0.getBit(35), false); EXPECT_EQ(u0.getBit(36), true); - EXPECT_EQ(u0.getBit(37), true); EXPECT_EQ(u0.getBit(38), false); EXPECT_EQ(u0.getBit(39), true); EXPECT_EQ(u0.getBit(40), false); EXPECT_EQ(u0.getBit(41), false); EXPECT_EQ(u0.getBit(42), true); EXPECT_EQ(u0.getBit(43), false); EXPECT_EQ(u0.getBit(44), false); EXPECT_EQ(u0.getBit(45), false); - EXPECT_EQ(u0.getBit(46), false); EXPECT_EQ(u0.getBit(47), true); EXPECT_EQ(u0.getBit(48), false); EXPECT_EQ(u0.getBit(49), true); EXPECT_EQ(u0.getBit(50), true); EXPECT_EQ(u0.getBit(51), false); EXPECT_EQ(u0.getBit(52), false); EXPECT_EQ(u0.getBit(53), true); EXPECT_EQ(u0.getBit(54), true); - EXPECT_EQ(u0.getBit(55), false); EXPECT_EQ(u0.getBit(56), false); EXPECT_EQ(u0.getBit(57), true); EXPECT_EQ(u0.getBit(58), true); EXPECT_EQ(u0.getBit(59), true); EXPECT_EQ(u0.getBit(60), false); EXPECT_EQ(u0.getBit(61), false); EXPECT_EQ(u0.getBit(62), false); EXPECT_EQ(u0.getBit(63), true); - EXPECT_EQ(u0.getBit(64), false); EXPECT_EQ(u0.getBit(65), true); EXPECT_EQ(u0.getBit(66), false); EXPECT_EQ(u0.getBit(67), true); EXPECT_EQ(u0.getBit(68), true); EXPECT_EQ(u0.getBit(69), true); EXPECT_EQ(u0.getBit(70), true); EXPECT_EQ(u0.getBit(71), false); EXPECT_EQ(u0.getBit(72), true); - EXPECT_EQ(u0.getBit(73), true); EXPECT_EQ(u0.getBit(74), false); EXPECT_EQ(u0.getBit(75), false); EXPECT_EQ(u0.getBit(76), false); EXPECT_EQ(u0.getBit(77), true); EXPECT_EQ(u0.getBit(78), false); EXPECT_EQ(u0.getBit(79), true); EXPECT_EQ(u0.getBit(80), false); EXPECT_EQ(u0.getBit(81), true); - EXPECT_EQ(u0.getBit(82), true); EXPECT_EQ(u0.getBit(83), true); EXPECT_EQ(u0.getBit(84), false); EXPECT_EQ(u0.getBit(85), false); EXPECT_EQ(u0.getBit(86), true); EXPECT_EQ(u0.getBit(87), false); EXPECT_EQ(u0.getBit(88), true); EXPECT_EQ(u0.getBit(89), true); EXPECT_EQ(u0.getBit(90), true); - EXPECT_EQ(u0.getBit(91), true); EXPECT_EQ(u0.getBit(92), false); EXPECT_EQ(u0.getBit(93), false); EXPECT_EQ(u0.getBit(94), false); EXPECT_EQ(u0.getBit(95), true); EXPECT_EQ(u0.getBit(96), true); EXPECT_EQ(u0.getBit(97), true); EXPECT_EQ(u0.getBit(98), true); EXPECT_EQ(u0.getBit(99), false); - EXPECT_EQ(u0.getBit(100), false); EXPECT_EQ(u0.getBit(101), false); EXPECT_EQ(u0.getBit(102), true); EXPECT_EQ(u0.getBit(103), false); EXPECT_EQ(u0.getBit(104), true); EXPECT_EQ(u0.getBit(105), true); EXPECT_EQ(u0.getBit(106), false); EXPECT_EQ(u0.getBit(107), true); EXPECT_EQ(u0.getBit(108), false); - EXPECT_EQ(u0.getBit(109), true); EXPECT_EQ(u0.getBit(110), true); EXPECT_EQ(u0.getBit(111), true); EXPECT_EQ(u0.getBit(112), true); EXPECT_EQ(u0.getBit(113), true); EXPECT_EQ(u0.getBit(114), true); EXPECT_EQ(u0.getBit(115), true); EXPECT_EQ(u0.getBit(116), true); EXPECT_EQ(u0.getBit(117), false); - EXPECT_EQ(u0.getBit(118), true); EXPECT_EQ(u0.getBit(119), true); EXPECT_EQ(u0.getBit(120), true); EXPECT_EQ(u0.getBit(121), false); EXPECT_EQ(u0.getBit(122), false); EXPECT_EQ(u0.getBit(123), true); EXPECT_EQ(u0.getBit(124), false); EXPECT_EQ(u0.getBit(125), false); EXPECT_EQ(u0.getBit(126), false); - EXPECT_EQ(u0.getBit(127), true); - - Aesi512 u1 = "28532736677951985108511975536651973171."; - EXPECT_EQ(u1.getBit(0), true); - EXPECT_EQ(u1.getBit(1), true); EXPECT_EQ(u1.getBit(2), false); EXPECT_EQ(u1.getBit(3), false); EXPECT_EQ(u1.getBit(4), true); EXPECT_EQ(u1.getBit(5), true); EXPECT_EQ(u1.getBit(6), false); EXPECT_EQ(u1.getBit(7), false); EXPECT_EQ(u1.getBit(8), false); EXPECT_EQ(u1.getBit(9), true); - EXPECT_EQ(u1.getBit(10), false); EXPECT_EQ(u1.getBit(11), false); EXPECT_EQ(u1.getBit(12), true); EXPECT_EQ(u1.getBit(13), true); EXPECT_EQ(u1.getBit(14), false); EXPECT_EQ(u1.getBit(15), true); EXPECT_EQ(u1.getBit(16), false); EXPECT_EQ(u1.getBit(17), false); EXPECT_EQ(u1.getBit(18), true); - EXPECT_EQ(u1.getBit(19), false); EXPECT_EQ(u1.getBit(20), false); EXPECT_EQ(u1.getBit(21), true); EXPECT_EQ(u1.getBit(22), false); EXPECT_EQ(u1.getBit(23), true); EXPECT_EQ(u1.getBit(24), false); EXPECT_EQ(u1.getBit(25), true); EXPECT_EQ(u1.getBit(26), true); EXPECT_EQ(u1.getBit(27), true); - EXPECT_EQ(u1.getBit(28), false); EXPECT_EQ(u1.getBit(29), false); EXPECT_EQ(u1.getBit(30), false); EXPECT_EQ(u1.getBit(31), true); EXPECT_EQ(u1.getBit(32), false); EXPECT_EQ(u1.getBit(33), false); EXPECT_EQ(u1.getBit(34), true); EXPECT_EQ(u1.getBit(35), true); EXPECT_EQ(u1.getBit(36), true); - EXPECT_EQ(u1.getBit(37), true); EXPECT_EQ(u1.getBit(38), true); EXPECT_EQ(u1.getBit(39), true); EXPECT_EQ(u1.getBit(40), false); EXPECT_EQ(u1.getBit(41), false); EXPECT_EQ(u1.getBit(42), false); EXPECT_EQ(u1.getBit(43), true); EXPECT_EQ(u1.getBit(44), true); EXPECT_EQ(u1.getBit(45), false); - EXPECT_EQ(u1.getBit(46), false); EXPECT_EQ(u1.getBit(47), true); EXPECT_EQ(u1.getBit(48), false); EXPECT_EQ(u1.getBit(49), true); EXPECT_EQ(u1.getBit(50), true); EXPECT_EQ(u1.getBit(51), false); EXPECT_EQ(u1.getBit(52), false); EXPECT_EQ(u1.getBit(53), false); EXPECT_EQ(u1.getBit(54), true); - EXPECT_EQ(u1.getBit(55), true); EXPECT_EQ(u1.getBit(56), false); EXPECT_EQ(u1.getBit(57), false); EXPECT_EQ(u1.getBit(58), true); EXPECT_EQ(u1.getBit(59), false); EXPECT_EQ(u1.getBit(60), false); EXPECT_EQ(u1.getBit(61), true); EXPECT_EQ(u1.getBit(62), true); EXPECT_EQ(u1.getBit(63), true); - EXPECT_EQ(u1.getBit(64), false); EXPECT_EQ(u1.getBit(65), true); EXPECT_EQ(u1.getBit(66), true); EXPECT_EQ(u1.getBit(67), true); EXPECT_EQ(u1.getBit(68), true); EXPECT_EQ(u1.getBit(69), false); EXPECT_EQ(u1.getBit(70), false); EXPECT_EQ(u1.getBit(71), false); EXPECT_EQ(u1.getBit(72), false); - EXPECT_EQ(u1.getBit(73), false); EXPECT_EQ(u1.getBit(74), false); EXPECT_EQ(u1.getBit(75), false); EXPECT_EQ(u1.getBit(76), true); EXPECT_EQ(u1.getBit(77), false); EXPECT_EQ(u1.getBit(78), false); EXPECT_EQ(u1.getBit(79), true); EXPECT_EQ(u1.getBit(80), false); EXPECT_EQ(u1.getBit(81), true); - EXPECT_EQ(u1.getBit(82), false); EXPECT_EQ(u1.getBit(83), true); EXPECT_EQ(u1.getBit(84), false); EXPECT_EQ(u1.getBit(85), false); EXPECT_EQ(u1.getBit(86), true); EXPECT_EQ(u1.getBit(87), false); EXPECT_EQ(u1.getBit(88), true); EXPECT_EQ(u1.getBit(89), true); EXPECT_EQ(u1.getBit(90), true); - EXPECT_EQ(u1.getBit(91), true); EXPECT_EQ(u1.getBit(92), true); EXPECT_EQ(u1.getBit(93), true); EXPECT_EQ(u1.getBit(94), false); EXPECT_EQ(u1.getBit(95), true); EXPECT_EQ(u1.getBit(96), true); EXPECT_EQ(u1.getBit(97), true); EXPECT_EQ(u1.getBit(98), true); EXPECT_EQ(u1.getBit(99), false); - EXPECT_EQ(u1.getBit(100), false); EXPECT_EQ(u1.getBit(101), false); EXPECT_EQ(u1.getBit(102), false); EXPECT_EQ(u1.getBit(103), true); EXPECT_EQ(u1.getBit(104), false); EXPECT_EQ(u1.getBit(105), false); EXPECT_EQ(u1.getBit(106), true); EXPECT_EQ(u1.getBit(107), false); EXPECT_EQ(u1.getBit(108), true); - EXPECT_EQ(u1.getBit(109), true); EXPECT_EQ(u1.getBit(110), false); EXPECT_EQ(u1.getBit(111), false); EXPECT_EQ(u1.getBit(112), true); EXPECT_EQ(u1.getBit(113), true); EXPECT_EQ(u1.getBit(114), true); EXPECT_EQ(u1.getBit(115), false); EXPECT_EQ(u1.getBit(116), true); EXPECT_EQ(u1.getBit(117), true); - EXPECT_EQ(u1.getBit(118), true); EXPECT_EQ(u1.getBit(119), false); EXPECT_EQ(u1.getBit(120), true); EXPECT_EQ(u1.getBit(121), false); EXPECT_EQ(u1.getBit(122), true); EXPECT_EQ(u1.getBit(123), false); EXPECT_EQ(u1.getBit(124), true); - - Aesi512 u2 = "202963489620510457840756855970746955719."; - EXPECT_EQ(u2.getBit(0), true); - EXPECT_EQ(u2.getBit(1), true); EXPECT_EQ(u2.getBit(2), true); EXPECT_EQ(u2.getBit(3), false); EXPECT_EQ(u2.getBit(4), false); EXPECT_EQ(u2.getBit(5), false); EXPECT_EQ(u2.getBit(6), true); EXPECT_EQ(u2.getBit(7), true); EXPECT_EQ(u2.getBit(8), true); EXPECT_EQ(u2.getBit(9), true); - EXPECT_EQ(u2.getBit(10), true); EXPECT_EQ(u2.getBit(11), false); EXPECT_EQ(u2.getBit(12), true); EXPECT_EQ(u2.getBit(13), true); EXPECT_EQ(u2.getBit(14), true); EXPECT_EQ(u2.getBit(15), false); EXPECT_EQ(u2.getBit(16), true); EXPECT_EQ(u2.getBit(17), false); EXPECT_EQ(u2.getBit(18), false); - EXPECT_EQ(u2.getBit(19), false); EXPECT_EQ(u2.getBit(20), false); EXPECT_EQ(u2.getBit(21), false); EXPECT_EQ(u2.getBit(22), true); EXPECT_EQ(u2.getBit(23), false); EXPECT_EQ(u2.getBit(24), false); EXPECT_EQ(u2.getBit(25), false); EXPECT_EQ(u2.getBit(26), true); EXPECT_EQ(u2.getBit(27), true); - EXPECT_EQ(u2.getBit(28), true); EXPECT_EQ(u2.getBit(29), false); EXPECT_EQ(u2.getBit(30), true); EXPECT_EQ(u2.getBit(31), false); EXPECT_EQ(u2.getBit(32), true); EXPECT_EQ(u2.getBit(33), false); EXPECT_EQ(u2.getBit(34), false); EXPECT_EQ(u2.getBit(35), false); EXPECT_EQ(u2.getBit(36), true); - EXPECT_EQ(u2.getBit(37), false); EXPECT_EQ(u2.getBit(38), true); EXPECT_EQ(u2.getBit(39), true); EXPECT_EQ(u2.getBit(40), false); EXPECT_EQ(u2.getBit(41), true); EXPECT_EQ(u2.getBit(42), false); EXPECT_EQ(u2.getBit(43), true); EXPECT_EQ(u2.getBit(44), true); EXPECT_EQ(u2.getBit(45), false); - EXPECT_EQ(u2.getBit(46), true); EXPECT_EQ(u2.getBit(47), true); EXPECT_EQ(u2.getBit(48), true); EXPECT_EQ(u2.getBit(49), false); EXPECT_EQ(u2.getBit(50), false); EXPECT_EQ(u2.getBit(51), false); EXPECT_EQ(u2.getBit(52), true); EXPECT_EQ(u2.getBit(53), true); EXPECT_EQ(u2.getBit(54), false); - EXPECT_EQ(u2.getBit(55), false); EXPECT_EQ(u2.getBit(56), false); EXPECT_EQ(u2.getBit(57), true); EXPECT_EQ(u2.getBit(58), false); EXPECT_EQ(u2.getBit(59), true); EXPECT_EQ(u2.getBit(60), true); EXPECT_EQ(u2.getBit(61), false); EXPECT_EQ(u2.getBit(62), false); EXPECT_EQ(u2.getBit(63), true); - EXPECT_EQ(u2.getBit(64), false); EXPECT_EQ(u2.getBit(65), true); EXPECT_EQ(u2.getBit(66), true); EXPECT_EQ(u2.getBit(67), true); EXPECT_EQ(u2.getBit(68), true); EXPECT_EQ(u2.getBit(69), true); EXPECT_EQ(u2.getBit(70), false); EXPECT_EQ(u2.getBit(71), false); EXPECT_EQ(u2.getBit(72), false); - EXPECT_EQ(u2.getBit(73), true); EXPECT_EQ(u2.getBit(74), false); EXPECT_EQ(u2.getBit(75), true); EXPECT_EQ(u2.getBit(76), false); EXPECT_EQ(u2.getBit(77), true); EXPECT_EQ(u2.getBit(78), true); EXPECT_EQ(u2.getBit(79), true); EXPECT_EQ(u2.getBit(80), true); EXPECT_EQ(u2.getBit(81), false); - EXPECT_EQ(u2.getBit(82), false); EXPECT_EQ(u2.getBit(83), false); EXPECT_EQ(u2.getBit(84), true); EXPECT_EQ(u2.getBit(85), true); EXPECT_EQ(u2.getBit(86), false); EXPECT_EQ(u2.getBit(87), true); EXPECT_EQ(u2.getBit(88), true); EXPECT_EQ(u2.getBit(89), false); EXPECT_EQ(u2.getBit(90), false); - EXPECT_EQ(u2.getBit(91), false); EXPECT_EQ(u2.getBit(92), false); EXPECT_EQ(u2.getBit(93), true); EXPECT_EQ(u2.getBit(94), true); EXPECT_EQ(u2.getBit(95), false); EXPECT_EQ(u2.getBit(96), false); EXPECT_EQ(u2.getBit(97), true); EXPECT_EQ(u2.getBit(98), false); EXPECT_EQ(u2.getBit(99), false); - EXPECT_EQ(u2.getBit(100), false); EXPECT_EQ(u2.getBit(101), true); EXPECT_EQ(u2.getBit(102), false); EXPECT_EQ(u2.getBit(103), true); EXPECT_EQ(u2.getBit(104), false); EXPECT_EQ(u2.getBit(105), false); EXPECT_EQ(u2.getBit(106), false); EXPECT_EQ(u2.getBit(107), true); EXPECT_EQ(u2.getBit(108), true); - EXPECT_EQ(u2.getBit(109), false); EXPECT_EQ(u2.getBit(110), true); EXPECT_EQ(u2.getBit(111), false); EXPECT_EQ(u2.getBit(112), true); EXPECT_EQ(u2.getBit(113), false); EXPECT_EQ(u2.getBit(114), false); EXPECT_EQ(u2.getBit(115), false); EXPECT_EQ(u2.getBit(116), true); EXPECT_EQ(u2.getBit(117), true); - EXPECT_EQ(u2.getBit(118), false); EXPECT_EQ(u2.getBit(119), true); EXPECT_EQ(u2.getBit(120), false); EXPECT_EQ(u2.getBit(121), false); EXPECT_EQ(u2.getBit(122), false); EXPECT_EQ(u2.getBit(123), true); EXPECT_EQ(u2.getBit(124), true); EXPECT_EQ(u2.getBit(125), false); EXPECT_EQ(u2.getBit(126), false); - EXPECT_EQ(u2.getBit(127), true); - - Aesi512 u3 = "99039543241645718481744753772010007488."; - EXPECT_EQ(u3.getBit(0), false); - EXPECT_EQ(u3.getBit(1), false); EXPECT_EQ(u3.getBit(2), false); EXPECT_EQ(u3.getBit(3), false); EXPECT_EQ(u3.getBit(4), false); EXPECT_EQ(u3.getBit(5), false); EXPECT_EQ(u3.getBit(6), true); EXPECT_EQ(u3.getBit(7), true); EXPECT_EQ(u3.getBit(8), true); EXPECT_EQ(u3.getBit(9), true); - EXPECT_EQ(u3.getBit(10), false); EXPECT_EQ(u3.getBit(11), true); EXPECT_EQ(u3.getBit(12), false); EXPECT_EQ(u3.getBit(13), true); EXPECT_EQ(u3.getBit(14), true); EXPECT_EQ(u3.getBit(15), true); EXPECT_EQ(u3.getBit(16), true); EXPECT_EQ(u3.getBit(17), false); EXPECT_EQ(u3.getBit(18), true); - EXPECT_EQ(u3.getBit(19), true); EXPECT_EQ(u3.getBit(20), false); EXPECT_EQ(u3.getBit(21), true); EXPECT_EQ(u3.getBit(22), true); EXPECT_EQ(u3.getBit(23), false); EXPECT_EQ(u3.getBit(24), false); EXPECT_EQ(u3.getBit(25), true); EXPECT_EQ(u3.getBit(26), true); EXPECT_EQ(u3.getBit(27), true); - EXPECT_EQ(u3.getBit(28), false); EXPECT_EQ(u3.getBit(29), false); EXPECT_EQ(u3.getBit(30), true); EXPECT_EQ(u3.getBit(31), true); EXPECT_EQ(u3.getBit(32), false); EXPECT_EQ(u3.getBit(33), false); EXPECT_EQ(u3.getBit(34), false); EXPECT_EQ(u3.getBit(35), false); EXPECT_EQ(u3.getBit(36), false); - EXPECT_EQ(u3.getBit(37), false); EXPECT_EQ(u3.getBit(38), true); EXPECT_EQ(u3.getBit(39), true); EXPECT_EQ(u3.getBit(40), true); EXPECT_EQ(u3.getBit(41), true); EXPECT_EQ(u3.getBit(42), true); EXPECT_EQ(u3.getBit(43), true); EXPECT_EQ(u3.getBit(44), true); EXPECT_EQ(u3.getBit(45), false); - EXPECT_EQ(u3.getBit(46), false); EXPECT_EQ(u3.getBit(47), true); EXPECT_EQ(u3.getBit(48), true); EXPECT_EQ(u3.getBit(49), false); EXPECT_EQ(u3.getBit(50), true); EXPECT_EQ(u3.getBit(51), true); EXPECT_EQ(u3.getBit(52), true); EXPECT_EQ(u3.getBit(53), true); EXPECT_EQ(u3.getBit(54), false); - EXPECT_EQ(u3.getBit(55), false); EXPECT_EQ(u3.getBit(56), false); EXPECT_EQ(u3.getBit(57), true); EXPECT_EQ(u3.getBit(58), false); EXPECT_EQ(u3.getBit(59), true); EXPECT_EQ(u3.getBit(60), false); EXPECT_EQ(u3.getBit(61), true); EXPECT_EQ(u3.getBit(62), true); EXPECT_EQ(u3.getBit(63), true); - EXPECT_EQ(u3.getBit(64), false); EXPECT_EQ(u3.getBit(65), true); EXPECT_EQ(u3.getBit(66), true); EXPECT_EQ(u3.getBit(67), true); EXPECT_EQ(u3.getBit(68), true); EXPECT_EQ(u3.getBit(69), false); EXPECT_EQ(u3.getBit(70), true); EXPECT_EQ(u3.getBit(71), true); EXPECT_EQ(u3.getBit(72), true); - EXPECT_EQ(u3.getBit(73), true); EXPECT_EQ(u3.getBit(74), false); EXPECT_EQ(u3.getBit(75), false); EXPECT_EQ(u3.getBit(76), true); EXPECT_EQ(u3.getBit(77), false); EXPECT_EQ(u3.getBit(78), false); EXPECT_EQ(u3.getBit(79), true); EXPECT_EQ(u3.getBit(80), false); EXPECT_EQ(u3.getBit(81), false); - EXPECT_EQ(u3.getBit(82), true); EXPECT_EQ(u3.getBit(83), true); EXPECT_EQ(u3.getBit(84), true); EXPECT_EQ(u3.getBit(85), false); EXPECT_EQ(u3.getBit(86), false); EXPECT_EQ(u3.getBit(87), true); EXPECT_EQ(u3.getBit(88), true); EXPECT_EQ(u3.getBit(89), true); EXPECT_EQ(u3.getBit(90), true); - EXPECT_EQ(u3.getBit(91), true); EXPECT_EQ(u3.getBit(92), true); EXPECT_EQ(u3.getBit(93), true); EXPECT_EQ(u3.getBit(94), false); EXPECT_EQ(u3.getBit(95), true); EXPECT_EQ(u3.getBit(96), true); EXPECT_EQ(u3.getBit(97), true); EXPECT_EQ(u3.getBit(98), false); EXPECT_EQ(u3.getBit(99), true); - EXPECT_EQ(u3.getBit(100), true); EXPECT_EQ(u3.getBit(101), true); EXPECT_EQ(u3.getBit(102), true); EXPECT_EQ(u3.getBit(103), false); EXPECT_EQ(u3.getBit(104), false); EXPECT_EQ(u3.getBit(105), true); EXPECT_EQ(u3.getBit(106), false); EXPECT_EQ(u3.getBit(107), false); EXPECT_EQ(u3.getBit(108), true); - EXPECT_EQ(u3.getBit(109), false); EXPECT_EQ(u3.getBit(110), true); EXPECT_EQ(u3.getBit(111), false); EXPECT_EQ(u3.getBit(112), false); EXPECT_EQ(u3.getBit(113), true); EXPECT_EQ(u3.getBit(114), false); EXPECT_EQ(u3.getBit(115), false); EXPECT_EQ(u3.getBit(116), false); EXPECT_EQ(u3.getBit(117), false); - EXPECT_EQ(u3.getBit(118), false); EXPECT_EQ(u3.getBit(119), true); EXPECT_EQ(u3.getBit(120), false); EXPECT_EQ(u3.getBit(121), true); EXPECT_EQ(u3.getBit(122), false); EXPECT_EQ(u3.getBit(123), true); EXPECT_EQ(u3.getBit(124), false); EXPECT_EQ(u3.getBit(125), false); EXPECT_EQ(u3.getBit(126), true); - - - Aesi512 u4 = "185521423754314153400893953240556219688."; - EXPECT_EQ(u4.getBit(0), false); - EXPECT_EQ(u4.getBit(1), false); EXPECT_EQ(u4.getBit(2), false); EXPECT_EQ(u4.getBit(3), true); EXPECT_EQ(u4.getBit(4), false); EXPECT_EQ(u4.getBit(5), true); EXPECT_EQ(u4.getBit(6), false); EXPECT_EQ(u4.getBit(7), false); EXPECT_EQ(u4.getBit(8), true); EXPECT_EQ(u4.getBit(9), false); - EXPECT_EQ(u4.getBit(10), true); EXPECT_EQ(u4.getBit(11), true); EXPECT_EQ(u4.getBit(12), false); EXPECT_EQ(u4.getBit(13), true); EXPECT_EQ(u4.getBit(14), false); EXPECT_EQ(u4.getBit(15), true); EXPECT_EQ(u4.getBit(16), true); EXPECT_EQ(u4.getBit(17), false); EXPECT_EQ(u4.getBit(18), false); - EXPECT_EQ(u4.getBit(19), true); EXPECT_EQ(u4.getBit(20), false); EXPECT_EQ(u4.getBit(21), false); EXPECT_EQ(u4.getBit(22), false); EXPECT_EQ(u4.getBit(23), false); EXPECT_EQ(u4.getBit(24), true); EXPECT_EQ(u4.getBit(25), false); EXPECT_EQ(u4.getBit(26), false); EXPECT_EQ(u4.getBit(27), true); - EXPECT_EQ(u4.getBit(28), false); EXPECT_EQ(u4.getBit(29), false); EXPECT_EQ(u4.getBit(30), false); EXPECT_EQ(u4.getBit(31), true); EXPECT_EQ(u4.getBit(32), false); EXPECT_EQ(u4.getBit(33), false); EXPECT_EQ(u4.getBit(34), false); EXPECT_EQ(u4.getBit(35), true); EXPECT_EQ(u4.getBit(36), false); - EXPECT_EQ(u4.getBit(37), false); EXPECT_EQ(u4.getBit(38), false); EXPECT_EQ(u4.getBit(39), true); EXPECT_EQ(u4.getBit(40), false); EXPECT_EQ(u4.getBit(41), false); EXPECT_EQ(u4.getBit(42), false); EXPECT_EQ(u4.getBit(43), false); EXPECT_EQ(u4.getBit(44), true); EXPECT_EQ(u4.getBit(45), true); - EXPECT_EQ(u4.getBit(46), false); EXPECT_EQ(u4.getBit(47), true); EXPECT_EQ(u4.getBit(48), false); EXPECT_EQ(u4.getBit(49), false); EXPECT_EQ(u4.getBit(50), true); EXPECT_EQ(u4.getBit(51), true); EXPECT_EQ(u4.getBit(52), false); EXPECT_EQ(u4.getBit(53), true); EXPECT_EQ(u4.getBit(54), false); - EXPECT_EQ(u4.getBit(55), false); EXPECT_EQ(u4.getBit(56), true); EXPECT_EQ(u4.getBit(57), true); EXPECT_EQ(u4.getBit(58), true); EXPECT_EQ(u4.getBit(59), true); EXPECT_EQ(u4.getBit(60), false); EXPECT_EQ(u4.getBit(61), true); EXPECT_EQ(u4.getBit(62), false); EXPECT_EQ(u4.getBit(63), false); - EXPECT_EQ(u4.getBit(64), false); EXPECT_EQ(u4.getBit(65), true); EXPECT_EQ(u4.getBit(66), false); EXPECT_EQ(u4.getBit(67), false); EXPECT_EQ(u4.getBit(68), true); EXPECT_EQ(u4.getBit(69), false); EXPECT_EQ(u4.getBit(70), false); EXPECT_EQ(u4.getBit(71), true); EXPECT_EQ(u4.getBit(72), false); - EXPECT_EQ(u4.getBit(73), true); EXPECT_EQ(u4.getBit(74), true); EXPECT_EQ(u4.getBit(75), false); EXPECT_EQ(u4.getBit(76), false); EXPECT_EQ(u4.getBit(77), true); EXPECT_EQ(u4.getBit(78), true); EXPECT_EQ(u4.getBit(79), false); EXPECT_EQ(u4.getBit(80), true); EXPECT_EQ(u4.getBit(81), true); - EXPECT_EQ(u4.getBit(82), false); EXPECT_EQ(u4.getBit(83), false); EXPECT_EQ(u4.getBit(84), true); EXPECT_EQ(u4.getBit(85), false); EXPECT_EQ(u4.getBit(86), true); EXPECT_EQ(u4.getBit(87), true); EXPECT_EQ(u4.getBit(88), true); EXPECT_EQ(u4.getBit(89), false); EXPECT_EQ(u4.getBit(90), true); - EXPECT_EQ(u4.getBit(91), true); EXPECT_EQ(u4.getBit(92), true); EXPECT_EQ(u4.getBit(93), true); EXPECT_EQ(u4.getBit(94), true); EXPECT_EQ(u4.getBit(95), false); EXPECT_EQ(u4.getBit(96), false); EXPECT_EQ(u4.getBit(97), false); EXPECT_EQ(u4.getBit(98), true); EXPECT_EQ(u4.getBit(99), false); - EXPECT_EQ(u4.getBit(100), false); EXPECT_EQ(u4.getBit(101), true); EXPECT_EQ(u4.getBit(102), true); EXPECT_EQ(u4.getBit(103), false); EXPECT_EQ(u4.getBit(104), false); EXPECT_EQ(u4.getBit(105), false); EXPECT_EQ(u4.getBit(106), false); EXPECT_EQ(u4.getBit(107), false); EXPECT_EQ(u4.getBit(108), false); - EXPECT_EQ(u4.getBit(109), true); EXPECT_EQ(u4.getBit(110), false); EXPECT_EQ(u4.getBit(111), false); EXPECT_EQ(u4.getBit(112), false); EXPECT_EQ(u4.getBit(113), true); EXPECT_EQ(u4.getBit(114), false); EXPECT_EQ(u4.getBit(115), false); EXPECT_EQ(u4.getBit(116), true); EXPECT_EQ(u4.getBit(117), false); - EXPECT_EQ(u4.getBit(118), false); EXPECT_EQ(u4.getBit(119), true); EXPECT_EQ(u4.getBit(120), true); EXPECT_EQ(u4.getBit(121), true); EXPECT_EQ(u4.getBit(122), false); EXPECT_EQ(u4.getBit(123), true); EXPECT_EQ(u4.getBit(124), false); EXPECT_EQ(u4.getBit(125), false); EXPECT_EQ(u4.getBit(126), false); - EXPECT_EQ(u4.getBit(127), true); - - Aesi512 u5 = "212276592061158741188353364055816027621."; - EXPECT_EQ(u5.getBit(0), true); - EXPECT_EQ(u5.getBit(1), false); EXPECT_EQ(u5.getBit(2), true); EXPECT_EQ(u5.getBit(3), false); EXPECT_EQ(u5.getBit(4), false); EXPECT_EQ(u5.getBit(5), true); EXPECT_EQ(u5.getBit(6), true); EXPECT_EQ(u5.getBit(7), true); EXPECT_EQ(u5.getBit(8), true); EXPECT_EQ(u5.getBit(9), false); - EXPECT_EQ(u5.getBit(10), true); EXPECT_EQ(u5.getBit(11), true); EXPECT_EQ(u5.getBit(12), true); EXPECT_EQ(u5.getBit(13), true); EXPECT_EQ(u5.getBit(14), false); EXPECT_EQ(u5.getBit(15), false); EXPECT_EQ(u5.getBit(16), false); EXPECT_EQ(u5.getBit(17), true); EXPECT_EQ(u5.getBit(18), true); - EXPECT_EQ(u5.getBit(19), true); EXPECT_EQ(u5.getBit(20), true); EXPECT_EQ(u5.getBit(21), false); EXPECT_EQ(u5.getBit(22), true); EXPECT_EQ(u5.getBit(23), true); EXPECT_EQ(u5.getBit(24), true); EXPECT_EQ(u5.getBit(25), true); EXPECT_EQ(u5.getBit(26), true); EXPECT_EQ(u5.getBit(27), false); - EXPECT_EQ(u5.getBit(28), false); EXPECT_EQ(u5.getBit(29), false); EXPECT_EQ(u5.getBit(30), false); EXPECT_EQ(u5.getBit(31), true); EXPECT_EQ(u5.getBit(32), true); EXPECT_EQ(u5.getBit(33), false); EXPECT_EQ(u5.getBit(34), false); EXPECT_EQ(u5.getBit(35), false); EXPECT_EQ(u5.getBit(36), true); - EXPECT_EQ(u5.getBit(37), false); EXPECT_EQ(u5.getBit(38), true); EXPECT_EQ(u5.getBit(39), false); EXPECT_EQ(u5.getBit(40), true); EXPECT_EQ(u5.getBit(41), true); EXPECT_EQ(u5.getBit(42), true); EXPECT_EQ(u5.getBit(43), false); EXPECT_EQ(u5.getBit(44), false); EXPECT_EQ(u5.getBit(45), true); - EXPECT_EQ(u5.getBit(46), false); EXPECT_EQ(u5.getBit(47), true); EXPECT_EQ(u5.getBit(48), false); EXPECT_EQ(u5.getBit(49), true); EXPECT_EQ(u5.getBit(50), true); EXPECT_EQ(u5.getBit(51), true); EXPECT_EQ(u5.getBit(52), true); EXPECT_EQ(u5.getBit(53), true); EXPECT_EQ(u5.getBit(54), true); - EXPECT_EQ(u5.getBit(55), false); EXPECT_EQ(u5.getBit(56), false); EXPECT_EQ(u5.getBit(57), true); EXPECT_EQ(u5.getBit(58), true); EXPECT_EQ(u5.getBit(59), true); EXPECT_EQ(u5.getBit(60), true); EXPECT_EQ(u5.getBit(61), true); EXPECT_EQ(u5.getBit(62), false); EXPECT_EQ(u5.getBit(63), true); - EXPECT_EQ(u5.getBit(64), true); EXPECT_EQ(u5.getBit(65), true); EXPECT_EQ(u5.getBit(66), true); EXPECT_EQ(u5.getBit(67), false); EXPECT_EQ(u5.getBit(68), false); EXPECT_EQ(u5.getBit(69), false); EXPECT_EQ(u5.getBit(70), false); EXPECT_EQ(u5.getBit(71), true); EXPECT_EQ(u5.getBit(72), true); - EXPECT_EQ(u5.getBit(73), false); EXPECT_EQ(u5.getBit(74), true); EXPECT_EQ(u5.getBit(75), false); EXPECT_EQ(u5.getBit(76), true); EXPECT_EQ(u5.getBit(77), true); EXPECT_EQ(u5.getBit(78), true); EXPECT_EQ(u5.getBit(79), false); EXPECT_EQ(u5.getBit(80), false); EXPECT_EQ(u5.getBit(81), true); - EXPECT_EQ(u5.getBit(82), false); EXPECT_EQ(u5.getBit(83), true); EXPECT_EQ(u5.getBit(84), false); EXPECT_EQ(u5.getBit(85), true); EXPECT_EQ(u5.getBit(86), false); EXPECT_EQ(u5.getBit(87), false); EXPECT_EQ(u5.getBit(88), true); EXPECT_EQ(u5.getBit(89), false); EXPECT_EQ(u5.getBit(90), false); - EXPECT_EQ(u5.getBit(91), false); EXPECT_EQ(u5.getBit(92), false); EXPECT_EQ(u5.getBit(93), true); EXPECT_EQ(u5.getBit(94), false); EXPECT_EQ(u5.getBit(95), false); EXPECT_EQ(u5.getBit(96), true); EXPECT_EQ(u5.getBit(97), false); EXPECT_EQ(u5.getBit(98), false); EXPECT_EQ(u5.getBit(99), true); - EXPECT_EQ(u5.getBit(100), false); EXPECT_EQ(u5.getBit(101), false); EXPECT_EQ(u5.getBit(102), false); EXPECT_EQ(u5.getBit(103), false); EXPECT_EQ(u5.getBit(104), false); EXPECT_EQ(u5.getBit(105), false); EXPECT_EQ(u5.getBit(106), true); EXPECT_EQ(u5.getBit(107), true); EXPECT_EQ(u5.getBit(108), true); - EXPECT_EQ(u5.getBit(109), true); EXPECT_EQ(u5.getBit(110), true); EXPECT_EQ(u5.getBit(111), true); EXPECT_EQ(u5.getBit(112), false); EXPECT_EQ(u5.getBit(113), true); EXPECT_EQ(u5.getBit(114), false); EXPECT_EQ(u5.getBit(115), false); EXPECT_EQ(u5.getBit(116), true); EXPECT_EQ(u5.getBit(117), true); - EXPECT_EQ(u5.getBit(118), false); EXPECT_EQ(u5.getBit(119), true); EXPECT_EQ(u5.getBit(120), true); EXPECT_EQ(u5.getBit(121), true); EXPECT_EQ(u5.getBit(122), true); EXPECT_EQ(u5.getBit(123), true); EXPECT_EQ(u5.getBit(124), true); EXPECT_EQ(u5.getBit(125), false); EXPECT_EQ(u5.getBit(126), false); - EXPECT_EQ(u5.getBit(127), true); - - Aesi512 u6 = "29771602601962196722470093116016540190."; - EXPECT_EQ(u6.getBit(0), false); - EXPECT_EQ(u6.getBit(1), true); EXPECT_EQ(u6.getBit(2), true); EXPECT_EQ(u6.getBit(3), true); EXPECT_EQ(u6.getBit(4), true); EXPECT_EQ(u6.getBit(5), false); EXPECT_EQ(u6.getBit(6), false); EXPECT_EQ(u6.getBit(7), false); EXPECT_EQ(u6.getBit(8), false); EXPECT_EQ(u6.getBit(9), true); - EXPECT_EQ(u6.getBit(10), false); EXPECT_EQ(u6.getBit(11), true); EXPECT_EQ(u6.getBit(12), true); EXPECT_EQ(u6.getBit(13), true); EXPECT_EQ(u6.getBit(14), false); EXPECT_EQ(u6.getBit(15), true); EXPECT_EQ(u6.getBit(16), true); EXPECT_EQ(u6.getBit(17), false); EXPECT_EQ(u6.getBit(18), true); - EXPECT_EQ(u6.getBit(19), true); EXPECT_EQ(u6.getBit(20), false); EXPECT_EQ(u6.getBit(21), false); EXPECT_EQ(u6.getBit(22), false); EXPECT_EQ(u6.getBit(23), false); EXPECT_EQ(u6.getBit(24), false); EXPECT_EQ(u6.getBit(25), false); EXPECT_EQ(u6.getBit(26), true); EXPECT_EQ(u6.getBit(27), true); - EXPECT_EQ(u6.getBit(28), true); EXPECT_EQ(u6.getBit(29), true); EXPECT_EQ(u6.getBit(30), true); EXPECT_EQ(u6.getBit(31), false); EXPECT_EQ(u6.getBit(32), true); EXPECT_EQ(u6.getBit(33), true); EXPECT_EQ(u6.getBit(34), false); EXPECT_EQ(u6.getBit(35), true); EXPECT_EQ(u6.getBit(36), true); - EXPECT_EQ(u6.getBit(37), false); EXPECT_EQ(u6.getBit(38), false); EXPECT_EQ(u6.getBit(39), false); EXPECT_EQ(u6.getBit(40), false); EXPECT_EQ(u6.getBit(41), true); EXPECT_EQ(u6.getBit(42), true); EXPECT_EQ(u6.getBit(43), true); EXPECT_EQ(u6.getBit(44), true); EXPECT_EQ(u6.getBit(45), true); - EXPECT_EQ(u6.getBit(46), false); EXPECT_EQ(u6.getBit(47), false); EXPECT_EQ(u6.getBit(48), true); EXPECT_EQ(u6.getBit(49), true); EXPECT_EQ(u6.getBit(50), false); EXPECT_EQ(u6.getBit(51), true); EXPECT_EQ(u6.getBit(52), false); EXPECT_EQ(u6.getBit(53), true); EXPECT_EQ(u6.getBit(54), false); - EXPECT_EQ(u6.getBit(55), false); EXPECT_EQ(u6.getBit(56), true); EXPECT_EQ(u6.getBit(57), false); EXPECT_EQ(u6.getBit(58), true); EXPECT_EQ(u6.getBit(59), false); EXPECT_EQ(u6.getBit(60), true); EXPECT_EQ(u6.getBit(61), true); EXPECT_EQ(u6.getBit(62), true); EXPECT_EQ(u6.getBit(63), true); - EXPECT_EQ(u6.getBit(64), false); EXPECT_EQ(u6.getBit(65), true); EXPECT_EQ(u6.getBit(66), true); EXPECT_EQ(u6.getBit(67), false); EXPECT_EQ(u6.getBit(68), false); EXPECT_EQ(u6.getBit(69), false); EXPECT_EQ(u6.getBit(70), false); EXPECT_EQ(u6.getBit(71), false); EXPECT_EQ(u6.getBit(72), true); - EXPECT_EQ(u6.getBit(73), true); EXPECT_EQ(u6.getBit(74), true); EXPECT_EQ(u6.getBit(75), false); EXPECT_EQ(u6.getBit(76), false); EXPECT_EQ(u6.getBit(77), true); EXPECT_EQ(u6.getBit(78), true); EXPECT_EQ(u6.getBit(79), false); EXPECT_EQ(u6.getBit(80), false); EXPECT_EQ(u6.getBit(81), false); - EXPECT_EQ(u6.getBit(82), false); EXPECT_EQ(u6.getBit(83), false); EXPECT_EQ(u6.getBit(84), true); EXPECT_EQ(u6.getBit(85), true); EXPECT_EQ(u6.getBit(86), false); EXPECT_EQ(u6.getBit(87), false); EXPECT_EQ(u6.getBit(88), false); EXPECT_EQ(u6.getBit(89), true); EXPECT_EQ(u6.getBit(90), true); - EXPECT_EQ(u6.getBit(91), true); EXPECT_EQ(u6.getBit(92), false); EXPECT_EQ(u6.getBit(93), false); EXPECT_EQ(u6.getBit(94), false); EXPECT_EQ(u6.getBit(95), false); EXPECT_EQ(u6.getBit(96), false); EXPECT_EQ(u6.getBit(97), true); EXPECT_EQ(u6.getBit(98), true); EXPECT_EQ(u6.getBit(99), false); - EXPECT_EQ(u6.getBit(100), true); EXPECT_EQ(u6.getBit(101), false); EXPECT_EQ(u6.getBit(102), true); EXPECT_EQ(u6.getBit(103), false); EXPECT_EQ(u6.getBit(104), true); EXPECT_EQ(u6.getBit(105), false); EXPECT_EQ(u6.getBit(106), true); EXPECT_EQ(u6.getBit(107), true); EXPECT_EQ(u6.getBit(108), false); - EXPECT_EQ(u6.getBit(109), false); EXPECT_EQ(u6.getBit(110), true); EXPECT_EQ(u6.getBit(111), true); EXPECT_EQ(u6.getBit(112), true); EXPECT_EQ(u6.getBit(113), false); EXPECT_EQ(u6.getBit(114), true); EXPECT_EQ(u6.getBit(115), false); EXPECT_EQ(u6.getBit(116), false); EXPECT_EQ(u6.getBit(117), true); - EXPECT_EQ(u6.getBit(118), true); EXPECT_EQ(u6.getBit(119), false); EXPECT_EQ(u6.getBit(120), false); EXPECT_EQ(u6.getBit(121), true); EXPECT_EQ(u6.getBit(122), true); EXPECT_EQ(u6.getBit(123), false); EXPECT_EQ(u6.getBit(124), true); - - Aesi512 u7 = "37894586767282899313108693355181559199."; - EXPECT_EQ(u7.getBit(0), true); - EXPECT_EQ(u7.getBit(1), true); EXPECT_EQ(u7.getBit(2), true); EXPECT_EQ(u7.getBit(3), true); EXPECT_EQ(u7.getBit(4), true); EXPECT_EQ(u7.getBit(5), false); EXPECT_EQ(u7.getBit(6), false); EXPECT_EQ(u7.getBit(7), true); EXPECT_EQ(u7.getBit(8), true); EXPECT_EQ(u7.getBit(9), false); - EXPECT_EQ(u7.getBit(10), true); EXPECT_EQ(u7.getBit(11), true); EXPECT_EQ(u7.getBit(12), false); EXPECT_EQ(u7.getBit(13), false); EXPECT_EQ(u7.getBit(14), true); EXPECT_EQ(u7.getBit(15), true); EXPECT_EQ(u7.getBit(16), false); EXPECT_EQ(u7.getBit(17), true); EXPECT_EQ(u7.getBit(18), true); - EXPECT_EQ(u7.getBit(19), true); EXPECT_EQ(u7.getBit(20), false); EXPECT_EQ(u7.getBit(21), true); EXPECT_EQ(u7.getBit(22), false); EXPECT_EQ(u7.getBit(23), false); EXPECT_EQ(u7.getBit(24), false); EXPECT_EQ(u7.getBit(25), false); EXPECT_EQ(u7.getBit(26), false); EXPECT_EQ(u7.getBit(27), false); - EXPECT_EQ(u7.getBit(28), false); EXPECT_EQ(u7.getBit(29), false); EXPECT_EQ(u7.getBit(30), true); EXPECT_EQ(u7.getBit(31), false); EXPECT_EQ(u7.getBit(32), true); EXPECT_EQ(u7.getBit(33), false); EXPECT_EQ(u7.getBit(34), true); EXPECT_EQ(u7.getBit(35), true); EXPECT_EQ(u7.getBit(36), true); - EXPECT_EQ(u7.getBit(37), true); EXPECT_EQ(u7.getBit(38), false); EXPECT_EQ(u7.getBit(39), false); EXPECT_EQ(u7.getBit(40), false); EXPECT_EQ(u7.getBit(41), false); EXPECT_EQ(u7.getBit(42), false); EXPECT_EQ(u7.getBit(43), false); EXPECT_EQ(u7.getBit(44), false); EXPECT_EQ(u7.getBit(45), false); - EXPECT_EQ(u7.getBit(46), true); EXPECT_EQ(u7.getBit(47), false); EXPECT_EQ(u7.getBit(48), true); EXPECT_EQ(u7.getBit(49), true); EXPECT_EQ(u7.getBit(50), true); EXPECT_EQ(u7.getBit(51), true); EXPECT_EQ(u7.getBit(52), false); EXPECT_EQ(u7.getBit(53), false); EXPECT_EQ(u7.getBit(54), true); - EXPECT_EQ(u7.getBit(55), true); EXPECT_EQ(u7.getBit(56), false); EXPECT_EQ(u7.getBit(57), false); EXPECT_EQ(u7.getBit(58), true); EXPECT_EQ(u7.getBit(59), false); EXPECT_EQ(u7.getBit(60), true); EXPECT_EQ(u7.getBit(61), true); EXPECT_EQ(u7.getBit(62), false); EXPECT_EQ(u7.getBit(63), true); - EXPECT_EQ(u7.getBit(64), true); EXPECT_EQ(u7.getBit(65), false); EXPECT_EQ(u7.getBit(66), false); EXPECT_EQ(u7.getBit(67), true); EXPECT_EQ(u7.getBit(68), false); EXPECT_EQ(u7.getBit(69), true); EXPECT_EQ(u7.getBit(70), true); EXPECT_EQ(u7.getBit(71), true); EXPECT_EQ(u7.getBit(72), false); - EXPECT_EQ(u7.getBit(73), false); EXPECT_EQ(u7.getBit(74), true); EXPECT_EQ(u7.getBit(75), true); EXPECT_EQ(u7.getBit(76), false); EXPECT_EQ(u7.getBit(77), true); EXPECT_EQ(u7.getBit(78), true); EXPECT_EQ(u7.getBit(79), true); EXPECT_EQ(u7.getBit(80), false); EXPECT_EQ(u7.getBit(81), false); - EXPECT_EQ(u7.getBit(82), true); EXPECT_EQ(u7.getBit(83), true); EXPECT_EQ(u7.getBit(84), false); EXPECT_EQ(u7.getBit(85), false); EXPECT_EQ(u7.getBit(86), true); EXPECT_EQ(u7.getBit(87), true); EXPECT_EQ(u7.getBit(88), false); EXPECT_EQ(u7.getBit(89), true); EXPECT_EQ(u7.getBit(90), false); - EXPECT_EQ(u7.getBit(91), false); EXPECT_EQ(u7.getBit(92), true); EXPECT_EQ(u7.getBit(93), false); EXPECT_EQ(u7.getBit(94), true); EXPECT_EQ(u7.getBit(95), false); EXPECT_EQ(u7.getBit(96), false); EXPECT_EQ(u7.getBit(97), false); EXPECT_EQ(u7.getBit(98), false); EXPECT_EQ(u7.getBit(99), false); - EXPECT_EQ(u7.getBit(100), false); EXPECT_EQ(u7.getBit(101), true); EXPECT_EQ(u7.getBit(102), true); EXPECT_EQ(u7.getBit(103), false); EXPECT_EQ(u7.getBit(104), true); EXPECT_EQ(u7.getBit(105), true); EXPECT_EQ(u7.getBit(106), false); EXPECT_EQ(u7.getBit(107), true); EXPECT_EQ(u7.getBit(108), true); - EXPECT_EQ(u7.getBit(109), true); EXPECT_EQ(u7.getBit(110), false); EXPECT_EQ(u7.getBit(111), false); EXPECT_EQ(u7.getBit(112), false); EXPECT_EQ(u7.getBit(113), true); EXPECT_EQ(u7.getBit(114), false); EXPECT_EQ(u7.getBit(115), false); EXPECT_EQ(u7.getBit(116), false); EXPECT_EQ(u7.getBit(117), false); - EXPECT_EQ(u7.getBit(118), false); EXPECT_EQ(u7.getBit(119), true); EXPECT_EQ(u7.getBit(120), false); EXPECT_EQ(u7.getBit(121), false); EXPECT_EQ(u7.getBit(122), true); EXPECT_EQ(u7.getBit(123), true); EXPECT_EQ(u7.getBit(124), true); - - Aesi512 u8 = "132933768221848679423944309756035959186."; - EXPECT_EQ(u8.getBit(0), false); - EXPECT_EQ(u8.getBit(1), true); EXPECT_EQ(u8.getBit(2), false); EXPECT_EQ(u8.getBit(3), false); EXPECT_EQ(u8.getBit(4), true); EXPECT_EQ(u8.getBit(5), false); EXPECT_EQ(u8.getBit(6), false); EXPECT_EQ(u8.getBit(7), true); EXPECT_EQ(u8.getBit(8), true); EXPECT_EQ(u8.getBit(9), false); - EXPECT_EQ(u8.getBit(10), false); EXPECT_EQ(u8.getBit(11), true); EXPECT_EQ(u8.getBit(12), false); EXPECT_EQ(u8.getBit(13), false); EXPECT_EQ(u8.getBit(14), false); EXPECT_EQ(u8.getBit(15), true); EXPECT_EQ(u8.getBit(16), true); EXPECT_EQ(u8.getBit(17), false); EXPECT_EQ(u8.getBit(18), false); - EXPECT_EQ(u8.getBit(19), false); EXPECT_EQ(u8.getBit(20), true); EXPECT_EQ(u8.getBit(21), false); EXPECT_EQ(u8.getBit(22), false); EXPECT_EQ(u8.getBit(23), false); EXPECT_EQ(u8.getBit(24), true); EXPECT_EQ(u8.getBit(25), true); EXPECT_EQ(u8.getBit(26), true); EXPECT_EQ(u8.getBit(27), false); - EXPECT_EQ(u8.getBit(28), true); EXPECT_EQ(u8.getBit(29), true); EXPECT_EQ(u8.getBit(30), true); EXPECT_EQ(u8.getBit(31), true); EXPECT_EQ(u8.getBit(32), false); EXPECT_EQ(u8.getBit(33), true); EXPECT_EQ(u8.getBit(34), true); EXPECT_EQ(u8.getBit(35), true); EXPECT_EQ(u8.getBit(36), false); - EXPECT_EQ(u8.getBit(37), false); EXPECT_EQ(u8.getBit(38), false); EXPECT_EQ(u8.getBit(39), true); EXPECT_EQ(u8.getBit(40), true); EXPECT_EQ(u8.getBit(41), false); EXPECT_EQ(u8.getBit(42), true); EXPECT_EQ(u8.getBit(43), true); EXPECT_EQ(u8.getBit(44), true); EXPECT_EQ(u8.getBit(45), true); - EXPECT_EQ(u8.getBit(46), false); EXPECT_EQ(u8.getBit(47), true); EXPECT_EQ(u8.getBit(48), false); EXPECT_EQ(u8.getBit(49), true); EXPECT_EQ(u8.getBit(50), false); EXPECT_EQ(u8.getBit(51), false); EXPECT_EQ(u8.getBit(52), true); EXPECT_EQ(u8.getBit(53), false); EXPECT_EQ(u8.getBit(54), true); - EXPECT_EQ(u8.getBit(55), true); EXPECT_EQ(u8.getBit(56), true); EXPECT_EQ(u8.getBit(57), true); EXPECT_EQ(u8.getBit(58), false); EXPECT_EQ(u8.getBit(59), false); EXPECT_EQ(u8.getBit(60), false); EXPECT_EQ(u8.getBit(61), true); EXPECT_EQ(u8.getBit(62), true); EXPECT_EQ(u8.getBit(63), false); - EXPECT_EQ(u8.getBit(64), true); EXPECT_EQ(u8.getBit(65), true); EXPECT_EQ(u8.getBit(66), false); EXPECT_EQ(u8.getBit(67), false); EXPECT_EQ(u8.getBit(68), false); EXPECT_EQ(u8.getBit(69), false); EXPECT_EQ(u8.getBit(70), true); EXPECT_EQ(u8.getBit(71), true); EXPECT_EQ(u8.getBit(72), false); - EXPECT_EQ(u8.getBit(73), true); EXPECT_EQ(u8.getBit(74), true); EXPECT_EQ(u8.getBit(75), true); EXPECT_EQ(u8.getBit(76), true); EXPECT_EQ(u8.getBit(77), true); EXPECT_EQ(u8.getBit(78), true); EXPECT_EQ(u8.getBit(79), true); EXPECT_EQ(u8.getBit(80), false); EXPECT_EQ(u8.getBit(81), true); - EXPECT_EQ(u8.getBit(82), false); EXPECT_EQ(u8.getBit(83), true); EXPECT_EQ(u8.getBit(84), false); EXPECT_EQ(u8.getBit(85), true); EXPECT_EQ(u8.getBit(86), false); EXPECT_EQ(u8.getBit(87), false); EXPECT_EQ(u8.getBit(88), false); EXPECT_EQ(u8.getBit(89), true); EXPECT_EQ(u8.getBit(90), true); - EXPECT_EQ(u8.getBit(91), true); EXPECT_EQ(u8.getBit(92), true); EXPECT_EQ(u8.getBit(93), true); EXPECT_EQ(u8.getBit(94), false); EXPECT_EQ(u8.getBit(95), true); EXPECT_EQ(u8.getBit(96), true); EXPECT_EQ(u8.getBit(97), true); EXPECT_EQ(u8.getBit(98), false); EXPECT_EQ(u8.getBit(99), true); - EXPECT_EQ(u8.getBit(100), false); EXPECT_EQ(u8.getBit(101), false); EXPECT_EQ(u8.getBit(102), true); EXPECT_EQ(u8.getBit(103), true); EXPECT_EQ(u8.getBit(104), false); EXPECT_EQ(u8.getBit(105), false); EXPECT_EQ(u8.getBit(106), true); EXPECT_EQ(u8.getBit(107), true); EXPECT_EQ(u8.getBit(108), true); - EXPECT_EQ(u8.getBit(109), false); EXPECT_EQ(u8.getBit(110), false); EXPECT_EQ(u8.getBit(111), false); EXPECT_EQ(u8.getBit(112), false); EXPECT_EQ(u8.getBit(113), true); EXPECT_EQ(u8.getBit(114), false); EXPECT_EQ(u8.getBit(115), false); EXPECT_EQ(u8.getBit(116), false); EXPECT_EQ(u8.getBit(117), false); - EXPECT_EQ(u8.getBit(118), false); EXPECT_EQ(u8.getBit(119), false); EXPECT_EQ(u8.getBit(120), false); EXPECT_EQ(u8.getBit(121), false); EXPECT_EQ(u8.getBit(122), true); EXPECT_EQ(u8.getBit(123), false); EXPECT_EQ(u8.getBit(124), false); EXPECT_EQ(u8.getBit(125), true); EXPECT_EQ(u8.getBit(126), true); - - - Aesi512 u9 = "112312108742573550610800981189693677283."; - EXPECT_EQ(u9.getBit(0), true); - EXPECT_EQ(u9.getBit(1), true); EXPECT_EQ(u9.getBit(2), false); EXPECT_EQ(u9.getBit(3), false); EXPECT_EQ(u9.getBit(4), false); EXPECT_EQ(u9.getBit(5), true); EXPECT_EQ(u9.getBit(6), true); EXPECT_EQ(u9.getBit(7), true); EXPECT_EQ(u9.getBit(8), false); EXPECT_EQ(u9.getBit(9), true); - EXPECT_EQ(u9.getBit(10), true); EXPECT_EQ(u9.getBit(11), true); EXPECT_EQ(u9.getBit(12), true); EXPECT_EQ(u9.getBit(13), false); EXPECT_EQ(u9.getBit(14), false); EXPECT_EQ(u9.getBit(15), false); EXPECT_EQ(u9.getBit(16), false); EXPECT_EQ(u9.getBit(17), true); EXPECT_EQ(u9.getBit(18), true); - EXPECT_EQ(u9.getBit(19), true); EXPECT_EQ(u9.getBit(20), true); EXPECT_EQ(u9.getBit(21), true); EXPECT_EQ(u9.getBit(22), true); EXPECT_EQ(u9.getBit(23), false); EXPECT_EQ(u9.getBit(24), false); EXPECT_EQ(u9.getBit(25), false); EXPECT_EQ(u9.getBit(26), false); EXPECT_EQ(u9.getBit(27), true); - EXPECT_EQ(u9.getBit(28), false); EXPECT_EQ(u9.getBit(29), true); EXPECT_EQ(u9.getBit(30), true); EXPECT_EQ(u9.getBit(31), true); EXPECT_EQ(u9.getBit(32), true); EXPECT_EQ(u9.getBit(33), true); EXPECT_EQ(u9.getBit(34), false); EXPECT_EQ(u9.getBit(35), false); EXPECT_EQ(u9.getBit(36), false); - EXPECT_EQ(u9.getBit(37), false); EXPECT_EQ(u9.getBit(38), true); EXPECT_EQ(u9.getBit(39), true); EXPECT_EQ(u9.getBit(40), true); EXPECT_EQ(u9.getBit(41), false); EXPECT_EQ(u9.getBit(42), false); EXPECT_EQ(u9.getBit(43), false); EXPECT_EQ(u9.getBit(44), false); EXPECT_EQ(u9.getBit(45), true); - EXPECT_EQ(u9.getBit(46), false); EXPECT_EQ(u9.getBit(47), true); EXPECT_EQ(u9.getBit(48), true); EXPECT_EQ(u9.getBit(49), false); EXPECT_EQ(u9.getBit(50), false); EXPECT_EQ(u9.getBit(51), false); EXPECT_EQ(u9.getBit(52), false); EXPECT_EQ(u9.getBit(53), true); EXPECT_EQ(u9.getBit(54), false); - EXPECT_EQ(u9.getBit(55), false); EXPECT_EQ(u9.getBit(56), false); EXPECT_EQ(u9.getBit(57), true); EXPECT_EQ(u9.getBit(58), true); EXPECT_EQ(u9.getBit(59), false); EXPECT_EQ(u9.getBit(60), true); EXPECT_EQ(u9.getBit(61), true); EXPECT_EQ(u9.getBit(62), true); EXPECT_EQ(u9.getBit(63), false); - EXPECT_EQ(u9.getBit(64), true); EXPECT_EQ(u9.getBit(65), false); EXPECT_EQ(u9.getBit(66), false); EXPECT_EQ(u9.getBit(67), false); EXPECT_EQ(u9.getBit(68), true); EXPECT_EQ(u9.getBit(69), false); EXPECT_EQ(u9.getBit(70), false); EXPECT_EQ(u9.getBit(71), true); EXPECT_EQ(u9.getBit(72), false); - EXPECT_EQ(u9.getBit(73), true); EXPECT_EQ(u9.getBit(74), true); EXPECT_EQ(u9.getBit(75), true); EXPECT_EQ(u9.getBit(76), true); EXPECT_EQ(u9.getBit(77), true); EXPECT_EQ(u9.getBit(78), false); EXPECT_EQ(u9.getBit(79), false); EXPECT_EQ(u9.getBit(80), false); EXPECT_EQ(u9.getBit(81), false); - EXPECT_EQ(u9.getBit(82), true); EXPECT_EQ(u9.getBit(83), false); EXPECT_EQ(u9.getBit(84), true); EXPECT_EQ(u9.getBit(85), true); EXPECT_EQ(u9.getBit(86), false); EXPECT_EQ(u9.getBit(87), true); EXPECT_EQ(u9.getBit(88), true); EXPECT_EQ(u9.getBit(89), false); EXPECT_EQ(u9.getBit(90), false); - EXPECT_EQ(u9.getBit(91), false); EXPECT_EQ(u9.getBit(92), true); EXPECT_EQ(u9.getBit(93), false); EXPECT_EQ(u9.getBit(94), true); EXPECT_EQ(u9.getBit(95), false); EXPECT_EQ(u9.getBit(96), false); EXPECT_EQ(u9.getBit(97), false); EXPECT_EQ(u9.getBit(98), true); EXPECT_EQ(u9.getBit(99), true); - EXPECT_EQ(u9.getBit(100), true); EXPECT_EQ(u9.getBit(101), true); EXPECT_EQ(u9.getBit(102), true); EXPECT_EQ(u9.getBit(103), false); EXPECT_EQ(u9.getBit(104), false); EXPECT_EQ(u9.getBit(105), true); EXPECT_EQ(u9.getBit(106), true); EXPECT_EQ(u9.getBit(107), false); EXPECT_EQ(u9.getBit(108), false); - EXPECT_EQ(u9.getBit(109), false); EXPECT_EQ(u9.getBit(110), false); EXPECT_EQ(u9.getBit(111), true); EXPECT_EQ(u9.getBit(112), false); EXPECT_EQ(u9.getBit(113), true); EXPECT_EQ(u9.getBit(114), true); EXPECT_EQ(u9.getBit(115), true); EXPECT_EQ(u9.getBit(116), true); EXPECT_EQ(u9.getBit(117), true); - EXPECT_EQ(u9.getBit(118), true); EXPECT_EQ(u9.getBit(119), false); EXPECT_EQ(u9.getBit(120), false); EXPECT_EQ(u9.getBit(121), false); EXPECT_EQ(u9.getBit(122), true); EXPECT_EQ(u9.getBit(123), false); EXPECT_EQ(u9.getBit(124), true); EXPECT_EQ(u9.getBit(125), false); EXPECT_EQ(u9.getBit(126), true); - - Aesi512 o0{}; o0.setBit(36, true); o0.setBit(233, true); o0.setBit(68, true); - EXPECT_EQ(o0, "13803492693581127574869511724554050904902217944341068258230296519901184."); - o0.setBit(36, false); o0.setBit(233, false); o0.setBit(68, false); EXPECT_EQ(o0, 0); - - Aesi512 o1{}; o1.setBit(40, true); o1.setBit(43, true); o1.setBit(101, true); - EXPECT_EQ(o1, "2535301200456458812889011060736."); - o1.setBit(40, false); o1.setBit(43, false); o1.setBit(101, false); EXPECT_EQ(o1, 0); - - Aesi512 o2{}; o2.setBit(467, true); o2.setBit(34, true); o2.setBit(143, true); - EXPECT_EQ(o2, "381072821083495145432323880589986121307201921712032611188861933548019011086397170424842053596617683411093660193217652664276125542861053624320."); - o2.setBit(467, false); o2.setBit(34, false); o2.setBit(143, false); EXPECT_EQ(o2, 0); - - Aesi512 o3{}; o3.setBit(50, true); o3.setBit(122, true); o3.setBit(142, true); - EXPECT_EQ(o3, "5575191616544638925047421184516231404716032."); - o3.setBit(50, false); o3.setBit(122, false); o3.setBit(142, false); EXPECT_EQ(o3, 0); - - Aesi512 o4{}; o4.setBit(82, true); o4.setBit(393, true); o4.setBit(263, true); - EXPECT_EQ(o4, "20173827172553973356686868531273530268215647893900685167003743309054921599211790391081306314702963082124464928329826304."); - o4.setBit(82, false); o4.setBit(393, false); o4.setBit(263, false); EXPECT_EQ(o4, 0); - - Aesi512 o5{}; o5.setBit(15, true); o5.setBit(95, true); o5.setBit(300, true); - EXPECT_EQ(o5, "2037035976334486086268445688409378161051468393665936250636140488968462556895505502955405312."); - o5.setBit(15, false); o5.setBit(95, false); o5.setBit(300, false); EXPECT_EQ(o5, 0); - - Aesi512 o6{}; o6.setBit(372, true); o6.setBit(454, true); o6.setBit(95, true); - EXPECT_EQ(o6, "46517678354918840995156733324462709240253948519300880307139836878356634767735657509940046641609035065324985849726214028890990919808974848."); - o6.setBit(372, false); o6.setBit(454, false); o6.setBit(95, false); EXPECT_EQ(o6, 0); - - Aesi512 o7{}; o7.setBit(207, true); o7.setBit(117, true); o7.setBit(413, true); - EXPECT_EQ(o7, "21153791001287955166461289857048673274508949854856999017108761654469054984712718335777202719893201711079386101974112919355392."); - o7.setBit(207, false); o7.setBit(117, false); o7.setBit(413, false); EXPECT_EQ(o7, 0); - - Aesi512 o8{}; o8.setBit(467, true); o8.setBit(453, true); o8.setBit(159, true); - EXPECT_EQ(o8, "381096079922672604852821458951838537452301238235574605366790941234392791543616799158388491710971263513484456787699324830469003835743202705408."); - o8.setBit(467, false); o8.setBit(453, false); o8.setBit(159, false); EXPECT_EQ(o8, 0); - - Aesi512 o9{}; o9.setBit(58, true); o9.setBit(299, true); o9.setBit(348, true); - EXPECT_EQ(o9, "573374653997518896420693391068564869421985451981150806668594042814856037092345879208154808176260665049088."); - o9.setBit(58, false); o9.setBit(299, false); o9.setBit(348, false); EXPECT_EQ(o9, 0); - - Aesi512 o10{}; o10.setBit(19, true); o10.setBit(138, true); o10.setBit(475, true); - EXPECT_EQ(o10, "97554642197374757230674913431036447054643691958280348464348654988292866838117675628759565720734124099093040741270997952069244837987889564876800."); - o10.setBit(19, false); o10.setBit(138, false); o10.setBit(475, false); EXPECT_EQ(o10, 0); - - Aesi512 o11{}; o11.setBit(77, true); o11.setBit(12, true); o11.setBit(475, true); - EXPECT_EQ(o11, "97554642197374757230674913431036447054643691958280348464348654988292866838117675628759565720734124098744591597543956965633864967429587562663936."); - o11.setBit(77, false); o11.setBit(12, false); o11.setBit(475, false); EXPECT_EQ(o11, 0); - - Aesi512 o12{}; o12.setBit(381, true); o12.setBit(286, true); o12.setBit(43, true); - EXPECT_EQ(o12, "4925250774549309901534880012642282534737414069347026395530241885555829259136488255786899276083904329362757935693824."); - o12.setBit(381, false); o12.setBit(286, false); o12.setBit(43, false); EXPECT_EQ(o12, 0); - - Aesi512 o13{}; o13.setBit(337, true); o13.setBit(97, true); o13.setBit(201, true); - EXPECT_EQ(o13, "279968092772225526319680285071055534765208901030419709843049721544658666381181487607125927431709392896."); - o13.setBit(337, false); o13.setBit(97, false); o13.setBit(201, false); EXPECT_EQ(o13, 0); - - Aesi512 o14{}; o14.setBit(194, true); o14.setBit(425, true); o14.setBit(218, true); - EXPECT_EQ(o14, "86645927941275464361825443254471365732388658605494267974077487315456107651561489058394366268593783921789521354162084493037404160."); - o14.setBit(194, false); o14.setBit(425, false); o14.setBit(218, false); EXPECT_EQ(o14, 0); - - Aesi512 o15{}; o15.setBit(344, true); o15.setBit(130, true); o15.setBit(455, true); - EXPECT_EQ(o15, "93035356709837681990313447409664616233181969012844080635107234590230278824842889940145012891187353173577009331931050723030751081249374208."); - o15.setBit(344, false); o15.setBit(130, false); o15.setBit(455, false); EXPECT_EQ(o15, 0); - - Aesi512 o16{}; o16.setBit(361, true); o16.setBit(305, true); o16.setBit(498, true); - EXPECT_EQ(o16, "818347651974035467503297424206899788054165208595931745037343806136469731329983980347944439822371100858262045409960603463570581736060544575336064483328."); - o16.setBit(361, false); o16.setBit(305, false); o16.setBit(498, false); EXPECT_EQ(o16, 0); - - Aesi512 o17{}; o17.setBit(239, true); o17.setBit(143, true); o17.setBit(338, true); - EXPECT_EQ(o17, "559936185544451052639360570142994493062800566473454032475379884871460975055048813683416500599301079040."); - o17.setBit(239, false); o17.setBit(143, false); o17.setBit(338, false); EXPECT_EQ(o17, 0); - - Aesi512 o18{}; o18.setBit(429, true); o18.setBit(244, true); o18.setBit(150, true); - EXPECT_EQ(o18, "1386334847060407429789207092071541851718218537687908287613509343343764803176145571533301146998015491279763794780096980271551741952."); - o18.setBit(429, false); o18.setBit(244, false); o18.setBit(150, false); EXPECT_EQ(o18, 0); - - Aesi512 o19{}; o19.setBit(342, true); o19.setBit(286, true); o19.setBit(46, true); - EXPECT_EQ(o19, "8958978968711216966560578224720437651332144025643808164713994103192096844836638004813384296588516524032."); - o19.setBit(342, false); o19.setBit(286, false); o19.setBit(46, false); EXPECT_EQ(o19, 0); - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Bitwise, GetSetByte) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m {}; uint8_t byte {}; - m = "25500030152205279384249040235552387539274952473526657228704168006265771."; - m.setByte(3, 130); byte = m.getByte(8); - EXPECT_EQ(m, "25500030152205279384249040235552387539274952473526657228704168543136683."); EXPECT_EQ(byte, 114); - m = "11973067663711446855645029841783928448494082142254567843368572898704850322653440454347984366272327292124441799397540746."; - m.setByte(48, 17); byte = m.getByte(45); - EXPECT_EQ(m, "10791007477819612479276658638779620034341689964140604443330124096577478669508524136005556378625779822900242959688336266."); EXPECT_EQ(byte, 31); - m = "38766513705573349407986864851812593727672370420584096379717774965542388658671188340380285228435220355317930507752476255589469641877980698898243."; - m.setByte(48, 225); byte = m.getByte(18); - EXPECT_EQ(m, "38766513705573349407986867176530959314946643945047462288190989465247005616132541749329596078932804873653356581194185293799492449469032127000387."); EXPECT_EQ(byte, 51); - m = "10209847901010179163405590740748846728932893765953460450856065623952064384871938528316302635587242810753539861219085459173875586170032846039368061."; - m.setByte(48, 33); byte = m.getByte(13); - EXPECT_EQ(m, "10209847901010179163405590732277415396708080735313466829325188655859920441721867494707419553674412629881639579765018214373618723396607828123402621."); EXPECT_EQ(byte, 46); - m = "2015189327385899601434050704482979709608324068009805268669057088954254915929141776282171679180249471919481."; - m.setByte(24, 3); byte = m.getByte(5); - EXPECT_EQ(m, "2015189327385899601434050704482979709608324067708504385370496412290137023615173788309258617845975815300473."); EXPECT_EQ(byte, 37); - m = "18718590587298140828829309254524948374429187392444911099799871459576073231656356618694044469727252605534345383658571755378738."; - m.setByte(16, 121); byte = m.getByte(46); - EXPECT_EQ(m, "18718590587298140828829309254524948374429187392444911099799871459576073231656356618674988657179680051580396405642392735537202."); EXPECT_EQ(byte, 241); - m = "525022161679952953670395509613537510460871990725983691373975785604101648001280746454074607372686170831287."; - m.setByte(8, 148); byte = m.getByte(5); - EXPECT_EQ(m, "525022161679952953670395509613537510460871990725983691373975785604101648001280746452580421102715697150391."); EXPECT_EQ(byte, 248); - m = "196206845334197451698107697668285779009914678252827564371272562250095484."; - m.setByte(20, 66); byte = m.getByte(25); - EXPECT_EQ(m, "196206845334197451698049237602792542893186530859518913050486324948376444."); EXPECT_EQ(byte, 93); - m = "3784669068155155387740712606655250521196702590402769498."; - m.setByte(12, 183); byte = m.getByte(0); - EXPECT_EQ(m, "3784669068155155387740712289742600464139352216226968154."); EXPECT_EQ(byte, 90); - m = "1267217244931949321246003980709992388302511962449639931433176546307921895020482804361903101176546617585258398898210366900168883268646483200361361."; - m.setByte(40, 119); byte = m.getByte(47); - EXPECT_EQ(m, "1267217244931949321246003980709992388302511962310800774098317390952245484119461916912727307223364187538700694389766084724427247517153947549483921."); EXPECT_EQ(byte, 57); - m = "4660542240303479918651015069160831470157382095267786598931088090234791028075350804679257254148437711462858566496578524734644482704199701200326281120262136."; - m.setByte(34, 56); byte = m.getByte(43); - EXPECT_EQ(m, "4660542240303479918651015069160831470157382095267786598931088090234790792830289636719877572494847432052365965267625358264624331117540709379885494552045560."); EXPECT_EQ(byte, 222); - m = "5882861481174708272515590658267037896829231252803932767344477541714430028887826331610199811756703362720569099."; - m.setByte(30, 218); byte = m.getByte(30); - EXPECT_EQ(m, "5882861481174708272515590658267038241364408884588877036087490186583540615247186222355896645469912614781425419."); EXPECT_EQ(byte, 218); - m = "654607854758614823699478186797673005680933847718935115956157419943376045451008292263708009790424145827279730093893803046889111572549."; - m.setByte(25, 231); byte = m.getByte(14); - EXPECT_EQ(m, "654607854758614823699478186797673005680933847718935115956157419943376075982831133184523245087703900309369178015750684919952982298693."); EXPECT_EQ(byte, 16); - m = "51391635968034080968235143931943244814854725581."; - m.setByte(8, 199); byte = m.getByte(10); - EXPECT_EQ(m, "51391635968034080968235147141676713640316706765."); EXPECT_EQ(byte, 170); - m = "2703210061869264465928657652842835549518302189457245330338214557734368232872577539088199704199045756151335."; - m.setByte(42, 81); byte = m.getByte(5); - EXPECT_EQ(m, "2699150524524067195797022288709305244264206706993507528056208327488871360106063497374696863742490968253991."); EXPECT_EQ(byte, 121); - m = "53886330462185772711467215637667078502272024181372945896827325446926247886414947400664557577708271641134253006435222129616566692983430585."; - m.setByte(26, 202); byte = m.getByte(41); - EXPECT_EQ(m, "53886330462185772711467215637667078502272024181372945896827325446926247865023388155488879029693672267888696441659655876380028469451513273."); EXPECT_EQ(byte, 171); - m = "420282292186490072823697164798274997441726315143171645188942493901333371793022513254973822464120875452926."; - m.setByte(21, 244); byte = m.getByte(29); - EXPECT_EQ(m, "420282292186490072823697164798274997441726315143171725255848193437518842663692388783822771294729309850110."); EXPECT_EQ(byte, 57); - m = "641149140161898337883774982032843409818313787405228991243553210071105423423222991887451."; - m.setByte(32, 187); byte = m.getByte(1); - EXPECT_EQ(m, "641149142014571765680834108809979169957320313057548745893802234702426767549833066126427."); EXPECT_EQ(byte, 28); - m = "7095872742782960838669576139031373860195307904778004233328801671985844754."; - m.setByte(20, 15); byte = m.getByte(13); - EXPECT_EQ(m, "7095872742782960838669245839661337076135793872005810353366359431231132178."); EXPECT_EQ(byte, 108); - m = "69369513050798592599018686684274045923503120."; - m.setByte(10, 242); byte = m.getByte(15); - EXPECT_EQ(m, "69369513050798592852893108803346172611800080."); EXPECT_EQ(byte, 173); - m = "2962611506976377741074982101223066205248126798938955893735246608385573920155633."; - m.setByte(19, 133); byte = m.getByte(4); - EXPECT_EQ(m, "2962611506976377741074982101223066205248126798938955893735246608385573920155633."); EXPECT_EQ(byte, 172); - m = "1895087054472930971347434110566541886052466406275548191698994019506228291907649087325211597462039."; - m.setByte(6, 27); byte = m.getByte(33); - EXPECT_EQ(m, "1895087054472930971347434110566541886052466406275548191698994019506228291907649055237064252447255."); EXPECT_EQ(byte, 138); - m = "3727710584317747315864044339393878980224545305290603645482373789133370032867341032647579386."; - m.setByte(29, 225); byte = m.getByte(27); - EXPECT_EQ(m, "3727710584317747317099456935469389898175366604638191201471122295151869226241432868707653370."); EXPECT_EQ(byte, 174); - m = "160269685900709903017808373923991600665930."; - m.setByte(12, 89); byte = m.getByte(16); - EXPECT_EQ(m, "160269685893737824716553112215759733036362."); EXPECT_EQ(byte, 214); - m = "10508309163485329714717037142191754547449136985942971556952."; - m.setByte(9, 180); byte = m.getByte(6); - EXPECT_EQ(m, "10508309163485329714717037142191754443557074362810776855640."); EXPECT_EQ(byte, 228); - m = "111102977031713641674174197978365139792654107808542650792459477335437066361683448084."; - m.setByte(8, 114); byte = m.getByte(0); - EXPECT_EQ(m, "111102977031713641674174197978365139792654107808542650792459475988824748980886180116."); EXPECT_EQ(byte, 20); - m = "112578714913510269036928215992079535807521781."; - m.setByte(11, 147); byte = m.getByte(7); - EXPECT_EQ(m, "112578714913510241802247351713713488026788853."); EXPECT_EQ(byte, 113); - m = "20773901254363119471620870402639012738947407151580610415157876255794975742902516977253730226841830394541489529519173135134365685823731619549926314701."; - m.setByte(43, 126); byte = m.getByte(45); - EXPECT_EQ(m, "20773901254363119471620870402639012738947407008236946915778406780118669786522083177468418403824260160942187067836493379604065181447572050167070905037."); EXPECT_EQ(byte, 217); - m = "201597637203785798797953938331673561091488455350571584431051426374181195."; - m.setByte(15, 48); byte = m.getByte(15); - EXPECT_EQ(m, "201597637203785798797953938331673405571812948515414454685625373573865803."); EXPECT_EQ(byte, 48); - m = "1273099179911989256007890929447820995344548162282325938173213561655912873711039769362742292989968822599603191407871687860."; - m.setByte(10, 105); byte = m.getByte(13); - EXPECT_EQ(m, "1273099179911989256007890929447820995344548162282325938173213561655912873711039769362742292990026851038944693608257584308."); EXPECT_EQ(byte, 74); - m = "2638710524646020090465303056768019305932473342019."; - m.setByte(20, 33); byte = m.getByte(11); - EXPECT_EQ(m, "49406762919234913472983217703689075934922314717251."); EXPECT_EQ(byte, 147); - m = "31999212342009031986744849378199594297045373447607."; - m.setByte(9, 207); byte = m.getByte(19); - EXPECT_EQ(m, "31999212342009031986744849609595551957657988918711."); EXPECT_EQ(byte, 229); - m = "35087192645158151269133339872096994654592615394631."; - m.setByte(3, 84); byte = m.getByte(6); - EXPECT_EQ(m, "35087192645158151269133339872096994654593689136455."); EXPECT_EQ(byte, 50); - m = "291228422026370938625869604419923779450368."; - m.setByte(16, 159); byte = m.getByte(15); - EXPECT_EQ(m, "315728752444678507995232576155011090675200."); EXPECT_EQ(byte, 215); - m = "465673394661093310764445934267423333606317747385252379248542450646161678745543101141824945518810222677625240365173547657428761078."; - m.setByte(50, 101); byte = m.getByte(49); - EXPECT_EQ(m, "465673206156852210420118889385323777386450921316729502715226014008028651278266693912417737554699433227563545544241993646861744630."); EXPECT_EQ(byte, 79); - m = "290101750950999312213039444518955864872086306858985238167343950143241."; - m.setByte(9, 87); byte = m.getByte(14); - EXPECT_EQ(m, "290101750950999312213039444518955864872086306377303856914640138346249."); EXPECT_EQ(byte, 126); - m = "348078713664321910111850667944298147653512968372716726271684182190576725100332384926365708."; - m.setByte(6, 29); byte = m.getByte(4); - EXPECT_EQ(m, "348078713664321910111850667944298147653512968372716726271684182190576725083162411347015692."); EXPECT_EQ(byte, 71); - m = "17183495705326843067303991572885921560074965987609578451775601507586593393742206536366778600225095913507698274118240627593197060679."; - m.setByte(32, 168); byte = m.getByte(0); - EXPECT_EQ(m, "17183495705326843067303991572885921560074965987609574167468299726887362721615761214914188029235663284806828814187632334807400383047."); EXPECT_EQ(byte, 71); - m = "115493522494918195722613577735684103729932045295348141595603101481896210913508427413936970361917711555146640797730688159388368088."; - m.setByte(28, 190); byte = m.getByte(13); - EXPECT_EQ(m, "115493522494918195722613577735684103729932045295348141595603317161469548118626784750057666518963100652302021122310536988270361816."); EXPECT_EQ(byte, 163); - m = "5562807300607821983303438698013381735289977046199667414819803888262555484924377168982681832413375826816099726993702476032342512855415529787367015."; - m.setByte(23, 225); byte = m.getByte(37); - EXPECT_EQ(m, "5562807300607821983303438698013381735289977046199667414819803888262555484924377168982685167123672750990255514756833555105126067231745401305701991."); EXPECT_EQ(byte, 57); - m = "46476223558803333439547350188187739174148987245997067275699716148."; - m.setByte(11, 188); byte = m.getByte(4); - EXPECT_EQ(m, "46476223558803333439547350188187739176315382314746482756773183540."); EXPECT_EQ(byte, 67); - m = "1056084716594942775358538951120102968181960559109474502505673967106451345018094862844458463943815682492683943984853910."; - m.setByte(14, 198); byte = m.getByte(13); - EXPECT_EQ(m, "1056084716594942775358538951120102968181960559109474502505673967106451345018094863607726102148435343886666904380208022."); EXPECT_EQ(byte, 114); - m = "1934626198763332123161722839367426245490770909655229040991416162699069968202878392954941304256008847790219627238496671039766."; - m.setByte(41, 77); byte = m.getByte(41); - EXPECT_EQ(m, "1934626198763332123161680734790974172511226738987357026780133114187525273863477196870767912660774259803697574609838977253654."); EXPECT_EQ(byte, 77); - m = "2102951809858015776056628841411429556690003098454774990678013392861347740391199946754217775965995600491859202779."; - m.setByte(3, 12); byte = m.getByte(11); - EXPECT_EQ(m, "2102951809858015776056628841411429556690003098454774990678013392861347740391199946754217775965995600489611055835."); EXPECT_EQ(byte, 180); - m = "4276514576750030029829647085975374372063557647717830580690439840639538106876432930831508526773160576491990132107030820061613555330684241666."; - m.setByte(8, 126); byte = m.getByte(41); - EXPECT_EQ(m, "4276514576750030029829647085975374372063557647717830580690439840639538106876432930831508526773160576491990132107030821260651920121805096706."); EXPECT_EQ(byte, 114); - m = "5270957713426030684987553923002745495719."; - m.setByte(4, 37); byte = m.getByte(0); - EXPECT_EQ(m, "5270957713426030684987553922341320532135."); EXPECT_EQ(byte, 167); - m = "1810019463212630161229225735906487090124331777980760941175488394210634267303621721134578971665395285233946049155499596114690."; - m.setByte(37, 119); byte = m.getByte(16); - EXPECT_EQ(m, "1810019463212630161229225735906476650314953063739568815391335296147558878528104183211294461445592344029784762054880406203138."); EXPECT_EQ(byte, 193); - m = "16057991375434093123432454323061689391672."; - m.setByte(15, 110); byte = m.getByte(0); - EXPECT_EQ(m, "16140403511172757907552490360799070755384."); EXPECT_EQ(byte, 56); - m = "6177859178807629291011956649258930852428927962903598715840908056060555503364145349987198981272360442714039812144026849005495197371728."; - m.setByte(38, 88); byte = m.getByte(16); - EXPECT_EQ(m, "6177859178807629291011956649258930852431046480318986581370627239576501256651638877116611554973022028781368368695780719179925930642768."); EXPECT_EQ(byte, 65); - m = "621478024739904716223180743056579165744997535422960345221476097183615689776."; - m.setByte(16, 53); byte = m.getByte(8); - EXPECT_EQ(m, "621478024739904716223180743056579164724150434660144954831352274888311055408."); EXPECT_EQ(byte, 160); - m = "66134752615439768993960240082581357891527133480215851289338861987218308299500960547297074539918237613762885360433286518564."; - m.setByte(23, 147); byte = m.getByte(2); - EXPECT_EQ(m, "66134752615439768993960240082581357891527133480215851289338861985256714007192622808598390345165841858730899284038275733284."); EXPECT_EQ(byte, 2); - m = "1485004686580204777608746117376941160121158721950763536730."; - m.setByte(0, 202); byte = m.getByte(21); - EXPECT_EQ(m, "1485004686580204777608746117376941160121158721950763536842."); EXPECT_EQ(byte, 44); - m = "45867265252607230522208461404638921493920501576779512200404388102964162379501130340590."; - m.setByte(7, 127); byte = m.getByte(9); - EXPECT_EQ(m, "45867265252607230522208461404638921493920501576779512200404388102964738840253433764078."); EXPECT_EQ(byte, 65); - m = "7137440861238914938639440457363081009158196948141604506814724380176028675837751555610603509998270743224748809586635343003566582884."; - m.setByte(23, 218); byte = m.getByte(39); - EXPECT_EQ(m, "7137440861238914938639440457363081009158196948141604506814724380176028677308947274841856814022283889289045625860624900299824671844."); EXPECT_EQ(byte, 63); - m = "13731791177170774580929854100369547024037381358146959252514251517702945181148905298437602368706585210514768232633597266754734082189."; - m.setByte(8, 14); byte = m.getByte(45); - EXPECT_EQ(m, "13731791177170774580929854100369547024037381358146959252514251517702945181148905298437602368706585210514768229737458447182334478477."); EXPECT_EQ(byte, 16); - m = "16262263275612795439518620016861099109251053071274191909832297141860678949053996736984767597365644682997974828257336653838302218735461480200949492842701."; - m.setByte(21, 146); byte = m.getByte(56); - EXPECT_EQ(m, "16262263275612795439518620016861099109251053071274191909832297141860678949053996736984767597365644681127252732473780918537585632858619215041355837833421."); EXPECT_EQ(byte, 235); - m = "6639883088500219477216161912431723191534636015959980805476710177662073850201537393715276499076312062881651782093565395872452787984."; - m.setByte(35, 13); byte = m.getByte(20); - EXPECT_EQ(m, "6639883088500219477216161912431723191534635897457178379707236851574897533966884088528459316895801266521094788020403998354734399248."); EXPECT_EQ(byte, 110); - m = "73994250519711384469513487172938121517400311694199629013672500425483897993597953338482441209847546665803788032487793304945145116892718326."; - m.setByte(9, 39); byte = m.getByte(4); - EXPECT_EQ(m, "73994250519711384469513487172938121517400311694199629013672500425483897993597953338482441209847546665803788032487103839438646148691518710."); EXPECT_EQ(byte, 100); - m = "793564991844287200630047323074742917736625995479452670020511301846822912259025330856120150603599350."; - m.setByte(15, 100); byte = m.getByte(37); - EXPECT_EQ(m, "793564991844287200630047323074742917736625995479452670020511401538922596127715798641649671629442550."); EXPECT_EQ(byte, 121); - m = "13090797092636019816163623996579298165684641721209098983921178899956399986740."; - m.setByte(29, 66); byte = m.getByte(22); - EXPECT_EQ(m, "13091031752011810695332396778278615584550025058914152777064054425780009162804."); EXPECT_EQ(byte, 220); - m = "629411669098325908812721438426937759091490014194301388162120149385198278003027033553768188335377727761676574034453."; - m.setByte(14, 11); byte = m.getByte(40); - EXPECT_EQ(m, "629411669098325908812721438426937759091490014194301388162120149385198278003026213170864539832612419943256557259285."); EXPECT_EQ(byte, 213); - m = "2789173390702549845834028264408739290703958576685791603970032398834960074."; - m.setByte(30, 149); byte = m.getByte(12); - EXPECT_EQ(m, "264282538977903430624162058374360679633171575314277397405967750190142686922."); EXPECT_EQ(byte, 231); - m = "3419802312413369670736731265829631703528336250153109395."; - m.setByte(0, 68); byte = m.getByte(4); - EXPECT_EQ(m, "3419802312413369670736731265829631703528336250153109316."); EXPECT_EQ(byte, 168); - m = "1011543270904368030564683659208195407756."; - m.setByte(13, 40); byte = m.getByte(8); - EXPECT_EQ(m, "1011543331751596841519694931049949265804."); EXPECT_EQ(byte, 56); - m = "50434230858711963742992984066540008923658133806292734425760603926952040921278462490564352668910625208917741063231316733253460324874861403445573966387662."; - m.setByte(60, 145); byte = m.getByte(5); - EXPECT_EQ(m, "50434324511168473222759925514456902718647306264237014374895129701660829682430627083532956278093717113676875858039250375452147188314131782094133155092942."); EXPECT_EQ(byte, 74); - m = "2249093479877734359993614809207903904159754982030340557700833539344438317419765647884417875378193723062."; - m.setByte(27, 255); byte = m.getByte(36); - EXPECT_EQ(m, "2249093479877734359993614809207903922378781440690733856440652328619423108588617152179414122373992836790."); EXPECT_EQ(byte, 106); - m = "42378477282261856731312705087274447911007417."; - m.setByte(7, 122); byte = m.getByte(4); - EXPECT_EQ(m, "42378477282261856731312700403530835445691577."); EXPECT_EQ(byte, 102); - m = "11158577342622727202407368960763197418512921124081071302412917213598225519423853203737."; - m.setByte(14, 105); byte = m.getByte(11); - EXPECT_EQ(m, "11158577342622727202407368960763197418512921124080744187710829519457628098155112337689."); EXPECT_EQ(byte, 248); - m = "1360984031730203166524502513415255695786358198569015208303948751194603380151405228647085529167021595166038385389960427003295724047921121593."; - m.setByte(43, 175); byte = m.getByte(46); - EXPECT_EQ(m, "1360984031730203166524502513415253043928583460048829908292288558156578084123136502822036207579926054036462908079401096044343690465096042809."); EXPECT_EQ(byte, 178); - m = "400448052625448285010913014174622259382568896358407596609171724286336871441394884063534428171575511523016086778003."; - m.setByte(46, 72); byte = m.getByte(28); - EXPECT_EQ(m, "351147446727859977891057037486820496503898568291724145883284272211932739586189023618344458797482446908969707761811."); EXPECT_EQ(byte, 229); - m = "788481636686698326104097825448480015212706753936591699466897625701192782629355447620402763997708336971084513236893443."; - m.setByte(38, 98); byte = m.getByte(48); - EXPECT_EQ(m, "788481636686698326104095120264703443015184189440717491812699749351165994266014602825886021379342251259938701685178115."); EXPECT_EQ(byte, 20); - m = "100320208852603372314593488711214821536648761163583991456510547097467355638686801807582."; - m.setByte(8, 8); byte = m.getByte(24); - EXPECT_EQ(m, "100320208852603372314593488711214821536648761163583991456510547097430462150539382704350."); EXPECT_EQ(byte, 145); - m = "17964089316120025336185856027508610243247568407315737763150915110312001685766680379813003316386440241775065171758848346."; - m.setByte(36, 54); byte = m.getByte(43); - EXPECT_EQ(m, "17964089316120025336185856027450920747824033156825713422365883892860348772274188044589909495066833740121611300197013850."); EXPECT_EQ(byte, 45); - m = "182029462883275069130930933729621005217865543902454317675690643879022769402615098698687917179095002323370601540433429480076355648727620114921831584229."; - m.setByte(4, 127); byte = m.getByte(26); - EXPECT_EQ(m, "182029462883275069130930933729621005217865543902454317675690643879022769402615098698687917179095002323370601540433429480076355648727620114449385181669."); EXPECT_EQ(byte, 50); - m = "1911016421641240776465206014697183340299086607661634602261942084274172160628366."; - m.setByte(26, 212); byte = m.getByte(27); - EXPECT_EQ(m, "1911016421641236251327673381380567414133834574947745899738311591929547951953550."); EXPECT_EQ(byte, 41); - m = "3325321678389425978579879479669246890801583364181684521492317892506182612444455221286978862148095036873348750218315923807."; - m.setByte(8, 29); byte = m.getByte(36); - EXPECT_EQ(m, "3325321678389425978579879479669246890801583364181684521492317892506182612444455221286978862148095033645168537319144391007."); EXPECT_EQ(byte, 46); - m = "2173152753648370924619686483406380788147394971772578675702331090856352504746793519260469825010373594649300034."; - m.setByte(32, 111); byte = m.getByte(26); - EXPECT_EQ(m, "2173152753648370924619686483396191084294511146575304429021566554965264746096217149624997557617677239240985666."); EXPECT_EQ(byte, 245); - m = "93652610052884203582534995443554757943547541322139246512766228981548346339241273072793239086966174535601928402454452635426588922162113464372."; - m.setByte(50, 169); byte = m.getByte(26); - EXPECT_EQ(m, "93652610052884203394030754343210430898665441765919379686697706105015029902603140045325962679736767327637817613004390940605657368151546447924."); EXPECT_EQ(byte, 175); - m = "36200731266180541177114883906785686649558621833690070854977534830924009076982586251508338088."; - m.setByte(34, 244); byte = m.getByte(36); - EXPECT_EQ(m, "36200731380008796580966196655972907752499182769768596580688834904272392460121509212751023528."); EXPECT_EQ(byte, 87); - m = "17391309863097998239045521972761256492230203723500188887105697900117907047466214389118395451427371071410889669425846."; - m.setByte(1, 251); byte = m.getByte(23); - EXPECT_EQ(m, "17391309863097998239045521972761256492230203723500188887105697900117907047466214389118395451427371071410889669475254."); EXPECT_EQ(byte, 212); - m = "1407130623260803283530828213974028495775069119579623017958160626061384."; - m.setByte(18, 176); byte = m.getByte(19); - EXPECT_EQ(m, "1407130623260803283530830555552274341490498980830041646036118754005064."); EXPECT_EQ(byte, 46); - m = "456908067635076234443672710378015958650713719."; - m.setByte(16, 112); byte = m.getByte(15); - EXPECT_EQ(m, "456942095871768328290019047838759135471859319."); EXPECT_EQ(byte, 33); - m = "360795999685155339629839375054277164342266052643001946340636652018023181989014381766576434352377790719405780428924023."; - m.setByte(18, 169); byte = m.getByte(47); - EXPECT_EQ(m, "360795999685155339629839375054277164342266052643001946340636652018023180338759237075310321878734638543427028986373239."); EXPECT_EQ(byte, 40); - m = "311302337171820240565985277178449260725120130419545776073427385976405885902151672908620838775090128321518313429218456606110."; - m.setByte(46, 49); byte = m.getByte(30); - EXPECT_EQ(m, "311302337133942945791008894879047717660101702842030767924634003101638697113280205751572433798907590875568763786719409313182."); EXPECT_EQ(byte, 54); - m = "39518713092252491376689299367517442106606935267310688866652622."; - m.setByte(22, 83); byte = m.getByte(5); - EXPECT_EQ(m, "39518703418374389660765880980451833220280213674019980082663886."); EXPECT_EQ(byte, 233); - m = "36360988318521532933111285235496337387964127473039718584891264860140912458851521464217754380375249405922191705077674264595439100339253973314."; - m.setByte(14, 147); byte = m.getByte(47); - EXPECT_EQ(m, "36360988318521532933111285235496337387964127473039718584891264860140912458851521464217754380375249405922539588967196098046550643593311719746."); EXPECT_EQ(byte, 141); - m = "13483091628297795559035205069669460060934696416344517948751."; - m.setByte(7, 94); byte = m.getByte(16); - EXPECT_EQ(m, "13483091628297795559035205069669460060931525882206849119567."); EXPECT_EQ(byte, 25); - m = "421102176685849998087496851490258579044790730156201829241301523717673247975941823263867577055811595798600524486563225325720154118."; - m.setByte(6, 102); byte = m.getByte(30); - EXPECT_EQ(m, "421102176685849998087496851490258579044790730156201829241301523717673247975941823263867577055811595798600524486532544553258692614."); EXPECT_EQ(byte, 233); - m = "1539712383991468731147959762434313463069860657898734107297303689523010892604102562681352187645897385474586138546469072682924655."; - m.setByte(35, 27); byte = m.getByte(24); - EXPECT_EQ(m, "1539712383991468731147959762434313463069423557397983318256346810593975600850108021142565456253615727682394885082297900770835055."); EXPECT_EQ(byte, 58); - m = "12217128826724450276060706007664749680431372927830876608."; - m.setByte(7, 90); byte = m.getByte(8); - EXPECT_EQ(m, "12217128826724450276060706007664749673585901494227722688."); EXPECT_EQ(byte, 82); - m = "17419232812597520462000268842221105792335455052508003111544287661735608594230419136530608911762953775398262838718895743839862901792."; - m.setByte(40, 141); byte = m.getByte(17); - EXPECT_EQ(m, "17419232812597520462000268842221392014598268454459044044452914381718965356636414928001781815338401952841517444552598820759512402976."); EXPECT_EQ(byte, 111); - m = "184467690679076334321460806100772548333461128504629."; - m.setByte(16, 56); byte = m.getByte(19); - EXPECT_EQ(m, "184467690669548428047674529123798059325371618583861."); EXPECT_EQ(byte, 55); - m = "1429673876746702587655009481558601402934302287124320111801480475362784362832763974997670394852661915831868699746793295118584346763256034810."; - m.setByte(31, 28); byte = m.getByte(8); - EXPECT_EQ(m, "1429673876746702587655009481558601402934302287124320111801480408420482772509338495745694686704965188160158814923342209807168592188477961722."); EXPECT_EQ(byte, 145); - m = "15711311577106209191751215367128206320014449."; - m.setByte(12, 58); byte = m.getByte(14); - EXPECT_EQ(m, "15711311577093928826561504394801207007712369."); EXPECT_EQ(byte, 31); - m = "473124467356504233367935373407112941865942055."; - m.setByte(10, 224); byte = m.getByte(8); - EXPECT_EQ(m, "473124467356504233450142329140907725745962023."); EXPECT_EQ(byte, 34); - m = "478353996718892500934865980259176213453100805047672774814707703913271296499182597921077456832772909336174142773007532111530774."; - m.setByte(43, 155); byte = m.getByte(2); - EXPECT_EQ(m, "478353996718892500938664587341909769394206227155516856310402014676581262110372979436312047846294462299540111001596177779886870."); EXPECT_EQ(byte, 109); - m = "265295974621243484664052991725735921041305149616509439218495821669521369030442567113160428726301251093246869277096."; - m.setByte(14, 229); byte = m.getByte(24); - EXPECT_EQ(m, "265295974621243484664052991725735921041305149616509439218495821669521369030443460188220096716653358338615495133608."); EXPECT_EQ(byte, 141); - m = "9697532499093658222346399676087833087654803124597239646227722660469182853334637903772941177037087266060646120869344893346866247."; - m.setByte(22, 58); byte = m.getByte(23); - EXPECT_EQ(m, "9697532499093658222346399676087833087654803124597239646227722660469182837434996667289344271569236859376188340824926500691993671."); EXPECT_EQ(byte, 2); - m = "76037161695865804934571367569966851600682818152405514254217961538225004989182609775661990076143914514406211790571896357318."; - m.setByte(14, 196); byte = m.getByte(47); - EXPECT_EQ(m, "76037161695865804934571367569966851600682818152405514254217961538225004989182609775662986997140753201310889645867106615750."); EXPECT_EQ(byte, 240); - m = "8218490602206465278523501514619487822031474091."; - m.setByte(17, 158); byte = m.getByte(10); - EXPECT_EQ(m, "8220494184782895764196373864308046073260527019."); EXPECT_EQ(byte, 136); - - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count());; -} - -TEST(Bitwise, GetSetBlock) { - { - Aesi<256> v = 0; - v.setBlock(0, 2996518289); v.setBlock(1, 2204378359); v.setBlock(2, 2562794400); v.setBlock(3, 4234170865); v.setBlock(4, 2854339130); v.setBlock(5, 2984941461); v.setBlock(6, 1192451785); v.setBlock(7, 2085386850); - EXPECT_EQ(v, "0b0111110001001100011110100110001001000111000100110101111011001001101100011110101010010111100101011010101000100001110000100011101011111100011000000101000111110001100110001100000100100011101000001000001101100100001001001111011110110010100110110011110110010001"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 5838154); v.setBlock(1, 4092742162); v.setBlock(2, 2093312507); v.setBlock(3, 3235144972); v.setBlock(4, 564683421); v.setBlock(5, 601148827); v.setBlock(6, 666315807); v.setBlock(7, 2123657589); - EXPECT_EQ(v, "0b0111111010010100011100010111010100100111101101110010110000011111001000111101010011001101100110110010000110101000011000101001110111000000110101000110010100001100011111001100010101101001111110111111001111110010010010100001001000000000010110010001010101001010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1899136336); v.setBlock(1, 1962062636); v.setBlock(2, 979511162); v.setBlock(3, 598894541); v.setBlock(4, 19556868); v.setBlock(5, 274897474); v.setBlock(6, 2645406619); v.setBlock(7, 282702636); - EXPECT_EQ(v, "0b0001000011011001101100110010110010011101101011011011001110011011000100000110001010011010010000100000000100101010011010100000010000100011101100100110011111001101001110100110001000100111011110100111010011110010101100110010110001110001001100101000010101010000"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1771363449); v.setBlock(1, 866093798); v.setBlock(2, 515964119); v.setBlock(3, 2117929174); v.setBlock(4, 1590599710); v.setBlock(5, 31653167); v.setBlock(6, 4043874080); v.setBlock(7, 2639487490); - EXPECT_EQ(v, "0b1001110101010011011000100000001011110001000010001001111100100000000000011110001011111101001011110101111011001110101000000001111001111110001111010000100011010110000111101100000011111100110101110011001110011111100010101110011001101001100101001101110001111001"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 816181258); v.setBlock(1, 2362812647); v.setBlock(2, 4154305086); v.setBlock(3, 4046670874); v.setBlock(4, 412614353); v.setBlock(5, 1374776725); v.setBlock(6, 2866844404); v.setBlock(7, 3581549588); - EXPECT_EQ(v, "0b1101010101111010000111000001010010101010111000001001001011110100010100011111000101101101100101010001100010010111111111101101000111110001001100110100110000011010111101111001110110101010001111101000110011010101101010001110011100110000101001011111000000001010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 830011515); v.setBlock(1, 2694135319); v.setBlock(2, 2159315809); v.setBlock(3, 1982781521); v.setBlock(4, 35517563); v.setBlock(5, 3834815279); v.setBlock(6, 66186924); v.setBlock(7, 2160380246); - EXPECT_EQ(v, "0b1000000011000100110010010101011000000011111100011110111010101100111001001001001010100011001011110000001000011101111101000111101101110110001011101101100001010001100000001011010010001011011000011010000010010101001111100001011100110001011110001111100001111011"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 378798562); v.setBlock(1, 32642765); v.setBlock(2, 2394127302); v.setBlock(3, 1229750488); v.setBlock(4, 3582558977); v.setBlock(5, 502626102); v.setBlock(6, 3124542233); v.setBlock(7, 2293532049); - EXPECT_EQ(v, "0b1000100010110100100001011001000110111010001111001011101100011001000111011111010101110111001101101101010110001001100000110000000101001001010011001000000011011000100011101011001101111011110001100000000111110010000101101100110100010110100101000000000111100010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1658413944); v.setBlock(1, 4131334207); v.setBlock(2, 240063001); v.setBlock(3, 1069508628); v.setBlock(4, 3465011114); v.setBlock(5, 512577764); v.setBlock(6, 5974688); v.setBlock(7, 2451745539); - EXPECT_EQ(v, "0b1001001000100010101010110000001100000000010110110010101010100000000111101000110101010000111001001100111010000111110111111010101000111111101111110110100000010100000011100100111100010010000110011111011000111111001010000011111101100010110110010110001101111000"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1123538980); v.setBlock(1, 4097649259); v.setBlock(2, 1974045642); v.setBlock(3, 11707332); v.setBlock(4, 1750136655); v.setBlock(5, 3611228280); v.setBlock(6, 2110847509); v.setBlock(7, 3712711249); - EXPECT_EQ(v, "0b1101110101001011011110100101000101111101110100001111101000010101110101110011111011111000011110000110100001010000111101110100111100000000101100101010001111000100011101011010100110001011110010101111010000111101001010100110101101000010111101111101100000100100"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 2429133743); v.setBlock(1, 1751115826); v.setBlock(2, 3705673661); v.setBlock(3, 3559534575); v.setBlock(4, 3841629607); v.setBlock(5, 1982227590); v.setBlock(6, 2938846263); v.setBlock(7, 1275037345); - EXPECT_EQ(v, "0b0100101111111111100001101010000110101111001010110011110000110111011101100010011001100100100001101110010011111010100111011010011111010100001010100010111111101111110111001110000000010111101111010110100001011111111010000011001010010000110010011010001110101111"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1041401522); v.setBlock(1, 362096520); v.setBlock(2, 1362390126); v.setBlock(3, 796473907); v.setBlock(4, 4144453259); v.setBlock(5, 739787128); v.setBlock(6, 321085936); v.setBlock(7, 3378302733); - EXPECT_EQ(v, "0b1100100101011100110011110000110100010011001000110110000111110000001011000001100001000001011110001111011100000111010101101000101100101111011110010011101000110011010100010011010001101100011011100001010110010101001001111000100000111110000100101000011010110010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3850991329); v.setBlock(1, 3075011704); v.setBlock(2, 3412884974); v.setBlock(3, 3132340999); v.setBlock(4, 818954321); v.setBlock(5, 1274399492); v.setBlock(6, 3617213044); v.setBlock(7, 3859060060); - EXPECT_EQ(v, "0b1110011000000100100101010101110011010111100110100100101001110100010010111111010111001011000001000011000011010000010000000101000110111010101100111011101100000111110010110110110001111101111011101011011101001000111101000111100011100101100010010111011011100001"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 770884658); v.setBlock(1, 2151066307); v.setBlock(2, 2849326844); v.setBlock(3, 4009558025); v.setBlock(4, 4054752346); v.setBlock(5, 2189473466); v.setBlock(6, 1184082458); v.setBlock(7, 173925068); - EXPECT_EQ(v, "0b0000101001011101111000101100110001000110100100111010101000011010100000101000000010110110101110101111000110101110100111000101101011101110111111010000000000001001101010011101010101000110111111001000000000110110101010101100001100101101111100101100010000110010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1490112118); v.setBlock(1, 2165529776); v.setBlock(2, 3967521584); v.setBlock(3, 2237792965); v.setBlock(4, 3800843785); v.setBlock(5, 3114944526); v.setBlock(6, 482500077); v.setBlock(7, 720353553); - EXPECT_EQ(v, "0b0010101011101111101110010001000100011100110000100101110111101101101110011010101001001000000011101110001010001100010001100000100110000101011000100000001011000101111011000111101110010011001100001000000100010011010111001011000001011000110100010100111001110110"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3821909907); v.setBlock(1, 2061617179); v.setBlock(2, 4097673352); v.setBlock(3, 466240605); v.setBlock(4, 726595768); v.setBlock(5, 2032737202); v.setBlock(6, 1624450772); v.setBlock(7, 1506376752); - EXPECT_EQ(v, "0b0101100111001001011111000011000001100000110100110010011011010100011110010010100100011011101100100010101101001110111110001011100000011011110010100100010001011101111101000011110110001000100010000111101011100001110010000001101111100011110011011011011110010011"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1369296696); v.setBlock(1, 3142389534); v.setBlock(2, 2876156466); v.setBlock(3, 2596371073); v.setBlock(4, 1547466829); v.setBlock(5, 3220646325); v.setBlock(6, 964875921); v.setBlock(7, 3203319696); - EXPECT_EQ(v, "0b1011111011101110110001111001000000111001100000101101011010010001101111111111011100101001101101010101110000111100011110000100110110011010110000010111101010000001101010110110111010101010001100101011101101001101000011110001111001010001100111011100111100111000"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1790600854); v.setBlock(1, 3083359547); v.setBlock(2, 2883929944); v.setBlock(3, 2919235547); v.setBlock(4, 1945282022); v.setBlock(5, 3157783719); v.setBlock(6, 2868933201); v.setBlock(7, 4117201509); - EXPECT_EQ(v, "0b1111010101100111100000100110010110101011000000000111001001010001101111000011011111110100101001110111001111110010101001011110011010101101111111111111111111011011101010111110010101000111010110001011011111001000010101010011101101101010101110100110011010010110"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 752159466); v.setBlock(1, 1650941344); v.setBlock(2, 3959408811); v.setBlock(3, 4199780363); v.setBlock(4, 1635453441); v.setBlock(5, 1721151066); v.setBlock(6, 3480362280); v.setBlock(7, 1790351015); - EXPECT_EQ(v, "0b0110101010110110100101101010011111001111011100100001110100101000011001101001011010101110010110100110000101111011000010100000000111111010010100111001000000001011111010111111111111001000101010110110001001100111010111011010000000101100110101010000101011101010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3139548659); v.setBlock(1, 1220688699); v.setBlock(2, 1447387080); v.setBlock(3, 1458401987); v.setBlock(4, 1439544509); v.setBlock(5, 1222297735); v.setBlock(6, 4022003105); v.setBlock(7, 4080170984); - EXPECT_EQ(v, "0b1111001100110010011101111110100011101111101110101110010110100001010010001101101011001000100001110101010111001101101101001011110101010110111011010111001011000011010101100100010101011111110010000100100011000010001110110011101110111011001000011011010111110011"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1762737466); v.setBlock(1, 1801351446); v.setBlock(2, 1161424425); v.setBlock(3, 3643691220); v.setBlock(4, 3277899155); v.setBlock(5, 1735729124); v.setBlock(6, 447836645); v.setBlock(7, 1614015805); - EXPECT_EQ(v, "0b0110000000110011111011010011110100011010101100010111000111100101011001110111010100011111111001001100001101100000110001011001001111011001001011100101000011010100010001010011100111101110001010010110101101011110011100010001011001101001000100010011110100111010"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1277516593); v.setBlock(1, 1627371649); v.setBlock(2, 3270266578); v.setBlock(3, 1964291532); v.setBlock(4, 4095710735); v.setBlock(5, 4016484266); v.setBlock(6, 1408838094); v.setBlock(7, 2785749983); - EXPECT_EQ(v, "0b1010011000001011001010111101111101010011111110010010100111001110111011110110011010101111101010101111010000011111100101100000111101110101000101001011010111001100110000101110110001001110110100100110000011111111101110001000000101001100001001010101101100110001"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 2478182814); v.setBlock(1, 2534050561); v.setBlock(2, 58941359); v.setBlock(3, 3947182061); v.setBlock(4, 1590193474); v.setBlock(5, 3281460096); v.setBlock(6, 2038674258); v.setBlock(7, 819268818); - EXPECT_EQ(v, "0b0011000011010101000011001101001001111001100000111011001101010010110000111001011100011011100000000101111011001000011011010100001011101011010001010011011111101101000000111000001101011111101011111001011100001010100010110000000110010011101101100001000110011110"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 4033279119); v.setBlock(1, 338923298); v.setBlock(2, 390001710); v.setBlock(3, 3835457473); v.setBlock(4, 3120284392); v.setBlock(5, 2317025340); v.setBlock(6, 1580558798); v.setBlock(7, 424692813); - EXPECT_EQ(v, "0b0001100101010000010011000100110101011110001101010110100111001110100010100001101100000000001111001011100111111011110000101110100011100100100111000110111111000001000101110011111011110100001011100001010000110011100011110010001011110000011001101111010010001111"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1683516556); v.setBlock(1, 3950317078); v.setBlock(2, 3806427615); v.setBlock(3, 961832623); v.setBlock(4, 2868767090); v.setBlock(5, 457262732); v.setBlock(6, 2224175541); v.setBlock(7, 378957276); - EXPECT_EQ(v, "0b0001011010010110011011011101110010000100100100100011100110110101000110110100000101000110100011001010101011111101111010010111001000111001010101000110011010101111111000101110000101111001110111111110101101110101000011100001011001100100010110000110110010001100"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1133352752); v.setBlock(1, 3059096484); v.setBlock(2, 2604146896); v.setBlock(3, 2674077280); v.setBlock(4, 246510928); v.setBlock(5, 4113131624); v.setBlock(6, 553565087); v.setBlock(7, 1062874799); - EXPECT_EQ(v, "0b0011111101011010001011101010111100100000111111101011101110011111111101010010100101101000011010000000111010110001011101010101000010011111011000110010111001100000100110110011100000100000110100001011011001010110000110111010010001000011100011011001011100110000"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 2085239680); v.setBlock(1, 1994712778); v.setBlock(2, 3479462472); v.setBlock(3, 623739565); v.setBlock(4, 2417510094); v.setBlock(5, 3795684050); v.setBlock(6, 105387316); v.setBlock(7, 1888000207); - EXPECT_EQ(v, "0b0111000010001000100110001100111100000110010010000001010100110100111000100011110110001010110100101001000000011000010001101100111000100101001011011000001010101101110011110110010001100010010010000111011011100100111001101100101001111100010010100011101110000000"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 1610502617); v.setBlock(1, 2466559644); v.setBlock(2, 2183048355); v.setBlock(3, 3659430499); v.setBlock(4, 1159809795); v.setBlock(5, 1119352621); v.setBlock(6, 107677482); v.setBlock(7, 3872113695); - EXPECT_EQ(v, "0b1110011011001011110001000001111100000110011010110000011100101010010000101011011111110111001011010100010100100001010010110000001111011010000111100111101001100011100000100001111010101100101000111001001100000100101101101001110001011111111111100101000111011001"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3843633955); v.setBlock(1, 4136288623); v.setBlock(2, 3262052056); v.setBlock(3, 1291433090); v.setBlock(4, 1594212682); v.setBlock(5, 2122434418); v.setBlock(6, 2122560054); v.setBlock(7, 2107769694); - EXPECT_EQ(v, "0b0111110110100010000000110101111001111110100000111011001000110110011111101000000111000111011100100101111100000101110000010100101001001100111110011011010010000010110000100110111011110110110110001111011010001010110000010110111111100101000110010011001100100011"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3345606279); v.setBlock(1, 3864257319); v.setBlock(2, 2762524990); v.setBlock(3, 2582001197); v.setBlock(4, 1063343893); v.setBlock(5, 284235248); v.setBlock(6, 3064714409); v.setBlock(7, 3223017443); - EXPECT_EQ(v, "0b1100000000011011010101111110001110110110101010111101010010101001000100001111000100010101111100000011111101100001010101110001010110011001111001100011011000101101101001001010100011001001001111101110011001010011111000110010011111000111011010011110011010000111"); - } - { - Aesi<256> v = 0; - v.setBlock(0, 3805244152); v.setBlock(1, 697534818); v.setBlock(2, 2964653839); v.setBlock(3, 202322536); v.setBlock(4, 2921359744); v.setBlock(5, 1197838687); v.setBlock(6, 1881520378); v.setBlock(7, 227742533); - EXPECT_EQ(v, "0b0000110110010011000100110100010101110000001001011011100011111010010001110110010110010001010111111010111000100000011010011000000000001100000011110011001001101000101100001011010100000111000011110010100110010011100010010110001011100010110011110110101011111000"); - } - - { - Aesi<256> v = "0b1000000111111000101101001110100011111110111001010010100110101110100100010110111110000110100110011111011110100010111000000000101100011000000000001110110110110110001111010100000110100000111010101101010110111010110111100011010101110011101110100011001000110001"; - EXPECT_EQ(v.getBlock(0), 1941582385); EXPECT_EQ(v.getBlock(1), 3585793589); EXPECT_EQ(v.getBlock(2), 1027711210); EXPECT_EQ(v.getBlock(3), 402714038); EXPECT_EQ(v.getBlock(4), 4154646539); EXPECT_EQ(v.getBlock(5), 2440005273); EXPECT_EQ(v.getBlock(6), 4276431278); EXPECT_EQ(v.getBlock(7), 2180560104); - } -} - -TEST(Bitwise, CountBitsBytes) { - const auto timeStart = std::chrono::system_clock::now(); - - { - Aesi512 m = 0; EXPECT_EQ(m.bitCount(), 0); EXPECT_EQ(m.byteCount(), 0); - }{ - Aesi512 m = "8125433280239853252548211056150939786662988783355321803610299695202888531280061795935472804268151222945147553964613898040510775501409983."; - EXPECT_EQ(m.bitCount(), 452); EXPECT_EQ(m.byteCount(), 57); - }{ - Aesi512 m = "17574267251873162264218761220759873754600756500939123609416723673535177168061667995476463924261008261536776611267749."; - EXPECT_EQ(m.bitCount(), 383); EXPECT_EQ(m.byteCount(), 48); - }{ - Aesi512 m = "21802890716849309559167483785510602695344058930676827225663397326140604460817662307."; - EXPECT_EQ(m.bitCount(), 274); EXPECT_EQ(m.byteCount(), 35); - }{ - Aesi512 m = "131809808420798093069108302425012024571137335830720744893629509248644271768860200114478317853560728340486283732831799757717499791405."; - EXPECT_EQ(m.bitCount(), 436); EXPECT_EQ(m.byteCount(), 55); - }{ - Aesi512 m = "433465209374823396906000597351582380255601365637951225491."; - EXPECT_EQ(m.bitCount(), 189); EXPECT_EQ(m.byteCount(), 24); - }{ - Aesi512 m = "2629456433952760142429083664445582597876949492372857231139584353910376944544651100012259827002301897509955630054342321196527349466023286261."; - EXPECT_EQ(m.bitCount(), 460); EXPECT_EQ(m.byteCount(), 58); - }{ - Aesi512 m = "96406040941996537769947305839001509182667236508149012765337105619119234275587188230156962357657907962935261056152266015569090413578126311393192507827."; - EXPECT_EQ(m.bitCount(), 495); EXPECT_EQ(m.byteCount(), 62); - }{ - Aesi512 m = "779975898910398721588512843488292737216066708787279402842479265134130380576933342820188191171817284387486614000372261528684686600311889254943."; - EXPECT_EQ(m.bitCount(), 469); EXPECT_EQ(m.byteCount(), 59); - }{ - Aesi512 m = "235942049152378908081179353103850208970447097919975182053246678543156938370379557034727388517479366065434560109466574006814835006."; - EXPECT_EQ(m.bitCount(), 427); EXPECT_EQ(m.byteCount(), 54); - }{ - Aesi512 m = "201875921226053996734972115605743747569650032938025946229041017159355210997256571122101768564433281896618227162."; - EXPECT_EQ(m.bitCount(), 367); EXPECT_EQ(m.byteCount(), 46); - }{ - Aesi512 m = "15073045815333316943023135965557590030059580430131020419417594043252226785264218082879695545355297413008838849654297643522962831581276346739748452411005."; - EXPECT_EQ(m.bitCount(), 503); EXPECT_EQ(m.byteCount(), 63); - }{ - Aesi512 m = "4779143266357253920771631149725776855741684141203010232217393689880280981988983708."; - EXPECT_EQ(m.bitCount(), 272); EXPECT_EQ(m.byteCount(), 34); - }{ - Aesi512 m = "2073421040132906101606968078759317225438721792138284094607812513052260945297068866042052395426362224798695857992574."; - EXPECT_EQ(m.bitCount(), 380); EXPECT_EQ(m.byteCount(), 48); - }{ - Aesi512 m = "8056659416481504751897050853317416496949290710572167878886003741841335717120626786797209972094490663311696280531."; - EXPECT_EQ(m.bitCount(), 372); EXPECT_EQ(m.byteCount(), 47); - }{ - Aesi512 m = "2142462200685170464758953014183775179871969460337463575081194035221992317627132584005119954695168082695849861091."; - EXPECT_EQ(m.bitCount(), 370); EXPECT_EQ(m.byteCount(), 47); - }{ - Aesi512 m = "62436602421201799605543908261767952405552978341834407578470057072479070877359989051911219180730700900405485784333527578189654108644284314."; - EXPECT_EQ(m.bitCount(), 455); EXPECT_EQ(m.byteCount(), 57); - }{ - Aesi512 m = "8708886923751208896369646390414934986338160207927996314637234694235206909979086845075358681085923263473283036019941211939578987417."; - EXPECT_EQ(m.bitCount(), 432); EXPECT_EQ(m.byteCount(), 54); - }{ - Aesi512 m = "89350417268629761945311302081940817634086062965758014462352660629259870134745."; - EXPECT_EQ(m.bitCount(), 256); EXPECT_EQ(m.byteCount(), 32); - }{ - Aesi512 m = "947042416456442092300475377118864687689487941476858357893004304488139014532690257721893907183506176965809182242."; - EXPECT_EQ(m.bitCount(), 369); EXPECT_EQ(m.byteCount(), 47); - }{ - Aesi512 m = "51023079086295460865928137217812586222771465721882979976763630417920201452678256173660956."; - EXPECT_EQ(m.bitCount(), 295); EXPECT_EQ(m.byteCount(), 37); - }{ - Aesi512 m = "394659189019993910186127325893947611904290244834873046551135935656."; - EXPECT_EQ(m.bitCount(), 218); EXPECT_EQ(m.byteCount(), 28); - }{ - Aesi512 m = "37877413867687525478310222305154391480148401261437989997408830529823347525043333150254230178590071374435760769836732108165534044."; - EXPECT_EQ(m.bitCount(), 424); EXPECT_EQ(m.byteCount(), 53); - }{ - Aesi512 m = "238070679664433351272792579356666604707321803317863286672042730788775395964738812011349334479630745454353018796."; - EXPECT_EQ(m.bitCount(), 367); EXPECT_EQ(m.byteCount(), 46); - }{ - Aesi512 m = "267012496918653157167419170959622614804856381218193711762331242352905645916107540494367875074170692."; - EXPECT_EQ(m.bitCount(), 327); EXPECT_EQ(m.byteCount(), 41); - }{ - Aesi512 m = "1073603691947597544383478242209761023668674955975778069033461724734109933796134001131961241790993489349003858738008559432."; - EXPECT_EQ(m.bitCount(), 399); EXPECT_EQ(m.byteCount(), 50); - }{ - Aesi512 m = "562298521164442233158113896589082715246806788884332216264624631405816988860814005265019204093949261669027769520262704189761495475125709632881919."; - EXPECT_EQ(m.bitCount(), 478); EXPECT_EQ(m.byteCount(), 60); - }{ - Aesi512 m = "4158978421816859451128522099515091277614005938463674827112430404792191330568135712633235561579918390866268466676374544980567880949604447805648565."; - EXPECT_EQ(m.bitCount(), 481); EXPECT_EQ(m.byteCount(), 61); - }{ - Aesi512 m = "14924619216098556351851155524145079961383025330646663269574812166523143205418868252624810697655395."; - EXPECT_EQ(m.bitCount(), 323); EXPECT_EQ(m.byteCount(), 41); - }{ - Aesi512 m = "19263125433922139070353143174488847529421346973177209705127231844581796037119306630930585539489675909638996614473661956001635767638852."; - EXPECT_EQ(m.bitCount(), 443); EXPECT_EQ(m.byteCount(), 56); - }{ - Aesi512 m = "682806395672504228438313395837976674746610475712229974529528356835885995631486207670649897686632166147160247453750254696315344897085670207253."; - EXPECT_EQ(m.bitCount(), 468); EXPECT_EQ(m.byteCount(), 59); - }{ - Aesi512 m = "44165561608214009062731411641807426531080875031708."; - EXPECT_EQ(m.bitCount(), 165); EXPECT_EQ(m.byteCount(), 21); - }{ - Aesi512 m = "1810068275259181735129583643533689916163146029484908317346080710885725781416625194936179579160908146170735805."; - EXPECT_EQ(m.bitCount(), 360); EXPECT_EQ(m.byteCount(), 45); - }{ - Aesi512 m = "22203856399318573146469259769128778849626717054324."; - EXPECT_EQ(m.bitCount(), 164); EXPECT_EQ(m.byteCount(), 21); - }{ - Aesi512 m = "7694432564154108129168181465478548430868392855046604."; - EXPECT_EQ(m.bitCount(), 173); EXPECT_EQ(m.byteCount(), 22); - }{ - Aesi512 m = "1285401729605331393667176392943810500024205211000972253877823290865149302163170008070385888597921032464419651868028052643582626094727703773739."; - EXPECT_EQ(m.bitCount(), 469); EXPECT_EQ(m.byteCount(), 59); - }{ - Aesi512 m = "7965985649459576135397069050747352074976336307021856132905783547305822022499543909128907103263748211242642667."; - EXPECT_EQ(m.bitCount(), 362); EXPECT_EQ(m.byteCount(), 46); - }{ - Aesi512 m = "590007771335133157576169972021585528245811490226372057497198894444640402943288325."; - EXPECT_EQ(m.bitCount(), 269); EXPECT_EQ(m.byteCount(), 34); - }{ - Aesi512 m = "503140962366666306559517743623355538379506158349730754767227786462059097766284010030410635094454058647949382107093092344428041640646540768699921800282."; - EXPECT_EQ(m.bitCount(), 498); EXPECT_EQ(m.byteCount(), 63); - }{ - Aesi512 m = "3384777352685069629216151157031766989015071181826830603580543832463469699978010082081."; - EXPECT_EQ(m.bitCount(), 281); EXPECT_EQ(m.byteCount(), 36); - }{ - Aesi512 m = "7664372817785990326514266663237307917142062491158403533767880373365052616667133649."; - EXPECT_EQ(m.bitCount(), 273); EXPECT_EQ(m.byteCount(), 35); - }{ - Aesi512 m = "334215638884608286471654924286086692624854."; - EXPECT_EQ(m.bitCount(), 138); EXPECT_EQ(m.byteCount(), 18); - }{ - Aesi512 m = "34080246917087621931619781132472798534654778567128547384895677598758."; - EXPECT_EQ(m.bitCount(), 225); EXPECT_EQ(m.byteCount(), 29); - }{ - Aesi512 m = "29652837005697212319365507476545093089128339637930923529833544380900521909328030875059991197894410099757577321170398507."; - EXPECT_EQ(m.bitCount(), 394); EXPECT_EQ(m.byteCount(), 50); - }{ - Aesi512 m = "5507539735498776368361465467701902930055554588691378901463982655670782159582225073135111662243238408663182059630766021416042316106489465754074808853540974."; - EXPECT_EQ(m.bitCount(), 511); EXPECT_EQ(m.byteCount(), 64); - }{ - Aesi512 m = "3004975643443764126226151707508807531199878892716451932163126478736284424236635636281558878832196029."; - EXPECT_EQ(m.bitCount(), 331); EXPECT_EQ(m.byteCount(), 42); - }{ - Aesi512 m = "33813851846197160289962577402206813088513580354756664599207825023964752."; - EXPECT_EQ(m.bitCount(), 235); EXPECT_EQ(m.byteCount(), 30); - }{ - Aesi512 m = "377651090648098570965685387456182588498516."; - EXPECT_EQ(m.bitCount(), 139); EXPECT_EQ(m.byteCount(), 18); - }{ - Aesi512 m = "7410608557526364458156047672247498762540719035935927862959737209627950642463171897639112563283795045371205928539576466838870380014318225241722933868505375."; - EXPECT_EQ(m.bitCount(), 512); EXPECT_EQ(m.byteCount(), 64); - }{ - Aesi512 m = "10044990313301674850074738713697972584889987858."; - EXPECT_EQ(m.bitCount(), 153); EXPECT_EQ(m.byteCount(), 20); - }{ - Aesi512 m = "266099640168931550489566500155710899364300315367325913153890064383032281808."; - EXPECT_EQ(m.bitCount(), 248); EXPECT_EQ(m.byteCount(), 31); - }{ - Aesi512 m = "1482187387782878685086114755119507673273045170923240176317716983194935913741533035499712098299877."; - EXPECT_EQ(m.bitCount(), 320); EXPECT_EQ(m.byteCount(), 40); - }{ - Aesi512 m = "1173795849701350193393898818464811973771747962148586952799081909088."; - EXPECT_EQ(m.bitCount(), 220); EXPECT_EQ(m.byteCount(), 28); - }{ - Aesi512 m = "1075760111541429825505644691336694226487310."; - EXPECT_EQ(m.bitCount(), 140); EXPECT_EQ(m.byteCount(), 18); - }{ - Aesi512 m = "45171859382745997119719399550040468527765767975014522226860885063314372527502004679908084036170446028018456989547511984231472473256392440632."; - EXPECT_EQ(m.bitCount(), 464); EXPECT_EQ(m.byteCount(), 58); - }{ - Aesi512 m = "3550083230609724792508047331304227753793138230616730680629604946225570522563666068400196764430870432027087067680305391."; - EXPECT_EQ(m.bitCount(), 391); EXPECT_EQ(m.byteCount(), 49); - }{ - Aesi512 m = "238597071144511397377349027982816966185598914027694352122412323366822958481130189865972825210896."; - EXPECT_EQ(m.bitCount(), 317); EXPECT_EQ(m.byteCount(), 40); - }{ - Aesi512 m = "585583350737808456521626773441702619917565834."; - EXPECT_EQ(m.bitCount(), 149); EXPECT_EQ(m.byteCount(), 19); - }{ - Aesi512 m = "36049165193710656383674476318098849309081833966574925144648178032947125994642089205867044968998920577865084298839120084785200."; - EXPECT_EQ(m.bitCount(), 414); EXPECT_EQ(m.byteCount(), 52); - }{ - Aesi512 m = "19234485954353740431198448391386775220848294547901362245689574."; - EXPECT_EQ(m.bitCount(), 204); EXPECT_EQ(m.byteCount(), 26); - }{ - Aesi512 m = "14427157670805621590883010144772437273027."; - EXPECT_EQ(m.bitCount(), 134); EXPECT_EQ(m.byteCount(), 17); - }{ - Aesi512 m = "294592116837137192128962078358363421245896052688274598857112028471180048502021366005547689198067574009837."; - EXPECT_EQ(m.bitCount(), 348); EXPECT_EQ(m.byteCount(), 44); - }{ - Aesi512 m = "78014649575862615159507540438874452796220617919545457775300748208619982480459908586326061058242840934850085928995554769357091592190."; - EXPECT_EQ(m.bitCount(), 435); EXPECT_EQ(m.byteCount(), 55); - }{ - Aesi512 m = "4790741095386749449906937030566866031746046169304656278584923858487306270948959401572155081456882084125079092127248920113."; - EXPECT_EQ(m.bitCount(), 401); EXPECT_EQ(m.byteCount(), 51); - }{ - Aesi512 m = "633161550773844933515432109510252603991101078804467201160861966691510376183451."; - EXPECT_EQ(m.bitCount(), 259); EXPECT_EQ(m.byteCount(), 33); - }{ - Aesi512 m = "60122452179660513236341354307732611719576507171909615307390365442026320913187824739846223109852159341204602037787795321449601183014848534293967195178."; - EXPECT_EQ(m.bitCount(), 495); EXPECT_EQ(m.byteCount(), 62); - }{ - Aesi512 m = "161995631938575534869925629985890633415808895867596764222761722202191754575."; - EXPECT_EQ(m.bitCount(), 247); EXPECT_EQ(m.byteCount(), 31); - }{ - Aesi512 m = "911446817435997746933062831691885516611915352665999458511930156309284363237318454237971176312159689716360014561389228715376718662509862481060645832339."; - EXPECT_EQ(m.bitCount(), 499); EXPECT_EQ(m.byteCount(), 63); - }{ - Aesi512 m = "6823785331803106103597794618266911145262172838581223."; - EXPECT_EQ(m.bitCount(), 173); EXPECT_EQ(m.byteCount(), 22); - }{ - Aesi512 m = "155239918270315971266524910862097900140673811776184706157309200861937455."; - EXPECT_EQ(m.bitCount(), 237); EXPECT_EQ(m.byteCount(), 30); - }{ - Aesi512 m = "31791717464914174502002045742730878568603229720932639534325451917358893334089540214885596440815774662097524."; - EXPECT_EQ(m.bitCount(), 354); EXPECT_EQ(m.byteCount(), 45); - }{ - Aesi512 m = "1003586762829871808712634204549567450358275489539260017484895107722613982163260348845481532808575114339347311595215."; - EXPECT_EQ(m.bitCount(), 379); EXPECT_EQ(m.byteCount(), 48); - }{ - Aesi512 m = "4880164245754362338097205112813929292550604675359560497016587."; - EXPECT_EQ(m.bitCount(), 202); EXPECT_EQ(m.byteCount(), 26); - }{ - Aesi512 m = "19749483887303390161030962495768683795272790."; - EXPECT_EQ(m.bitCount(), 144); EXPECT_EQ(m.byteCount(), 18); - }{ - Aesi512 m = "63148738539734553392341133462985836036740639371798360597452567097525683306066658917516309566802305685801145960072360549701."; - EXPECT_EQ(m.bitCount(), 405); EXPECT_EQ(m.byteCount(), 51); - }{ - Aesi512 m = "107590342114875162918348472307699251018874103592474832066873484053754113708388326214150395."; - EXPECT_EQ(m.bitCount(), 296); EXPECT_EQ(m.byteCount(), 37); - }{ - Aesi512 m = "6698953979797583020827904972213947616977062455698932958829035301051011495115."; - EXPECT_EQ(m.bitCount(), 252); EXPECT_EQ(m.byteCount(), 32); - }{ - Aesi512 m = "5430207379526057381214725804197658314755709506858996920618690886502342024339746344612062226768199148738037128023372725688185796337503888328."; - EXPECT_EQ(m.bitCount(), 461); EXPECT_EQ(m.byteCount(), 58); - }{ - Aesi512 m = "48581874368844478342704760472464069633282490659897264814743946699473."; - EXPECT_EQ(m.bitCount(), 225); EXPECT_EQ(m.byteCount(), 29); - }{ - Aesi512 m = "125649816413620037750566080548892812403575569822422682828388593453790534195113364133371382224759702685614495034150."; - EXPECT_EQ(m.bitCount(), 376); EXPECT_EQ(m.byteCount(), 47); - }{ - Aesi512 m = "9090966395883606169412743491416218582727668678050520137422123160210277873679028562444511041122860878620562547703977100496584276850469220021458."; - EXPECT_EQ(m.bitCount(), 472); EXPECT_EQ(m.byteCount(), 59); - }{ - Aesi512 m = "174662122049287992457319598417451937883451980333462349197."; - EXPECT_EQ(m.bitCount(), 187); EXPECT_EQ(m.byteCount(), 24); - }{ - Aesi512 m = "813507411993390554879828672051435218814298367924349835202824439987190213087714864429892828655932570189200528471003010841188643835728860126206357."; - EXPECT_EQ(m.bitCount(), 479); EXPECT_EQ(m.byteCount(), 60); - }{ - Aesi512 m = "318619099993310255354692135487104214301662979."; - EXPECT_EQ(m.bitCount(), 148); EXPECT_EQ(m.byteCount(), 19); - }{ - Aesi512 m = "1777693857708080545844538076702187890341442968457518484."; - EXPECT_EQ(m.bitCount(), 181); EXPECT_EQ(m.byteCount(), 23); - }{ - Aesi512 m = "3204193290698947238931672972341151508380406116470290072152808452149735241615."; - EXPECT_EQ(m.bitCount(), 251); EXPECT_EQ(m.byteCount(), 32); - }{ - Aesi512 m = "1307947124275081320267802092014598881787726639944553485813418415062992248276001190919512309616545929415598763."; - EXPECT_EQ(m.bitCount(), 360); EXPECT_EQ(m.byteCount(), 45); - }{ - Aesi512 m = "28534850101898570474710141413913927972313704060038621588874963."; - EXPECT_EQ(m.bitCount(), 205); EXPECT_EQ(m.byteCount(), 26); - }{ - Aesi512 m = "186547211011565960360834677399752966883178428551654724629512194266072930."; - EXPECT_EQ(m.bitCount(), 237); EXPECT_EQ(m.byteCount(), 30); - }{ - Aesi512 m = "1369416445055542330663441898194145697102539611876570531."; - EXPECT_EQ(m.bitCount(), 180); EXPECT_EQ(m.byteCount(), 23); - }{ - Aesi512 m = "6148572308034937684753221787621890260678881623206328037140328020336862939698811176604453648297521709448290."; - EXPECT_EQ(m.bitCount(), 352); EXPECT_EQ(m.byteCount(), 44); - }{ - Aesi512 m = "51821718761454376853562798270553712164259354897877246623891326751545476237393228375021."; - EXPECT_EQ(m.bitCount(), 285); EXPECT_EQ(m.byteCount(), 36); - }{ - Aesi512 m = "444871851149431479626983465266102420775422."; - EXPECT_EQ(m.bitCount(), 139); EXPECT_EQ(m.byteCount(), 18); - }{ - Aesi512 m = "42146200574268847311698523498680873676706783693183222358186972843444316710."; - EXPECT_EQ(m.bitCount(), 245); EXPECT_EQ(m.byteCount(), 31); - }{ - Aesi512 m = "35453974191750223599443971448232408256392725686144289604176002346292."; - EXPECT_EQ(m.bitCount(), 225); EXPECT_EQ(m.byteCount(), 29); - }{ - Aesi512 m = "114399773536456471179538929162643059034663209191754021300097056704143055752447627827621176."; - EXPECT_EQ(m.bitCount(), 296); EXPECT_EQ(m.byteCount(), 37); - }{ - Aesi512 m = "306096489943631752388051638909060328435655026159556576651782659822077606."; - EXPECT_EQ(m.bitCount(), 238); EXPECT_EQ(m.byteCount(), 30); - }{ - Aesi512 m = "847445665267889245456213278113730865596260025864447116412907433580615172641770582449326549958998709878135166809715."; - EXPECT_EQ(m.bitCount(), 379); EXPECT_EQ(m.byteCount(), 48); - }{ - Aesi512 m = "855205585087312211296445789458057963768041132396148430034035722540576391486192631."; - EXPECT_EQ(m.bitCount(), 269); EXPECT_EQ(m.byteCount(), 34); - }{ - Aesi512 m = "7790374562144467155944484053910374470391879335804156417076224."; - EXPECT_EQ(m.bitCount(), 203); EXPECT_EQ(m.byteCount(), 26); - }{ - Aesi512 m = "4798011951051675050122476777454810968720955910594973468568707443382840023724197."; - EXPECT_EQ(m.bitCount(), 262); EXPECT_EQ(m.byteCount(), 33); - } - - - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count());; -} \ No newline at end of file diff --git a/test/bitwise/bitwise_not.cpp b/test/bitwise/bitwise_not.cpp deleted file mode 100644 index 53cac93..0000000 --- a/test/bitwise/bitwise_not.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, NOT) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi256 m0 = "56061994118377870519623994827540022144637583439516706780608137993940235344250"; - EXPECT_EQ(~m0, "0b1000010000001110000010010010100111110110100011100011100001100101110011010110001000110101010100001111001010110101000101111100001010101001100101111000000110100011100011011100101100010100001010101110111011111110111000000100101011010100000111011010011010000101"); - Aesi256 m1 = "18115333548358996710198856650207318829658943216941190350770112961088357937855"; - EXPECT_EQ(~m1, "0b1101011111110011000101011010010111001110100001011001101110010111111011011100101011100111111100010111011001001011111100100100001111011001001000001100010110111100000100000101110110001001111100001101110110001000011101100011111011110111011100111100110101000000"); - Aesi256 m2 = "26915489532339146181012835956526500084114019222804949185344513752087487306787"; - EXPECT_EQ(~m2, "0b1100010001111110010111110110111011000111011000101000100110110111011100101001100111001110101101101111000000101101101001100010111010111001110000100101000001001111000000110101000001010101001000001010000011100010111011011001110000000101101101000010001111011100"); - Aesi256 m3 = "67020632481953379840057612720074532798761612809076989335414176843397432096677"; - EXPECT_EQ(~m3, "0b0110101111010011101010101001000110111111111100010010011011011011110000010001101110011010001111100101000101010110011001000110101111001000111110110001010110101000010110000100011000011001100001110000101101110101000100101000111011001111000101111100100001011010"); - Aesi256 m4 = "12130100417959388150930683927471550939688339743571091538919518888425306008613"; - EXPECT_EQ(~m4, "0b1110010100101110100110110100000100110110011001011011101010110010111011011111011000111101000101110101101000000100100100000110001011101001001010111010000000100111000111011100010101100101011111000011000110101111100011010000011010111100010101101101001111011010"); - Aesi256 m5 = "74946925134150030934608919408678270238324247166299616025146476277034776193627"; - EXPECT_EQ(~m5, "0b0101101001001101100010110010101100101100010010100110010000000000101110111111111011000011101101010100010110101011111000000100001100100000100010110111101010101100100111001010011001101001110001010011100100100111110011110000110101011010110101010001010110100100"); - Aesi256 m6 = "68983978300932104411040202675875861224670399956393263103077901833987747447952"; - EXPECT_EQ(~m6, "0b0110011101111100011100111011000111011111011110011010101100000001110011110011110000001101100001110010001110110101110100111011111001000001110110011001001110100110011110111001111101000011100110001101001011111011101110110100000010101111011111000111101101101111"); - Aesi256 m7 = "87153082147613350835286450715993962610660651334278474478125299197982166807518"; - EXPECT_EQ(~m7, "0b0011111101010001000110101000010001110111100100011000101101111000110100001111110100000101010001111011111101101110011111110000111111000000010100000110100000111000000100011010100011011110000101001111011010010111001001010110100101000110110110110000110000100001"); - Aesi256 m8 = "76317374518129433096060547499728968330758354488869278329590240923527203215757"; - EXPECT_EQ(~m8, "0b0101011101000101111001011001001001010100100101000101001100000101001011111001000110100000101000000110000101100101100111011111111100110101101100010000001001010111101011111100100101101111100101101101111010100100110011100111001011010100111011001010011001110010"); - Aesi256 m9 = "68522416484437883373682117127188926590145758422005372335203141176290319920591"; - EXPECT_EQ(~m9, "0b0110100010000001101011111100100100101000110110100010001011010100011101000011110011100100101001010111110110100001001110010100101001010101010000101100111001100010001011001010001011111100010011110101011101011001011101010011010101101001000110100001001000110000"); - Aesi256 m10 = "88253449392037914083469965098900335496928503823323599250073524079759576055874"; - EXPECT_EQ(~m10, "0b0011110011100010010100010101101011110100111010111000100100111110000100010111100100010100001100111010101010000000100100011000101010000111010000110111010110111001101100100101110101110110110010111001001111101110001101000010111111101101101110110011111110111101"); - Aesi256 m11 = "23857867123896871921935517052189355599993089977130676580542321071193977755388"; - EXPECT_EQ(~m11, "0b1100101101000000111011001111110100110111101100111010011011111011101111000010000110111100100111111010110000101101111111110100001110001100110100001100010000100000100111011001111000001110100001001000000011000111001111000101011101000011001000000110100100000011"); - Aesi256 m12 = "2683084936685342628588305509340346693520238853877816980636071516725031681812"; - EXPECT_EQ(~m12, "0b1111101000010001011011011000000010000000000100111010000111011111101011100011111111101110011000000010000001010101110001010101100010001100111000111110101101011110000011110010110011110101011010101101011011001100111111000011001110010000000011001100000011101011"); - Aesi256 m13 = "22659456112645383774185337880164481916634185571761998969228824808259779894573"; - EXPECT_EQ(~m13, "0b1100110111100111001100111100110000101000010011100000011000011101111100110010101101111110000101000010111101000000010010101001000000111000110011011010011101100101010101011011001111111011111000111101100111110001010101001000001100101101010100101110001011010010"); - Aesi256 m14 = "66806120951990266392033548408039000554992799982975216856866318648041436398347"; - EXPECT_EQ(~m14, "0b0110110001001101000100110101010010011100111101000000110100101010000011100100101011010100110111000100100111111001010011100100110010000111101011010100111001001011101100101010001110000000000111010011111001011111110100011010111111010010100001110011110011110100"); - Aesi256 m15 = "85863036920344967163348613025827549887950384936652682822213762007261253795330"; - EXPECT_EQ(~m15, "0b0100001000101011001111100100100101100010001100001000011110000000111110101011101100110111000001001101101011101101001111101101110011001111000010110000101001000110100111111100011010000111100111110101110110011101000001110001001111111110101111110000000111111101"); - Aesi256 m16 = "19592354793447765571094003836977002485473518548660547489014588311451873918900"; - EXPECT_EQ(~m16, "0b1101010010101111000111101100001011101111110110101110001000100110010010101010011000111100110011111101111010010110001100101000000101101101001110000011100000010011111110011100001001101010101110011011000101001110110011111000111001110011101010101100000001001011"); - Aesi256 m17 = "10117247243047587547221172080296735553432885530414231527199592605215930852261"; - EXPECT_EQ(~m17, "0b1110100110100001110101110100101011111011000010100100001010110101100101011100111001100011001010111110010001000111011001011100011000110011101110001011000010011001001000100001000001000010011011111101101100001010011011011011111111000011010010011101110001011010"); - Aesi256 m18 = "6650810438349338597452743396175633388996894696828446811971435736974817846651"; - EXPECT_EQ(~m18, "0b1111000101001011110001100101001000100110011100101000101011100110001001111011010110000001101101011010101110111000101110111001101101100110001001101001100110001011100101101001111100010000000110100001010011001000110100010011110010100101010011101001101010000100"); - Aesi256 m19 = "71245382150833152943173863498524590891360532700461638226252599928802392646983"; - EXPECT_EQ(~m19, "0b0110001001111100100010101110111100101110001101111100010000011000001100010111110111100011111101101111001010001000110110100011110000100110111001000110010110100101111010010000000011001100011110101011110100100111010001010011001101110101001011000101101010111000"); - Aesi256 m20 = "84101132272460183061434396766091407999828483922059238285045627497408138014724"; - EXPECT_EQ(~m20, "0b0100011000010000011100100010110011110011101111111010010000101110100000010110100111111111101111100110101010100000111100111010100000111000100111110100101111101110101111011111010010000101001001101101010001100011000001011101001110100111110000001000111111111011"); - Aesi256 m21 = "14535316908113296162544965876707156380354011559920908996617997408440699211844"; - EXPECT_EQ(~m21, "0b1101111111011101010011010101101100111000111011000001111010000011000000100011010101110101010110010011011011101100001101100001001110100101000010000010111110101001001011000011101011101111001000010011011000100000110001011011000110100001101000011010111110111011"); - Aesi256 m22 = "83706060792430156321365407413784151455891188454178184460951860542594926196850"; - EXPECT_EQ(~m22, "0b0100011011110000000011000110110010010110110010101001001100011101111000111010001010001011110100001001011011001000101010111000001110101000101000110101110101101010010010110010001110100111101010100111111100010110101101000000100001010111010110001100011110001101"); - Aesi256 m23 = "18608920676670225971199611951798892603958154516711820112924234063521798623032"; - EXPECT_EQ(~m23, "0b1101011011011011101110010110000110101111001101010010010011011011011010000001000001011000001110100100111000110000011111101010110001101101001010000010001010000000000010110101110111011010011100101000110000101111111010011001100011110001011000001111000011000111"); - Aesi256 m24 = "52383890926533074021535725785658437054611006554587179293378084867558055877329"; - EXPECT_EQ(~m24, "0b1000110000101111110001001011011111001000100111001111100000111110111100101001000111011101110110011000000000001111000111101000011010001010001001100010010111110110001100011011011111101100110110111100101000000111001010011000000011010011010101111110010100101110"); - Aesi256 m25 = "57684095032365446377525941992129999442506010221900986997932303991910867576244"; - EXPECT_EQ(~m25, "0b1000000001110111111101011000111100010111010100111101111111000100011101111001101010101010111110000110101111000101111101110001011000011110100101100010000000000000110011110111001100101011010111111111100000100110111010011011001101010010111101010101101001001011"); - Aesi256 m26 = "85256640374051193423393139236227327255116653881761950937061104973683176723809"; - EXPECT_EQ(~m26, "0b0100001110000010011100111001101101100000010100010001111000000010110010101100010000000010100010100000011111000100010110011011100111110011000110101110001001011111011110101010111011110001000000000101000010011101011110011010100110101111000010001010101010011110"); - Aesi256 m27 = "28435189681147286361772230753625333407803292652190677119931102419040833390629"; - EXPECT_EQ(~m27, "0b1100000100100010010000001100001101100011001000101100111100000111101001001111011100011111011001010101100100110001001001011111101011111100010010111111101111000111011101000001001011010101111001000000111010110111010111011100011010011010110101111011011111011010"); - Aesi256 m28 = "84531237193021991029687803409646588703799741526292349838703790884347953525977"; - EXPECT_EQ(~m28, "0b0100010100011101000000111110011011001000110001001111000111001111111010111010101000101010001000101001000111110001000100110100101101010001001001100011101010000000000000110101011011110100001000000011010010011110001111001011001000101101011101000100101100100110"); - Aesi256 m29 = "86546913494278886837761736936709111415403840347721211496422342961787151584586"; - EXPECT_EQ(~m29, "0b0100000010101000001011101101000101110000101010010111001111010011110110101001011011001001011000101011111111101111000000001101000111001011101110011011000011011100000111001100001001100110001111010000100011011000110011100010001100111001011100111111001010110101"); - - -#ifdef NDEBUG - Logging::addRecord("Bitwise_NOT", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} diff --git a/test/bitwise/bitwise_or.cpp b/test/bitwise/bitwise_or.cpp deleted file mode 100644 index 104ac85..0000000 --- a/test/bitwise/bitwise_or.cpp +++ /dev/null @@ -1,420 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, OR) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi < 96 > m0 = 2020645940044775524ULL, m1 = 5357268711087358525ULL; - EXPECT_EQ(m0 | m1, 6798983837096166013); - Aesi < 96 > m2 = 1525558537524866468ULL, m3 = 780162980750373835ULL; - EXPECT_EQ(m2 | m3, 2304716529481809903); - Aesi < 96 > m4 = 5499392792818025779ULL, m5 = 3630553699293589542ULL; - EXPECT_EQ(m4 | m5, 9111861610500060471); - Aesi < 96 > m6 = 8217820161313030374ULL, m7 = 4471571076368997795ULL; - EXPECT_EQ(m6 | m7, 9083690044765232615); - Aesi < 96 > m8 = 5382728063723026549ULL, m9 = 6474072337812696999ULL; - EXPECT_EQ(m8 | m9, 6628118875407826935); - Aesi < 96 > m10 = 5531067238533613298ULL, m11 = 6205920378303271579ULL; - EXPECT_EQ(m10 | m11, 6836429038125307643); - Aesi < 96 > m12 = 726801461705099060ULL, m13 = 7197119885199483082ULL; - EXPECT_EQ(m12 | m13, 7779790748433508350); - Aesi < 96 > m14 = 2857227495610299548ULL, m15 = 6851320276054652512ULL; - EXPECT_EQ(m14 | m15, 9202806212469438204); - Aesi < 96 > m16 = 8647879979545733973ULL, m17 = 7657869608651681530ULL; - EXPECT_EQ(m16 | m17, 8811142956979941375); - Aesi < 96 > m18 = 7993340150400714359ULL, m19 = 5363863660180581854ULL; - EXPECT_EQ(m18 | m19, 7997915288348700671); - Aesi < 96 > m20 = 4407478874354858993ULL, m21 = 2858798932850881759ULL; - EXPECT_EQ(m20 | m21, 4588885444677582847); - Aesi < 96 > m22 = 148798269284364709ULL, m23 = 1937830191614830151ULL; - EXPECT_EQ(m22 | m23, 1942370298493646823); - Aesi < 96 > m24 = 9162479857370113771ULL, m25 = 3760340113672901768ULL; - EXPECT_EQ(m24 | m25, 9164803164194977515); - Aesi < 96 > m26 = 192295714791438702ULL, m27 = 3279685136564267485ULL; - EXPECT_EQ(m26 | m27, 3435098554140178943); - Aesi < 96 > m28 = 624540544870946014ULL, m29 = 5129147622974336686ULL; - EXPECT_EQ(m28 | m29, 5741795781346377470); - Aesi < 96 > m30 = 3917631123186086388ULL, m31 = 3272514707466701547ULL; - EXPECT_EQ(m30 | m31, 4575233676275579903); - Aesi < 96 > m32 = 5834378838445282859ULL, m33 = 5114723924435243853ULL; - EXPECT_EQ(m32 | m33, 6268983122486351727); - Aesi < 96 > m34 = 3924055531914283595ULL, m35 = 5293342119300753052ULL; - EXPECT_EQ(m34 | m35, 9184453447320661727); - Aesi < 96 > m36 = 8301970154162996009ULL, m37 = 4428614890117278083ULL; - EXPECT_EQ(m36 | m37, 9184983549889473451); - Aesi < 96 > m38 = 3615782113039458075ULL, m39 = 5873554648245063345ULL; - EXPECT_EQ(m38 | m39, 8336126617688334267); - - Aesi < 96 > r0 = 2047835587796591202ULL, r1 = 5443049987772906675ULL; - r0 |= r1; EXPECT_EQ(r0, 6911864060667887347); - Aesi < 96 > r2 = 4510151453757533823ULL, r3 = 2286555397785640804ULL; - r2 |= r3; EXPECT_EQ(r2, 4593529636695048063); - Aesi < 96 > r4 = 4388167193733001566ULL, r5 = 8839533454280551609ULL; - r4 |= r5; EXPECT_EQ(r4, 9146237825563950591); - Aesi < 96 > r6 = 9013148001953800496ULL, r7 = 8934686380896798720ULL; - r6 |= r7; EXPECT_EQ(r6, 9223200508427102512); - Aesi < 96 > r8 = 3629301352859462527ULL, r9 = 486578371779714171ULL; - r8 |= r9; EXPECT_EQ(r8, 3953595854238613375); - Aesi < 96 > r10 = 3124590658226067896ULL, r11 = 4571240866427317772ULL; - r10 |= r11; EXPECT_EQ(r10, 4574760016669032380); - Aesi < 96 > r12 = 2012961834446362382ULL, r13 = 1947448811664489642ULL; - r12 |= r13; EXPECT_EQ(r12, 2013102985543729070); - Aesi < 96 > r14 = 292813269398872651ULL, r15 = 7327551113656379806ULL; - r14 |= r15; EXPECT_EQ(r14, 7327630372111117279); - Aesi < 96 > r16 = 8530393272709473230ULL, r17 = 1860394511317219841ULL; - r16 |= r17; EXPECT_EQ(r16, 9219849200781425615); - Aesi < 96 > r18 = 2063171400442100177ULL, r19 = 1870769038441214218ULL; - r18 |= r19; EXPECT_EQ(r18, 2159440800362985947); - Aesi < 96 > r20 = 8117769925308468990ULL, r21 = 6293667702621214049ULL; - r20 |= r21; EXPECT_EQ(r20, 8646803527032528895); - Aesi < 96 > r22 = 2778498898382626760ULL, r23 = 4502673125009460622ULL; - r22 |= r23; EXPECT_EQ(r22, 4539548572356124622); - Aesi < 96 > r24 = 6203857817238052914ULL, r25 = 6439600255934219825ULL; - r24 |= r25; EXPECT_EQ(r24, 6872088209224459827); - Aesi < 96 > r26 = 8327999777747565718ULL, r27 = 2963108099365356848ULL; - r26 |= r27; EXPECT_EQ(r26, 8908119779469819318); - Aesi < 96 > r28 = 8345926349317658801ULL, r29 = 5439611742273630497ULL; - r28 |= r29; EXPECT_EQ(r28, 8935123862071802289); - Aesi < 96 > r30 = 589517085897666687ULL, r31 = 1699142349415543288ULL; - r30 |= r31; EXPECT_EQ(r30, 2287532837244269055); - Aesi < 96 > r32 = 4895087935113931520ULL, r33 = 4397533764706897032ULL; - r32 |= r33; EXPECT_EQ(r32, 9218865872828116872); - Aesi < 96 > r34 = 8787699061185064661ULL, r35 = 6278261499548717087ULL; - r34 |= r35; EXPECT_EQ(r34, 9220273329485446879); - Aesi < 96 > r36 = 3517043394867606010ULL, r37 = 7106425036492048894ULL; - r36 |= r37; EXPECT_EQ(r36, 8277369822149327358); - Aesi < 96 > r38 = 2440620310881118278ULL, r39 = 5365949614884060230ULL; - r38 |= r39; EXPECT_EQ(r38, 7782219880780987462); - - Aesi512 y0 = -7379608232792186683; EXPECT_EQ(y0 | 0, -7379608232792186683); Aesi512 y1 = 2970120816951561012; EXPECT_EQ(y1 | 0, 2970120816951561012); - Aesi512 y2 = -5696220288572448165; EXPECT_EQ(y2 | 0, -5696220288572448165); Aesi512 y3 = 7900362436724175479; EXPECT_EQ(y3 | 0, 7900362436724175479); - Aesi512 y4 = -777376026862911334; EXPECT_EQ(y4 | 0, -777376026862911334); Aesi512 y5 = -2069419668651330974; EXPECT_EQ(y5 | 0, -2069419668651330974); - Aesi512 y6 = 1259778954916885065; EXPECT_EQ(y6 | 0, 1259778954916885065); Aesi512 y7 = -2905725874441331650; EXPECT_EQ(y7 | 0, -2905725874441331650); - Aesi512 y8 = 4879706157249442504; EXPECT_EQ(y8 | 0, 4879706157249442504); Aesi512 y9 = 8027626211878286429; EXPECT_EQ(y9 | 0, 8027626211878286429); - Aesi512 y10 = 570797157455018920; EXPECT_EQ(y10 | 0, 570797157455018920); Aesi512 y11 = -427390551710800597; EXPECT_EQ(y11 | 0, -427390551710800597); - Aesi512 y12 = -2642894643427682157; EXPECT_EQ(y12 | 0, -2642894643427682157); Aesi512 y13 = -2738503629311636134; EXPECT_EQ(y13 | 0, -2738503629311636134); - Aesi512 y14 = 6337689599550252319; EXPECT_EQ(y14 | 0, 6337689599550252319); Aesi512 y15 = -5586759305152622746; EXPECT_EQ(y15 | 0, -5586759305152622746); - Aesi512 y16 = 5456108041498276808; EXPECT_EQ(y16 | 0, 5456108041498276808); Aesi512 y17 = 5452584994720316618; EXPECT_EQ(y17 | 0, 5452584994720316618); - Aesi512 y18 = -2316362324001525966; EXPECT_EQ(y18 | 0, -2316362324001525966); Aesi512 y19 = 7325722336685152086; EXPECT_EQ(y19 | 0, 7325722336685152086); - Aesi512 y20 = 377998544433893902; EXPECT_EQ(y20 | 0, 377998544433893902); Aesi512 y21 = -2465288838779088870; EXPECT_EQ(y21 | 0, -2465288838779088870); - Aesi512 y22 = -5468006971160031732; EXPECT_EQ(y22 | 0, -5468006971160031732); Aesi512 y23 = 3506965552698968660; EXPECT_EQ(y23 | 0, 3506965552698968660); - Aesi512 y24 = -7300963666391738798; EXPECT_EQ(y24 | 0, -7300963666391738798); Aesi512 y25 = 3103134765104197354; EXPECT_EQ(y25 | 0, 3103134765104197354); - Aesi512 y26 = 3165186477704156988; EXPECT_EQ(y26 | 0, 3165186477704156988); Aesi512 y27 = 1709646565921426320; EXPECT_EQ(y27 | 0, 1709646565921426320); - Aesi512 y28 = 1097774869699502254; EXPECT_EQ(y28 | 0, 1097774869699502254); Aesi512 y29 = 2491211643943272387; EXPECT_EQ(y29 | 0, 2491211643943272387); - Aesi512 y30 = -8927353262635906157; EXPECT_EQ(y30 | 0, -8927353262635906157); Aesi512 y31 = -38766286252702324; EXPECT_EQ(y31 | 0, -38766286252702324); - Aesi512 y32 = 5514084479833422753; EXPECT_EQ(y32 | 0, 5514084479833422753); Aesi512 y33 = 2194479717102096810; EXPECT_EQ(y33 | 0, 2194479717102096810); - Aesi512 y34 = 2751242616132452994; EXPECT_EQ(y34 | 0, 2751242616132452994); Aesi512 y35 = -2390446791466101241; EXPECT_EQ(y35 | 0, -2390446791466101241); - Aesi512 y36 = 8822853861241688997; EXPECT_EQ(y36 | 0, 8822853861241688997); Aesi512 y37 = -4950353505985954258; EXPECT_EQ(y37 | 0, -4950353505985954258); - Aesi512 y38 = -8136431100828633976; EXPECT_EQ(y38 | 0, -8136431100828633976); Aesi512 y39 = 8055314313686600301; EXPECT_EQ(y39 | 0, 8055314313686600301); - Aesi512 y40 = 3365309689234796764; EXPECT_EQ(y40 | 0, 3365309689234796764); Aesi512 y41 = 8794773495649163247; EXPECT_EQ(y41 | 0, 8794773495649163247); - Aesi512 y42 = -515275048992317636; EXPECT_EQ(y42 | 0, -515275048992317636); Aesi512 y43 = 3929495410971836324; EXPECT_EQ(y43 | 0, 3929495410971836324); - Aesi512 y44 = 5301875904659701242; EXPECT_EQ(y44 | 0, 5301875904659701242); Aesi512 y45 = -3342985643104422805; EXPECT_EQ(y45 | 0, -3342985643104422805); - Aesi512 y46 = -8770275292430445047; EXPECT_EQ(y46 | 0, -8770275292430445047); Aesi512 y47 = -7256290758481884326; EXPECT_EQ(y47 | 0, -7256290758481884326); - Aesi512 y48 = -6395402439121471762; EXPECT_EQ(y48 | 0, -6395402439121471762); Aesi512 y49 = 8481418200485971540; EXPECT_EQ(y49 | 0, 8481418200485971540); - Aesi512 y50 = -6826837351772736686; EXPECT_EQ(y50 | 0, -6826837351772736686); Aesi512 y51 = 5378333528058019140; EXPECT_EQ(y51 | 0, 5378333528058019140); - Aesi512 y52 = 7949354112667923489; EXPECT_EQ(y52 | 0, 7949354112667923489); Aesi512 y53 = 758475868520796204; EXPECT_EQ(y53 | 0, 758475868520796204); - Aesi512 y54 = -6506001218570206180; EXPECT_EQ(y54 | 0, -6506001218570206180); Aesi512 y55 = -7151596374648398466; EXPECT_EQ(y55 | 0, -7151596374648398466); - Aesi512 y56 = -2312960319391550338; EXPECT_EQ(y56 | 0, -2312960319391550338); Aesi512 y57 = -205899936757631221; EXPECT_EQ(y57 | 0, -205899936757631221); - Aesi512 y58 = -8988800751555513056; EXPECT_EQ(y58 | 0, -8988800751555513056); Aesi512 y59 = -5137089545283585480; EXPECT_EQ(y59 | 0, -5137089545283585480); - -#ifdef NDEBUG - Logging::addRecord("Bitwise_OR", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Bitwise, DifferentPrecisionOR) { - { - Aesi < 384 > first = "46221828550383548671803689981323585789309810345838952982919178641296601829066."; - Aesi < 256 > second = "6200415520367090353171802511135999424687148510071774509794."; - EXPECT_EQ(first | second, "46221828550383548673975434459295650877043740365634515208999257693296983539434."); - - Aesi < 320 > third = "-86582451695755212696197158387178075350298844513431632265869987089621360392922."; - Aesi < 256 > forth = "-136364000506691303813165579161739687768394246053898549458."; - third |= forth; EXPECT_EQ(third, "-86582451695755212696235243530316223704466964855412642128216807575229325769434."); - } - { - Aesi < 384 > first = "-46221828550383548671803689981323585789309810345838952982919178641296601829066."; - Aesi < 256 > second = "6200415520367090353171802511135999424687148510071774509794."; - EXPECT_EQ(first | second, "-46221828550383548673975434459295650877043740365634515208999257693296983539434."); - - Aesi < 320 > third = "86582451695755212696197158387178075350298844513431632265869987089621360392922."; - Aesi < 256 > forth = "-136364000506691303813165579161739687768394246053898549458."; - third |= forth; EXPECT_EQ(third, "86582451695755212696235243530316223704466964855412642128216807575229325769434."); - } - { - Aesi < 352 > first = "-48709546203770858091244258034139682067405085241382288597585194396155623610883."; - Aesi < 288 > second = "1430888126194076391632801377020460168282593925879063994202."; - EXPECT_EQ(first | second, "-48709546203770858092422271568239806411423834826317868858069186933675281735515."); - - Aesi < 448 > third = "-98163424244583349783272619780878624982351029984357235806595480931137289429060."; - Aesi < 256 > forth = "-5387395878352056304235249922650367974608065874012852471206."; - third |= forth; EXPECT_EQ(third, "-98163424244583349785053858691545071466933694342173933201721864217305561163238."); - } - { - Aesi < 352 > first = "69484720740330411164426034664912585846212085398136074828444953194972432897245."; - Aesi < 288 > second = "5583299350392958780179489220763592751535525567357374245815."; - EXPECT_EQ(first | second, "69484720740330411167617108464274767649241311371569910925488368187689221832703."); - - Aesi < 384 > third = "39132688648825796936471201962618052033168559823199788069847595325981593695523."; - Aesi < 224 > forth = "4645766705285778938096989561903058999891365757822266438915."; - third |= forth; EXPECT_EQ(third, "39132688648825796937776121928818921397295301735200952356958947245675257001251."); - } - { - Aesi < 352 > first = "-103738240934674960986379078448802675680236849441138101291684756322516115743178."; - Aesi < 256 > second = "3104939837795390092948498080059892739865457982945428973915."; - EXPECT_EQ(first | second, "-103738240934674960987375200784354913666381582623815177712982280696737183001051."); - - Aesi < 352 > third = "67592052690489413760295375911469011384901557392110257979159386203713187520019."; - Aesi < 192 > forth = "2244334311125138880392089666114494364666751271123312016687."; - third |= forth; EXPECT_EQ(third, "67592052690489413762281502116889598241520278323889624079494910290093634748223."); - } - { - Aesi < 448 > first = "76752495526065054733976248158404938255342790304989726459192902751986165265328."; - Aesi < 192 > second = "495589113104539174595259910369819520346421662335516936504."; - EXPECT_EQ(first | second, "76752495526065054734371823969658243843611548071956984587965024821576146533304."); - - Aesi < 448 > third = "91615730622339808100046881288038243507870144947834578409522955695534720335648."; - Aesi < 288 > forth = "2628201840772295691060081519106483597184126537896522686091."; - third |= forth; EXPECT_EQ(third, "91615730622339808102649310142997501299450239458543659046659364881760067174315."); - } - { - Aesi < 416 > first = "15772200816371374827083903579379733042742697002210598904666923902203206064883."; - Aesi < 256 > second = "5606953445930285552814582169223836594761637526138652234764."; - EXPECT_EQ(first | second, "15772200816371374832591813033648036382261329377098379070436069253199871926015."); - - Aesi < 352 > third = "-36155086291353127922050183020483309168889820971726920810820466138672837990218."; - Aesi < 224 > forth = "3973319801150395844846791049657410769602155620652093548280."; - third |= forth; EXPECT_EQ(third, "-36155086291353127925973409019544171509521851589830011761464577920044546963450."); - } - { - Aesi < 416 > first = "73951008172966829480189659198560292004098601490753413305616876862656954658316."; - Aesi < 288 > second = "-2438438598101727741533547726417552066902648557548502294952."; - EXPECT_EQ(first | second, "73951008172966829481788055228744681933979013899562507028039313162698789679020."); - - Aesi < 384 > third = "-96244525607652019657397679525706089893840544545583852682014251800836043660296."; - Aesi < 224 > forth = "-1676716566652170495098096217737276714945597169092562767824."; - third |= forth; EXPECT_EQ(third, "-96244525607652019659071308559072055944911159516699245203340466659632477102040."); - } - { - Aesi < 320 > first = "49607756871400128259691988893127860722939170577218823462405421709931153689934."; - Aesi < 256 > second = "-1501754870462735612682965440814990895341862671792072070913."; - EXPECT_EQ(first | second, "49607756871400128260697976962362511244370291253405370918550081043953159741263."); - - Aesi < 384 > third = "9815134023030734725212430732083991554256591366529240815547565456373066606614."; - Aesi < 320 > forth = "-16501220801857935205155693691333985220455588310504416603."; - third |= forth; EXPECT_EQ(third, "9815134023030734725212814651579960042917794070560101496450695374407336963423."); - } - { - Aesi < 384 > first = "-68240968110386693298200521965846216919562784333604280415650153946166248501196."; - Aesi < 320 > second = "4674141496001557840032974155124745921873144432523996180794."; - EXPECT_EQ(first | second, "-68240968110386693299279404930231463290279206339400573876039780274547294371838."); - - Aesi < 320 > third = "62235779636897389969954022082309859982355382995056108846294072819268397351985."; - Aesi < 288 > forth = "-4428721367786790329459725032631824837304356848971930532088."; - third |= forth; EXPECT_EQ(third, "62235779636897389973892344077943545666288241523695556944557367452841493003513."); - } - { - Aesi < 320 > first = "-2184376944847706296836680020764739441470522176519261992943353867430934520116."; - Aesi < 256 > second = "-2534931283450050797705226322576285725720697727432116932346."; - EXPECT_EQ(first | second, "-2184376944847706297694938368939370019436398934659209998823995851876162252798."); - - Aesi < 384 > third = "-11916748102685320107134862867047062080014007074073260220966138461055468035460."; - Aesi < 224 > forth = "6200463017497022744115470453921028952333842869379853511795."; - third |= forth; EXPECT_EQ(third, "-11916748102685320112040121515002707157546382842962441646585417834114926378487."); - } - { - Aesi < 384 > first = "-4788419524022100461044907824792354082635339435355079343581184186366074170508."; - Aesi < 224 > second = "-2552736234698278001003834333573584069150673881970426768825."; - EXPECT_EQ(first | second, "-4788419524022100461242030676633276266916085655551915457095012948892252630461."); - - Aesi < 448 > third = "-114494178122579045792130966709935511919715093874598422805214757664769928218209."; - Aesi < 320 > forth = "4437772134380824660882673405088482570029023477697839582426."; - third |= forth; EXPECT_EQ(third, "-114494178122579045792921399456231775556229863779611273246804741948398037323515."); - } - { - Aesi < 416 > first = "21629402376844582370076045237386817018702611235921120697970027560688947743391."; - Aesi < 256 > second = "5955981833897658771555559420670755619257134127332853717385."; - EXPECT_EQ(first | second, "21629402376844582374014971837607203374995512230604195287721202973506683198367."); - - Aesi < 384 > third = "-58604546921252061415782032100651304303740174302683643072590302516636727210849."; - Aesi < 288 > forth = "3364268928260023369081528387542463649733658487351982168682."; - third |= forth; EXPECT_EQ(third, "-58604546921252061416006211205438671594586335236081733057159097040697550535531."); - } - { - Aesi < 448 > first = "-64953783172872426755872097854389709286177075851103824052723103539152973655724."; - Aesi < 224 > second = "-5072458949798190504490040230713471571764591732601447477754."; - EXPECT_EQ(first | second, "-64953783172872426759311221859423170359350700348570621695922238600120408735742."); - - Aesi < 320 > third = "22786756003032093683873517927263446854389776433704376140810581356328900433674."; - Aesi < 288 > forth = "6015017017822749641956970447090175344706659889526689033388."; - third |= forth; EXPECT_EQ(third, "22786756003032093683899097854191717732324870445500928422119538385784323571630."); - } - { - Aesi < 352 > first = "-55807037146456907436280304038943434923897001297786623754309676042096905187612."; - Aesi < 192 > second = "5200358677575514254229678217710032260505787457893262461659."; - EXPECT_EQ(first | second, "-55807037146456907440988729768261078838984799841590042866924272330026299620319."); - - Aesi < 320 > third = "90538376066530682391271822463092534193346867778735978563611969417502732601697."; - Aesi < 224 > forth = "-2104277719799218510703259398255219739007947010794522021150."; - third |= forth; EXPECT_EQ(third, "90538376066530682391676502352418828116162745569557348830345327716620375575935."); - } - { - Aesi < 416 > first = "-54226172443937446348452375347235371352034967670928752408257633950126627010135."; - Aesi < 288 > second = "-200784272764774419612511455957241579372693537980069328091."; - EXPECT_EQ(first | second, "-54226172443937446348453935184923883379176066395436160960687736242917703857887."); - - Aesi < 320 > third = "114737159617371717679531697386187951302288002489683407985764764153775367134069."; - Aesi < 224 > forth = "-2730519406776103682513742995869512131539035411747053111608."; - third |= forth; EXPECT_EQ(third, "114737159617371717681279796080714631241539984714014448536393456468454077766525."); - } - { - Aesi < 448 > first = "20577552298723799323480226921155794363700292859470955136690499977988815050772."; - Aesi < 320 > second = "-1118777258339803894429236210225272961742222347374629174518."; - EXPECT_EQ(first | second, "20577552298723799324292451174236240075368589005293150926860946941947024506102."); - - Aesi < 448 > third = "27725416948270402186852330011774118177371766004042726229237148507598849863807."; - Aesi < 256 > forth = "-3383813184027000226576661107168509956291215759004595454342."; - third |= forth; EXPECT_EQ(third, "27725416948270402190039968776473212078224479317305056229815626650944804844031."); - } - { - Aesi < 352 > first = "89476408807276198713515705367407944704823457666683318660124457972920698219964."; - Aesi < 256 > second = "4374715988925107120043594291070795637447312878094202018780."; - EXPECT_EQ(first | second, "89476408807276198717886589367730077268169351858844638138877705995833758433276."); - - Aesi < 352 > third = "38310965107576982412476086576495230357548336834184741663431989508325596678442."; - Aesi < 192 > forth = "-5656999668023741087166070375102879591942321217448341656231."; - third |= forth; EXPECT_EQ(third, "38310965107576982415729606412591144785252597109336797131614280203162835475375."); - } - { - Aesi < 384 > first = "-45678087558307209439660535455440814752181102150881298259594711296820602260690."; - Aesi < 256 > second = "3059186912956997058217790794018613183180725319047856880183."; - EXPECT_EQ(first | second, "-45678087558307209440457529128118757647719799307770338353546635193733584649975."); - - Aesi < 320 > third = "-47922983542616337641504620496620018763713251892103353673888648761095776543821."; - Aesi < 224 > forth = "637558504026635345817464046312872110472298401627244606456."; - third |= forth; EXPECT_EQ(third, "-47922983542616337641945983076622916682367393197679129724653926050137500203005."); - } - { - Aesi < 448 > first = "64176895496584542219390840923546015397035449210213006070398724456383884636677."; - Aesi < 256 > second = "2355221475889358969523182792329295475072292299469399301998."; - EXPECT_EQ(first | second, "64176895496584542220176355951191731227699854277488089009951896754845470539631."); - - Aesi < 320 > third = "-7224147389265436270624565753871237128106430333047702432559502521448731627600."; - Aesi < 288 > forth = "-2007376267108295903611718178751886564171034390144949850798."; - third |= forth; EXPECT_EQ(third, "-7224147389265436272202732522397367897984396231432327499453747540620682973950."); - } - { - Aesi < 320 > first = "-97677080679810936782563215020262426938529880590218941192297306920273465280392."; - Aesi < 288 > second = "3736661887789896502969813631568716183863896895172322371759."; - EXPECT_EQ(first | second, "-97677080679810936782572847748464650589185491296630158603232876285957933346735."); - - Aesi < 416 > third = "-31300573833219677149573835574932569787808178235803611966995005128651017251649."; - Aesi < 256 > forth = "-3928009971791325414131494380310354755848589661635836772157."; - third |= forth; EXPECT_EQ(third, "-31300573833219677149575585177095791668203254392457242378285907334614981803901."); - } - { - Aesi < 384 > first = "-11446583040090373605475078308686407661253780578535359300478961590761130945324."; - Aesi < 256 > second = "5331833116310608968194825580652912015773026830142893852056."; - EXPECT_EQ(first | second, "-11446583040090373606065102988175644356203462231333614468099675472071170453436."); - - Aesi < 320 > third = "-68707419666393645828147856613241702916226074757284942290924105507272351258859."; - Aesi < 320 > forth = "634429482120836099755533226523752771030237282299204917147."; - third |= forth; EXPECT_EQ(third, "-68707419666393645828543168708992238190447867181001106605380434830896771096571."); - } - { - Aesi < 448 > first = "-70786232019316395353567532124018796960084696721551478628337602460190753675794."; - Aesi < 320 > second = "-206420519447502052802903124914540137035050655734684886034."; - EXPECT_EQ(first | second, "-70786232019316395353763991243690750667799688429456209867279356385737244671506."); - - Aesi < 352 > third = "-101387916587362736665062575606304030726554469973558360563727366205591261557626."; - Aesi < 320 > forth = "3174669512453129202692757243325078657077915945890077758786."; - third |= forth; EXPECT_EQ(third, "-101387916587362736665096392323081749964283085107813164330488857318513271142266."); - } - { - Aesi < 448 > first = "-12257836845708347315435105376582819217967952140211556014384812246525055063506."; - Aesi < 320 > second = "-2114561867474020185579086369377814952356109598680475475138."; - EXPECT_EQ(first | second, "-12257836845708347317548514762049510668256071046372839342419935407542891961810."); - - Aesi < 384 > third = "41304790637645591219569765192040562669010598151199086713963155441207773778044."; - Aesi < 256 > forth = "-3786999049347541291874128925066286530669327729211334335686."; - third |= forth; EXPECT_EQ(third, "41304790637645591220158243912360564083549378493909034914451722796388430273790."); - } - { - Aesi < 448 > first = "-92312462605157059075554709466350354490480144313883935153915729117943182472317."; - Aesi < 288 > second = "-3424500456397332241035183176530331166080182427575291342382."; - EXPECT_EQ(first | second, "-92312462605157059075619075588777857526568569481769256285651993851069992926847."); - - Aesi < 448 > third = "-115121142030112945715856414932761647187564920949771928182256448809279112350693."; - Aesi < 192 > forth = "-4048105763242507991101179290551485826379516109316644289332."; - third |= forth; EXPECT_EQ(third, "-115121142030112945719020269994317243596235416959044648362800664119638554459125."); - } - { - Aesi < 416 > first = "-58842532344869953834913798431591433176671866797521520663556116509745843932542."; - Aesi < 256 > second = "3841468437559600690099540509432251948926313197738666126268."; - EXPECT_EQ(first | second, "-58842532344869953835417487088123362365977360497753335352539717595700647587838."); - - Aesi < 320 > third = "9077470965946562740576211980453256929958789141671945759112295916561828403954."; - Aesi < 320 > forth = "1719779725084143624729572013995929580593409441317974414342."; - third |= forth; EXPECT_EQ(third, "9077470965946562740579499983377940108333121427950324580530280816998740909814."); - } - { - Aesi < 352 > first = "-51949188006887396075993669970515081249227344792528468327298119011573870811469."; - Aesi < 320 > second = "4037737793948045605103363627697909704068440177177399188773."; - EXPECT_EQ(first | second, "-51949188006887396076880434529543831365936166782326260567308031155647684730221."); - - Aesi < 320 > third = "43835758903955456399987053313422411319058636666226381064763263006017702455914."; - Aesi < 320 > forth = "-4849348095756430172446247639060907034975299698442561091373."; - third |= forth; EXPECT_EQ(third, "43835758903955456401660638137463799346212670859439313659807885955970224881519."); - } - { - Aesi < 384 > first = "-75746795937618724268046620241498645056993814350984313049073698481989233847941."; - Aesi < 192 > second = "-5367632638824209373537519320358535926501739130786208254095."; - EXPECT_EQ(first | second, "-75746795937618724271442643478499095845288800813070028863249833165593344192143."); - - Aesi < 352 > third = "41393729978955478773669994604798191776815028444900719502047500428339442384104."; - Aesi < 224 > forth = "1922195532580060323497057557255035354899963026682387949387."; - third |= forth; EXPECT_EQ(third, "41393729978955478773967358746974150481999047572249480445886085743329643659243."); - } - { - Aesi < 416 > first = "111863008462042417575723250523537763271336101872009592716033839401074108922375."; - Aesi < 256 > second = "3975967503264040601026777178697328418658354909589064632092."; - EXPECT_EQ(first | second, "111863008462042417578914388139928151969532970366557260406093708846846720081695."); - - Aesi < 416 > third = "-48681719552384552162546442502439738245450019072171964708233902059119163436636."; - Aesi < 224 > forth = "2886640040143185538237483814058043223994119210293832038933."; - third |= forth; EXPECT_EQ(third, "-48681719552384552164914244315330345107422442354506062224133939165479849950813."); - } - { - Aesi < 448 > first = "-10580832856574864198027337408794828921005421157882618337126725368849199606536."; - Aesi < 256 > second = "-6239589568521130352105003363482510413084902674322909948992."; - EXPECT_EQ(first | second, "-10580832856574864201469329129823901598314681275331801094486317948143935549256."); - - Aesi < 416 > third = "30535789984260392016074862685596499396823165476021293317477511474592054510182."; - Aesi < 256 > forth = "-2987088112933285911887083474739333233444982224787241199069."; - third |= forth; EXPECT_EQ(third, "30535789984260392017461975270820487190068104017097498622511087067336377133055."); - } - { - Aesi < 384 > first = "110242996963396357628456428079916663097795706280827152222256222696414433404339."; - Aesi < 224 > second = "6081186169123916765088928103838213281718969807619852207447."; - EXPECT_EQ(first | second, "110242996963396357629045101018070107919635302724919791789242681674985604277751."); - - Aesi < 384 > third = "111645584922399683188341396160241384529778335894428664867315798697862283131737."; - Aesi < 320 > forth = "2511588231149330796006355168609249633602592616451335203793."; - third |= forth; EXPECT_EQ(third, "111645584922399683188443690289872537333761263335336308661430540664903515765721."); - } - { - Aesi < 448 > first = "-98702638832347071436629865249073568531588714741040267234836238263490835133731."; - Aesi < 192 > second = "-1131340455245014915544397473522356645741877098212966557705."; - EXPECT_EQ(first | second, "-98702638832347071436731304254478274993262172930476438560340492396095468240171."); - - Aesi < 448 > third = "40651179135155448432858702835385710555290544009091205358908779182914920083931."; - Aesi < 192 > forth = "-3994844685394449537328714648200793993619805397935099100188."; - third |= forth; EXPECT_EQ(third, "40651179135155448432907751531949085067073351358277665565741421136551302102495."); - } -} \ No newline at end of file diff --git a/test/bitwise/bitwise_shift.cpp b/test/bitwise/bitwise_shift.cpp deleted file mode 100644 index aa0fe7a..0000000 --- a/test/bitwise/bitwise_shift.cpp +++ /dev/null @@ -1,351 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, LeftShift) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi128 t = 14183932482008727; - EXPECT_EQ(t << 48, "3992422065038923586049945894912"); - - Aesi128 t2 = -51851516069619428; - EXPECT_EQ(t2 << 40, "-57011344836360679021114032128"); - - Aesi128 t3 = 664154091149463552; - EXPECT_EQ(t3 << 32, "2852520100991549003783995392"); - EXPECT_EQ(t3 << 64, "12251480544941320143633640456854700032"); - - Aesi512 m0 = "7611378567734697137"; - EXPECT_EQ(m0 << 0, "7611378567734697137"); - Aesi512 m1 = "-14850715800956435"; - EXPECT_EQ(m1 << 1, "-29701431601912870"); - Aesi512 m2 = "3028070178233437411"; - EXPECT_EQ(m2 << 2, "12112280712933749644"); - Aesi512 m3 = "9209955177909808159"; - EXPECT_EQ(m3 << 3, "73679641423278465272"); - Aesi512 m4 = "7165047339148406389"; - EXPECT_EQ(m4 << 4, "114640757426374502224"); - Aesi512 m5 = "-6626468019145325155"; - EXPECT_EQ(m5 << 5, "-212046976612650404960"); - Aesi512 m6 = "-7243061664548612285"; - EXPECT_EQ(m6 << 6, "-463555946531111186240"); - Aesi512 m7 = "-4116700124356305042"; - EXPECT_EQ(m7 << 7, "-526937615917607045376"); - Aesi512 m8 = "6549960156157611707"; - EXPECT_EQ(m8 << 8, "1676789799976348596992"); - Aesi512 m9 = "-2220785136167096747"; - EXPECT_EQ(m9 << 9, "-1137041989717553534464"); - Aesi512 m10 = "-7483545574330362604"; - EXPECT_EQ(m10 << 10, "-7663150668114291306496"); - Aesi512 m11 = "5261993495534712122"; - EXPECT_EQ(m11 << 11, "10776562678855090425856"); - Aesi512 m12 = "4481097010014354026"; - EXPECT_EQ(m12 << 12, "18354573353018794090496"); - Aesi512 m13 = "6106312505204834006"; - EXPECT_EQ(m13 << 13, "50022912042638000177152"); - Aesi512 m14 = "5040797595058699798"; - EXPECT_EQ(m14 << 14, "82588427797441737490432"); - Aesi512 m15 = "2583471234648375770"; - EXPECT_EQ(m15 << 15, "84655185416957977231360"); - Aesi512 m16 = "-6788631554508561346"; - EXPECT_EQ(m16 << 16, "-444899757556273076371456"); - Aesi512 m17 = "-4757003174447655866"; - EXPECT_EQ(m17 << 17, "-623509920081203149668352"); - Aesi512 m18 = "662716474672706556"; - EXPECT_EQ(m18 << 18, "173727147536601987416064"); - Aesi512 m19 = "5540167296155729817"; - EXPECT_EQ(m19 << 19, "2904643231366895274295296"); - Aesi512 m20 = "-4474265061727718627"; - EXPECT_EQ(m20 << 20, "-4691606961366204287025152"); - Aesi512 m21 = "5969471790508062653"; - EXPECT_EQ(m21 << 21, "12518889704407564608864256"); - Aesi512 m22 = "-5265695256006552653"; - EXPECT_EQ(m22 << 22, "-22085926675049307818688512"); - Aesi512 m23 = "6873645034989426292"; - EXPECT_EQ(m23 << 23, "57660313729672581308481536"); - Aesi512 m24 = "-7905873368535063591"; - EXPECT_EQ(m24 << 24, "-132638545172560365439942656"); - Aesi512 m25 = "-8693228561668035435"; - EXPECT_EQ(m25 << 25, "-291696346632947901577297920"); - Aesi512 m26 = "-7043023364600938157"; - EXPECT_EQ(m26 << 26, "-472649297123826773050523648"); - Aesi512 m27 = "9015025164445810640"; - EXPECT_EQ(m27 << 27, "1209976195434743083219025920"); - Aesi512 m28 = "9196295832952317037"; - EXPECT_EQ(m28 << 28, "2468611865429455050083663872"); - Aesi512 m29 = "8916222897565776331"; - EXPECT_EQ(m29 << 29, "4786860718611420918811983872"); - Aesi512 m30 = "-3572865449040353898"; - EXPECT_EQ(m30 << 30, "-3836335064159168644044029952"); - Aesi512 m31 = "-2302817096154652646"; - EXPECT_EQ(m31 << 31, "-4945262058326960236404932608"); - Aesi512 m32 = "8766205683538466197"; - EXPECT_EQ(m32 << 32, "37650566720807037874116493312"); - Aesi512 m33 = "1266493289020195681"; - EXPECT_EQ(m33 << 33, "10879094513890432666830897152"); - Aesi512 m34 = "-3803022461808819812"; - EXPECT_EQ(m34 << 34, "-65335428397689160387587473408"); - Aesi512 m35 = "2819148680530451735"; - EXPECT_EQ(m35 << 35, "96865211083518737071451668480"); - Aesi512 m36 = "-115014577408934116"; - EXPECT_EQ(m36 << 36, "-7903741576554119143018725376"); - Aesi512 m37 = "5094258238779213589"; - EXPECT_EQ(m37 << 37, "700149521053929002539321131008"); - Aesi512 m38 = "6926579382724352037"; - EXPECT_EQ(m38 << 38, "1903963643004733400429182844928"); - Aesi512 m39 = "-4288188454945410159"; - EXPECT_EQ(m39 << 39, "-2357456534153639180571028488192"); - Aesi512 m40 = "3988053960996393546"; - EXPECT_EQ(m40 << 40, "4384911702313669082627960733696"); - Aesi512 m41 = "-2258729486426273464"; - EXPECT_EQ(m41 << 41, "-4966998668652400866832708272128"); - Aesi512 m42 = "-3570856372627071555"; - EXPECT_EQ(m42 << 42, "-15704792411285977019368310046720"); - Aesi512 m43 = "-5982264275839351161"; - EXPECT_EQ(m43 << 43, "-52620553053714710909654283583488"); - Aesi512 m44 = "3885006050906365667"; - EXPECT_EQ(m44 << 44, "68345749231226682154935199465472"); - Aesi512 m45 = "2053736025208931047"; - EXPECT_EQ(m45 << 45, "72259412483189886271357246767104"); - Aesi512 m46 = "8299788207491102700"; - EXPECT_EQ(m46 << 46, "584045673101733860269708070092800"); - Aesi512 m47 = "-3983710329745327356"; - EXPECT_EQ(m47 << 47, "-560657386143532875868869406752768"); - Aesi512 m48 = "-983082642483429910"; - EXPECT_EQ(m48 << 48, "-276713163897673592691636526120960"); - Aesi512 m49 = "1193608687650818412"; - EXPECT_EQ(m49 << 49, "671941955116301568858476242796544"); - Aesi512 m50 = "-1409637001423648041"; - EXPECT_EQ(m50 << 50, "-1587110168584801164226584152899584"); - Aesi512 m51 = "-2318294309199358223"; - EXPECT_EQ(m51 << 51, "-5220334693522685565061654122594304"); - Aesi512 m52 = "7759206841436993107"; - EXPECT_EQ(m52 << 52, "34944361039786245398611811287171072"); - Aesi512 m53 = "2481279744575149350"; - EXPECT_EQ(m53 << 53, "22349381066141204212750813967155200"); - Aesi512 m54 = "6109086707179308773"; - EXPECT_EQ(m54 << 54, "110051522472107141603454931416645632"); - Aesi512 m55 = "-3627467853719473164"; - EXPECT_EQ(m55 << 55, "-130693302994475777871668478058954752"); - Aesi512 m56 = "5409416572247721086"; - EXPECT_EQ(m56 << 56, "389789543345065958989778025495658496"); - Aesi512 m57 = "-4523803313772409553"; - EXPECT_EQ(m57 << 57, "-651948765382490837066286700183945216"); - Aesi512 m58 = "353876324472099082"; - EXPECT_EQ(m58 << 58, "101997906113778314260086863071019008"); - Aesi512 m59 = "-6294738255972270889"; - EXPECT_EQ(m59 << 59, "-3628669550590915205494791792421240832"); - Aesi512 m60 = "4970526475298684237"; - EXPECT_EQ(m60 << 60, "5730626862589526840406077674002317312"); - Aesi512 m61 = "-5578860993609043904"; - EXPECT_EQ(m61 << 61, "-12863977621488376418595430470787268608"); - Aesi512 m62 = "-9076278761796422038"; - EXPECT_EQ(m62 << 62, "-41856947865126003831195552773520228352"); - Aesi512 m63 = "5117330721373399756"; - EXPECT_EQ(m63 << 63, "47199045078853293325904793862141902848"); - Aesi512 m64 = "-6514032524115553954"; - EXPECT_EQ(m64 << 64, "-120162690860179866772223964920795889664"); - - Aesi < 448 > r0 = 6072323214095036032; - EXPECT_EQ(r0 << 587, 6072323214095036032); - Aesi < 640 > r1 = -8572474764272951220; - EXPECT_EQ(r1 << 771, -8572474764272951220); - Aesi < 320 > r2 = -9038684410537786378; - EXPECT_EQ(r2 << 419, -9038684410537786378); - Aesi < 640 > r3 = 1858310578097034903; - EXPECT_EQ(r3 << 885, 1858310578097034903); - Aesi < 320 > r4 = -1747591025141945043; - EXPECT_EQ(r4 << 373, -1747591025141945043); - Aesi < 576 > r5 = 6464175228791360326; - EXPECT_EQ(r5 << 801, 6464175228791360326); - Aesi < 448 > r6 = 8210083021775260927; - EXPECT_EQ(r6 << 526, 8210083021775260927); - Aesi < 352 > r7 = 9110354989523270182; - EXPECT_EQ(r7 << 524, 9110354989523270182); - Aesi < 512 > r8 = -5765383716230255672; - EXPECT_EQ(r8 << 533, -5765383716230255672); - Aesi < 448 > r9 = 5003573553825361921; - EXPECT_EQ(r9 << 461, 5003573553825361921); - -#ifdef NDEBUG - Logging::addRecord("Bitwise_left_shift", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Bitwise, RightShift) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi128 t = "3992422065038923586049945894912"; - EXPECT_EQ(t >> 48, 14183932482008727); - - Aesi128 t2 = "-57011344836360679021114032128"; - EXPECT_EQ(t2 >> 40, -51851516069619428); - - Aesi128 t3 = "12251480544941320143633640456854700032"; - EXPECT_EQ(t3 >> 32, "2852520100991549003783995392"); - EXPECT_EQ(t3 >> 64, 664154091149463552); - - Aesi512 m0 = "-7012752518397063856"; - EXPECT_EQ(m0 >> 0, "-7012752518397063856"); - Aesi512 m1 = "-509887270435692686"; - EXPECT_EQ(m1 >> 1, "-254943635217846343"); - Aesi512 m2 = "-8184334220959771790"; - EXPECT_EQ(m2 >> 2, "-2046083555239942947"); - Aesi512 m3 = "3351820170374867843"; - EXPECT_EQ(m3 >> 3, "418977521296858480"); - Aesi512 m4 = "4915421088540746270"; - EXPECT_EQ(m4 >> 4, "307213818033796641"); - Aesi512 m5 = "8438204166676859529"; - EXPECT_EQ(m5 >> 5, "263693880208651860"); - Aesi512 m6 = "-2739484334816504925"; - EXPECT_EQ(m6 >> 6, "-42804442731507889"); - Aesi512 m7 = "266001740642782779"; - EXPECT_EQ(m7 >> 7, "2078138598771740"); - Aesi512 m8 = "-1175290871526875389"; - EXPECT_EQ(m8 >> 8, "-4590979966901856"); - Aesi512 m9 = "815008955377970465"; - EXPECT_EQ(m9 >> 9, "1591814365972598"); - Aesi512 m10 = "2344488435310894562"; - EXPECT_EQ(m10 >> 10, "2289539487608295"); - Aesi512 m11 = "-3113852275729656862"; - EXPECT_EQ(m11 >> 11, "-1520435681508621"); - Aesi512 m12 = "434792608945898747"; - EXPECT_EQ(m12 >> 12, "106150539293432"); - Aesi512 m13 = "7322845047111508288"; - EXPECT_EQ(m13 >> 13, "893901983289979"); - Aesi512 m14 = "-1329128847375632490"; - EXPECT_EQ(m14 >> 14, "-81123586875954"); - Aesi512 m15 = "-1460969452823870895"; - EXPECT_EQ(m15 >> 15, "-44585249414790"); - Aesi512 m16 = "5088985740704164933"; - EXPECT_EQ(m16 >> 16, "77651759959475"); - Aesi512 m17 = "8654937513605207048"; - EXPECT_EQ(m17 >> 17, "66031932934610"); - Aesi512 m18 = "-7585990118536899168"; - EXPECT_EQ(m18 >> 18, "-28938255762240"); - Aesi512 m19 = "-9166759203599994615"; - EXPECT_EQ(m19 >> 19, "-17484205634307"); - Aesi512 m20 = "430195421370873728"; - EXPECT_EQ(m20 >> 20, "410266324396"); - Aesi512 m21 = "-6324517206293388887"; - EXPECT_EQ(m21 >> 21, "-3015764811655"); - Aesi512 m22 = "-552186186360978546"; - EXPECT_EQ(m22 >> 22, "-131651445951"); - Aesi512 m23 = "4291161933042871825"; - EXPECT_EQ(m23 >> 23, "511546365385"); - Aesi512 m24 = "5566105157328393012"; - EXPECT_EQ(m24 >> 24, "331765720685"); - Aesi512 m25 = "-447599232970243378"; - EXPECT_EQ(m25 >> 25, "-13339496641"); - Aesi512 m26 = "-6526777808899700007"; - EXPECT_EQ(m26 >> 26, "-97256568206"); - Aesi512 m27 = "5016099065664698267"; - EXPECT_EQ(m27 >> 27, "37372850370"); - Aesi512 m28 = "7433991250555581813"; - EXPECT_EQ(m28 >> 28, "27693775484"); - Aesi512 m29 = "-579349558847605025"; - EXPECT_EQ(m29 >> 29, "-1079122645"); - Aesi512 m30 = "8546705475788830920"; - EXPECT_EQ(m30 >> 30, "7959739748"); - Aesi512 m31 = "3973055550534862666"; - EXPECT_EQ(m31 >> 31, "1850098162"); - Aesi512 m32 = "-7102539187586558083"; - EXPECT_EQ(m32 >> 32, "-1653688770"); - Aesi512 m33 = "-1006163889429665095"; - EXPECT_EQ(m33 >> 33, "-117132892"); - Aesi512 m34 = "6052273411960370380"; - EXPECT_EQ(m34 >> 34, "352288678"); - Aesi512 m35 = "6032708312001015429"; - EXPECT_EQ(m35 >> 35, "175574919"); - Aesi512 m36 = "5302166584191945998"; - EXPECT_EQ(m36 >> 36, "77156678"); - Aesi512 m37 = "6702575940320330704"; - EXPECT_EQ(m37 >> 37, "48767658"); - Aesi512 m38 = "-2726192946820544501"; - EXPECT_EQ(m38 >> 38, "-9917832"); - Aesi512 m39 = "-1707356398469593785"; - EXPECT_EQ(m39 >> 39, "-3105663"); - Aesi512 m40 = "-1068135359883951539"; - EXPECT_EQ(m40 >> 40, "-971463"); - Aesi512 m41 = "-7896452788601812806"; - EXPECT_EQ(m41 >> 41, "-3590890"); - Aesi512 m42 = "1778047024676052239"; - EXPECT_EQ(m42 >> 42, "404281"); - Aesi512 m43 = "1228810500423788634"; - EXPECT_EQ(m43 >> 43, "139699"); - Aesi512 m44 = "4643629888420427605"; - EXPECT_EQ(m44 >> 44, "263959"); - Aesi512 m45 = "5768242547774764105"; - EXPECT_EQ(m45 >> 45, "163943"); - Aesi512 m46 = "2787779154174915047"; - EXPECT_EQ(m46 >> 46, "39616"); - Aesi512 m47 = "121923821763079398"; - EXPECT_EQ(m47 >> 47, "866"); - Aesi512 m48 = "5150859008093854496"; - EXPECT_EQ(m48 >> 48, "18299"); - Aesi512 m49 = "-2641967318352266365"; - EXPECT_EQ(m49 >> 49, "-4693"); - Aesi512 m50 = "-4236919705932143805"; - EXPECT_EQ(m50 >> 50, "-3763"); - Aesi512 m51 = "608702086868244174"; - EXPECT_EQ(m51 >> 51, "270"); - Aesi512 m52 = "557211125845202862"; - EXPECT_EQ(m52 >> 52, "123"); - Aesi512 m53 = "1898146143517035565"; - EXPECT_EQ(m53 >> 53, "210"); - Aesi512 m54 = "2849983067230014139"; - EXPECT_EQ(m54 >> 54, "158"); - Aesi512 m55 = "-7360929843008969715"; - EXPECT_EQ(m55 >> 55, "-204"); - Aesi512 m56 = "3333481632325305337"; - EXPECT_EQ(m56 >> 56, "46"); - Aesi512 m57 = "-7073367381067599246"; - EXPECT_EQ(m57 >> 57, "-49"); - Aesi512 m58 = "-5051357207431141036"; - EXPECT_EQ(m58 >> 58, "-17"); - Aesi512 m59 = "-2098067526904791870"; - EXPECT_EQ(m59 >> 59, "-3"); - Aesi512 m60 = "-7700403146794931890"; - EXPECT_EQ(m60 >> 60, "-6"); - Aesi512 m61 = "-640566444632702690"; - EXPECT_EQ(m61 >> 61, "0"); - Aesi512 m62 = "6071373372689047450"; - EXPECT_EQ(m62 >> 62, "1"); - Aesi512 m63 = "4993416047838457489"; - EXPECT_EQ(m63 >> 63, "0"); - Aesi512 m64 = "-3131877204238914397"; - EXPECT_EQ(m64 >> 64, "0"); - - Aesi < 640 > r0 = -4123752496635792174; - EXPECT_EQ(r0 >> 912, -4123752496635792174); - Aesi < 384 > r1 = 2517497127064487752; - EXPECT_EQ(r1 >> 408, 2517497127064487752); - Aesi < 352 > r2 = 8495228711565174881; - EXPECT_EQ(r2 >> 420, 8495228711565174881); - Aesi < 640 > r3 = 7683298758282245769; - EXPECT_EQ(r3 >> 695, 7683298758282245769); - Aesi < 480 > r4 = -294229487585297021; - EXPECT_EQ(r4 >> 622, -294229487585297021); - Aesi < 480 > r5 = -4587985225776016414; - EXPECT_EQ(r5 >> 664, -4587985225776016414); - Aesi < 352 > r6 = 8028103029153636174; - EXPECT_EQ(r6 >> 469, 8028103029153636174); - Aesi < 448 > r7 = -5190368338978269751; - EXPECT_EQ(r7 >> 581, -5190368338978269751); - Aesi < 480 > r8 = 9183991195476062818; - EXPECT_EQ(r8 >> 585, 9183991195476062818); - Aesi < 320 > r9 = -5895904731635797704; - EXPECT_EQ(r9 >> 434, -5895904731635797704); - -#ifdef NDEBUG - Logging::addRecord("Bitwise_right_shift", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/bitwise/bitwise_xor.cpp b/test/bitwise/bitwise_xor.cpp deleted file mode 100644 index 67d93d9..0000000 --- a/test/bitwise/bitwise_xor.cpp +++ /dev/null @@ -1,451 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Bitwise, XOR) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi < 96 > m0 = 8980983974862324411ULL, m1 = 2275821107446334292ULL; - EXPECT_EQ(m0 ^ m1, 7149335124743143919); - Aesi < 96 > m2 = 5929039959812382730ULL, m3 = 5865990284982001136ULL; - EXPECT_EQ(m2 ^ m3, 225181612106071546); - Aesi < 96 > m4 = 2348733683970235220ULL, m5 = 8037993418087636272ULL; - EXPECT_EQ(m4 ^ m5, 5698408927172019812); - Aesi < 96 > m6 = 4731703132876683316ULL, m7 = 2866670897528785032ULL; - EXPECT_EQ(m6 ^ m7, 7377484497988677820); - Aesi < 96 > m8 = 8846197703556754491ULL, m9 = 89813386367205630ULL; - EXPECT_EQ(m8 ^ m9, 8933757640696032453); - Aesi < 96 > m10 = 6937171463592985735ULL, m11 = 4563941165456893861ULL; - EXPECT_EQ(m10 ^ m11, 6851005267702244130); - Aesi < 96 > m12 = 1518628271953756023ULL, m13 = 3946611315143942938ULL; - EXPECT_EQ(m12 ^ m13, 2582372703773793389); - Aesi < 96 > m14 = 5301450474978658558ULL, m15 = 6723090551834134897ULL; - EXPECT_EQ(m14 ^ m15, 1504129857657110927); - Aesi < 96 > m16 = 4223988422606718532ULL, m17 = 9219199883406280541ULL; - EXPECT_EQ(m16 ^ m17, 5003413861837504793); - Aesi < 96 > m18 = 9014466296910835551ULL, m19 = 8652528329170907179ULL; - EXPECT_EQ(m18 ^ m19, 363144475731926900); - Aesi < 96 > m20 = 6713998067778146158ULL, m21 = 6942300296191815209ULL; - EXPECT_EQ(m20 ^ m21, 4428420511131328839); - Aesi < 96 > m22 = 8176197850194658266ULL, m23 = 8744843587304529273ULL; - EXPECT_EQ(m22 ^ m23, 588947120141754019); - Aesi < 96 > m24 = 7048871244264337309ULL, m25 = 8609093729948658707ULL; - EXPECT_EQ(m24 ^ m25, 1633463262290281358); - Aesi < 96 > m26 = 3411559924976466180ULL, m27 = 8268042228590725135ULL; - EXPECT_EQ(m26 ^ m27, 6766015453006033163); - Aesi < 96 > m28 = 8832732530923275635ULL, m29 = 2160031969745157988ULL; - EXPECT_EQ(m28 ^ m29, 7452844756437940759); - Aesi < 96 > m30 = 1859952019346371937ULL, m31 = 491403244050845705ULL; - EXPECT_EQ(m30 ^ m31, 2242282596984235368); - Aesi < 96 > m32 = 69328175451101827ULL, m33 = 9136904141346616231ULL; - EXPECT_EQ(m32 ^ m33, 9095723631210850596); - Aesi < 96 > m34 = 5519209732596004881ULL, m35 = 1318401553819460099ULL; - EXPECT_EQ(m34 ^ m35, 6833028504770583058); - Aesi < 96 > m36 = 3109216737461888011ULL, m37 = 8347327756193470689ULL; - EXPECT_EQ(m36 ^ m37, 6409047198741757162); - Aesi < 96 > m38 = 6445545695326738505ULL, m39 = 3828317484873197560ULL; - EXPECT_EQ(m38 ^ m39, 7805802279293370289); - - Aesi < 96 > r0 = 9122165470357914114ULL, r1 = 913347652617637195ULL; - r0 ^= r1; EXPECT_EQ(r0, 8229393666183171913); - Aesi < 96 > r2 = 8891362178826352742ULL, r3 = 8120718805155836972ULL; - r2 ^= r3; EXPECT_EQ(r2, 853115956852706378); - Aesi < 96 > r4 = 4170345981088879111ULL, r5 = 8511921372414751734ULL; - r4 ^= r5; EXPECT_EQ(r4, 5746699712049832433); - Aesi < 96 > r6 = 2199662578192301232ULL, r7 = 6665562358360395428ULL; - r6 ^= r7; EXPECT_EQ(r6, 4757508558287172116); - Aesi < 96 > r8 = 1817722836024882476ULL, r9 = 3712305808697824701ULL; - r8 ^= r9; EXPECT_EQ(r8, 3079647677662453905); - Aesi < 96 > r10 = 3847405400368673618ULL, r11 = 2970148324676566177ULL; - r10 ^= r11; EXPECT_EQ(r10, 2043698520350101491); - Aesi < 96 > r12 = 1440385263592145174ULL, r13 = 2670364454407021991ULL; - r12 ^= r13; EXPECT_EQ(r12, 3959311232726246577); - Aesi < 96 > r14 = 1308114057494421891ULL, r15 = 8648522490507570692ULL; - r14 ^= r15; EXPECT_EQ(r14, 7647925461813055367); - Aesi < 96 > r16 = 6425607198590700850ULL, r17 = 8362660867458128108ULL; - r16 ^= r17; EXPECT_EQ(r16, 3252289920464049630); - Aesi < 96 > r18 = 1905324811879118393ULL, r19 = 1207777558113759312ULL; - r18 ^= r19; EXPECT_EQ(r18, 771225598206264937); - Aesi < 96 > r20 = 7522557097996989209ULL, r21 = 3658099529145873901ULL; - r20 ^= r21; EXPECT_EQ(r20, 6530593228804540148); - Aesi < 96 > r22 = 6655607508161154119ULL, r23 = 7527531017527016207ULL; - r22 ^= r23; EXPECT_EQ(r22, 3758920570628011848); - Aesi < 96 > r24 = 2623629862769400602ULL, r25 = 1315083192849878500ULL; - r24 ^= r25; EXPECT_EQ(r24, 3902681645905172222); - Aesi < 96 > r26 = 4420157800326454539ULL, r27 = 7538214389803591162ULL; - r26 ^= r27; EXPECT_EQ(r26, 6181911861934061809); - Aesi < 96 > r28 = 3546712561762565144ULL, r29 = 5025233326456180804ULL; - r28 ^= r29; EXPECT_EQ(r28, 8396191148970208348); - Aesi < 96 > r30 = 8876018422015848960ULL, r31 = 284960104116629356ULL; - r30 ^= r31; EXPECT_EQ(r30, 8708151944349506924); - Aesi < 96 > r32 = 1581905550141243622ULL, r33 = 3640422532779266785ULL; - r32 ^= r33; EXPECT_EQ(r32, 2842175667502682631); - Aesi < 96 > r34 = 3383225491851133179ULL, r35 = 5000179251454908659ULL; - r34 ^= r35; EXPECT_EQ(r34, 7752829254201169928); - Aesi < 96 > r36 = 4476723811974996976ULL, r37 = 1396664004355549946ULL; - r36 ^= r37; EXPECT_EQ(r36, 3261017439913281802); - Aesi < 96 > r38 = 934443020163735547ULL, r39 = 1299518146827248963ULL; - r38 ^= r39; EXPECT_EQ(r38, 2233537094250937016); - - Aesi512 y0 = -6652583106797519413; EXPECT_EQ(y0 ^ 0, -6652583106797519413); Aesi512 y1 = 7735878406530979626; EXPECT_EQ(y1 ^ 0, 7735878406530979626); - Aesi512 y2 = 2162627523902914222; EXPECT_EQ(y2 ^ 0, 2162627523902914222); Aesi512 y3 = 1171815049526031649; EXPECT_EQ(y3 ^ 0, 1171815049526031649); - Aesi512 y4 = 8557217326701597875; EXPECT_EQ(y4 ^ 0, 8557217326701597875); Aesi512 y5 = 5888932561581891950; EXPECT_EQ(y5 ^ 0, 5888932561581891950); - Aesi512 y6 = 5043879029109165922; EXPECT_EQ(y6 ^ 0, 5043879029109165922); Aesi512 y7 = -1454113503148561589; EXPECT_EQ(y7 ^ 0, -1454113503148561589); - Aesi512 y8 = -1459088315943265714; EXPECT_EQ(y8 ^ 0, -1459088315943265714); Aesi512 y9 = 1762258331777406157; EXPECT_EQ(y9 ^ 0, 1762258331777406157); - Aesi512 y10 = -770974676523450011; EXPECT_EQ(y10 ^ 0, -770974676523450011); Aesi512 y11 = -4999307849436956084; EXPECT_EQ(y11 ^ 0, -4999307849436956084); - Aesi512 y12 = 4354598598581085920; EXPECT_EQ(y12 ^ 0, 4354598598581085920); Aesi512 y13 = 148678106723966883; EXPECT_EQ(y13 ^ 0, 148678106723966883); - Aesi512 y14 = -3422048039334349806; EXPECT_EQ(y14 ^ 0, -3422048039334349806); Aesi512 y15 = -3846906216831977821; EXPECT_EQ(y15 ^ 0, -3846906216831977821); - Aesi512 y16 = 1187216367367166461; EXPECT_EQ(y16 ^ 0, 1187216367367166461); Aesi512 y17 = 5696250726926076608; EXPECT_EQ(y17 ^ 0, 5696250726926076608); - Aesi512 y18 = 5163734250655534484; EXPECT_EQ(y18 ^ 0, 5163734250655534484); Aesi512 y19 = -3439774873613818458; EXPECT_EQ(y19 ^ 0, -3439774873613818458); - Aesi512 y20 = -3004398981146302089; EXPECT_EQ(y20 ^ 0, -3004398981146302089); Aesi512 y21 = -2849073514542617295; EXPECT_EQ(y21 ^ 0, -2849073514542617295); - Aesi512 y22 = 4351504996019293703; EXPECT_EQ(y22 ^ 0, 4351504996019293703); Aesi512 y23 = 8648251167683573561; EXPECT_EQ(y23 ^ 0, 8648251167683573561); - Aesi512 y24 = -5738482727104124346; EXPECT_EQ(y24 ^ 0, -5738482727104124346); Aesi512 y25 = -3907626487262575028; EXPECT_EQ(y25 ^ 0, -3907626487262575028); - Aesi512 y26 = 2705074888495144170; EXPECT_EQ(y26 ^ 0, 2705074888495144170); Aesi512 y27 = 4499344126070650797; EXPECT_EQ(y27 ^ 0, 4499344126070650797); - Aesi512 y28 = 3165840682768100164; EXPECT_EQ(y28 ^ 0, 3165840682768100164); Aesi512 y29 = -591438519799156109; EXPECT_EQ(y29 ^ 0, -591438519799156109); - Aesi512 y30 = 1539497900613426651; EXPECT_EQ(y30 ^ 0, 1539497900613426651); Aesi512 y31 = -3815268260161607160; EXPECT_EQ(y31 ^ 0, -3815268260161607160); - Aesi512 y32 = 7440782379717764332; EXPECT_EQ(y32 ^ 0, 7440782379717764332); Aesi512 y33 = -7556059161534389080; EXPECT_EQ(y33 ^ 0, -7556059161534389080); - Aesi512 y34 = -5614644988445039641; EXPECT_EQ(y34 ^ 0, -5614644988445039641); Aesi512 y35 = 3954451072551111104; EXPECT_EQ(y35 ^ 0, 3954451072551111104); - Aesi512 y36 = -1242416396248218622; EXPECT_EQ(y36 ^ 0, -1242416396248218622); Aesi512 y37 = 5680201312284594976; EXPECT_EQ(y37 ^ 0, 5680201312284594976); - Aesi512 y38 = -5454609604686326633; EXPECT_EQ(y38 ^ 0, -5454609604686326633); Aesi512 y39 = -4622311989677889067; EXPECT_EQ(y39 ^ 0, -4622311989677889067); - Aesi512 y40 = -2474115385712135834; EXPECT_EQ(y40 ^ 0, -2474115385712135834); Aesi512 y41 = -8506743866264905679; EXPECT_EQ(y41 ^ 0, -8506743866264905679); - Aesi512 y42 = -7866936034851706220; EXPECT_EQ(y42 ^ 0, -7866936034851706220); Aesi512 y43 = -8806792467525009614; EXPECT_EQ(y43 ^ 0, -8806792467525009614); - Aesi512 y44 = 7503015719520133947; EXPECT_EQ(y44 ^ 0, 7503015719520133947); Aesi512 y45 = 6038827430243272660; EXPECT_EQ(y45 ^ 0, 6038827430243272660); - Aesi512 y46 = -1030896399084174952; EXPECT_EQ(y46 ^ 0, -1030896399084174952); Aesi512 y47 = 5815047418117056630; EXPECT_EQ(y47 ^ 0, 5815047418117056630); - Aesi512 y48 = -5829737776573732504; EXPECT_EQ(y48 ^ 0, -5829737776573732504); Aesi512 y49 = -3908082412208505143; EXPECT_EQ(y49 ^ 0, -3908082412208505143); - Aesi512 y50 = 8241705532620992109; EXPECT_EQ(y50 ^ 0, 8241705532620992109); Aesi512 y51 = 1789725445496298122; EXPECT_EQ(y51 ^ 0, 1789725445496298122); - Aesi512 y52 = 3547088116508155647; EXPECT_EQ(y52 ^ 0, 3547088116508155647); Aesi512 y53 = -845481703297730061; EXPECT_EQ(y53 ^ 0, -845481703297730061); - Aesi512 y54 = 2934222797803673249; EXPECT_EQ(y54 ^ 0, 2934222797803673249); Aesi512 y55 = -2543088764666443823; EXPECT_EQ(y55 ^ 0, -2543088764666443823); - Aesi512 y56 = 2217818106922620497; EXPECT_EQ(y56 ^ 0, 2217818106922620497); Aesi512 y57 = -4137323814594963163; EXPECT_EQ(y57 ^ 0, -4137323814594963163); - Aesi512 y58 = 4814566605532490742; EXPECT_EQ(y58 ^ 0, 4814566605532490742); Aesi512 y59 = -6428660675943912762; EXPECT_EQ(y59 ^ 0, -6428660675943912762); - - Aesi512 e0 = -872399371349274581; EXPECT_EQ(e0 ^ e0, 0); Aesi512 e1 = 4655876137305428030; EXPECT_EQ(e1 ^ e1, 0); - Aesi512 e2 = 4225124115658427348; EXPECT_EQ(e2 ^ e2, 0); Aesi512 e3 = 7088320902054361636; EXPECT_EQ(e3 ^ e3, 0); - Aesi512 e4 = -3418738210646662755; EXPECT_EQ(e4 ^ e4, 0); Aesi512 e5 = 2970064323217158776; EXPECT_EQ(e5 ^ e5, 0); - Aesi512 e6 = -6554273501984264009; EXPECT_EQ(e6 ^ e6, 0); Aesi512 e7 = 3560049859667286910; EXPECT_EQ(e7 ^ e7, 0); - Aesi512 e8 = 2796596525801380326; EXPECT_EQ(e8 ^ e8, 0); Aesi512 e9 = -3680962316551344967; EXPECT_EQ(e9 ^ e9, 0); - Aesi512 e10 = -2275148996157343394; EXPECT_EQ(e10 ^ e10, 0); Aesi512 e11 = 1510963602371676019; EXPECT_EQ(e11 ^ e11, 0); - Aesi512 e12 = 2615335576808209499; EXPECT_EQ(e12 ^ e12, 0); Aesi512 e13 = -5483836872589866918; EXPECT_EQ(e13 ^ e13, 0); - Aesi512 e14 = 7478822047765580133; EXPECT_EQ(e14 ^ e14, 0); Aesi512 e15 = -2123741133112998366; EXPECT_EQ(e15 ^ e15, 0); - Aesi512 e16 = 2660392548653021630; EXPECT_EQ(e16 ^ e16, 0); Aesi512 e17 = -8445326165875817619; EXPECT_EQ(e17 ^ e17, 0); - Aesi512 e18 = 4876777829330614480; EXPECT_EQ(e18 ^ e18, 0); Aesi512 e19 = 8798348075196592505; EXPECT_EQ(e19 ^ e19, 0); - Aesi512 e20 = 3759335478943361691; EXPECT_EQ(e20 ^ e20, 0); Aesi512 e21 = 7476161062704668043; EXPECT_EQ(e21 ^ e21, 0); - Aesi512 e22 = 2878822222492835562; EXPECT_EQ(e22 ^ e22, 0); Aesi512 e23 = -2096225550442118875; EXPECT_EQ(e23 ^ e23, 0); - Aesi512 e24 = 2389137150982677634; EXPECT_EQ(e24 ^ e24, 0); Aesi512 e25 = 977195684750857383; EXPECT_EQ(e25 ^ e25, 0); - Aesi512 e26 = -181765273376632167; EXPECT_EQ(e26 ^ e26, 0); Aesi512 e27 = -6774299673585191159; EXPECT_EQ(e27 ^ e27, 0); - Aesi512 e28 = -4359446246755790347; EXPECT_EQ(e28 ^ e28, 0); Aesi512 e29 = -6889367208525652850; EXPECT_EQ(e29 ^ e29, 0); - Aesi512 e30 = 2532841348560638083; EXPECT_EQ(e30 ^ e30, 0); Aesi512 e31 = -6551650670623996088; EXPECT_EQ(e31 ^ e31, 0); - Aesi512 e32 = -8074970477546236102; EXPECT_EQ(e32 ^ e32, 0); Aesi512 e33 = 6621774932800906521; EXPECT_EQ(e33 ^ e33, 0); - Aesi512 e34 = -203051090539507323; EXPECT_EQ(e34 ^ e34, 0); Aesi512 e35 = -8523904323010071395; EXPECT_EQ(e35 ^ e35, 0); - Aesi512 e36 = -5588016298856232703; EXPECT_EQ(e36 ^ e36, 0); Aesi512 e37 = -3072159085675554861; EXPECT_EQ(e37 ^ e37, 0); - Aesi512 e38 = 4538407123913009898; EXPECT_EQ(e38 ^ e38, 0); Aesi512 e39 = -8678267948539782427; EXPECT_EQ(e39 ^ e39, 0); - Aesi512 e40 = 5580103516555131807; EXPECT_EQ(e40 ^ e40, 0); Aesi512 e41 = -4252781619698947210; EXPECT_EQ(e41 ^ e41, 0); - Aesi512 e42 = -6872747642310508664; EXPECT_EQ(e42 ^ e42, 0); Aesi512 e43 = -7143038148456854072; EXPECT_EQ(e43 ^ e43, 0); - Aesi512 e44 = 7718402901465646931; EXPECT_EQ(e44 ^ e44, 0); Aesi512 e45 = -2283146554465274577; EXPECT_EQ(e45 ^ e45, 0); - Aesi512 e46 = 8271372903316036199; EXPECT_EQ(e46 ^ e46, 0); Aesi512 e47 = 1349821174167213479; EXPECT_EQ(e47 ^ e47, 0); - Aesi512 e48 = 5657399588981528159; EXPECT_EQ(e48 ^ e48, 0); Aesi512 e49 = -2336213843584333446; EXPECT_EQ(e49 ^ e49, 0); - Aesi512 e50 = 7796780472781494262; EXPECT_EQ(e50 ^ e50, 0); Aesi512 e51 = 712989842011531055; EXPECT_EQ(e51 ^ e51, 0); - Aesi512 e52 = 3333140542037539605; EXPECT_EQ(e52 ^ e52, 0); Aesi512 e53 = 8775266287560378042; EXPECT_EQ(e53 ^ e53, 0); - Aesi512 e54 = -2531547591749992014; EXPECT_EQ(e54 ^ e54, 0); Aesi512 e55 = -4358331220058001262; EXPECT_EQ(e55 ^ e55, 0); - Aesi512 e56 = 627142671780653697; EXPECT_EQ(e56 ^ e56, 0); Aesi512 e57 = -478975383411509354; EXPECT_EQ(e57 ^ e57, 0); - Aesi512 e58 = 779413273234111004; EXPECT_EQ(e58 ^ e58, 0); Aesi512 e59 = 2987880071363343624; EXPECT_EQ(e59 ^ e59, 0); - -#ifdef NDEBUG - Logging::addRecord("Bitwise_XOR", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Bitwise, DifferentPrecisionXOR) { - { - Aesi < 448 > first = "-3179857521619637484238747986927154980033758458337296525182790672089056246244."; - Aesi < 288 > second = "-5533784449681278852061514331656626833263004121888632131908."; - EXPECT_EQ(first ^ second, "-3179857521619637485014084370992276992422676982152110142279094461483155695776."); - - Aesi < 416 > third = "-274020239836115431940011776656040618501338662129745246073114940473323523792."; - Aesi < 256 > forth = "-3907991008567283212028595563959962968013689106014038909895."; - third ^= forth; EXPECT_EQ(third, "-274020239836115429570709335640956298643114926790370398629160468050703838487."); - } - { - Aesi < 448 > first = "-44098988525877645387886437347166567702813365595532179779097431633311259488186."; - Aesi < 320 > second = "3534354131407176500805994947148845186193645574505333060497."; - EXPECT_EQ(first ^ second, "-44098988525877645385137535433391499999423275368760800820432166616580599061547."); - - Aesi < 320 > third = "3145126618379139574144790607544817471413323639789049508183305679970207687273."; - Aesi < 320 > forth = "66991002351755223210620150985055498645907353134317074351."; - third ^= forth; EXPECT_EQ(third, "3145126618379139574088582450466030482796584562618368646004971923501753046470."); - } - { - Aesi < 448 > first = "-14368021904913845827095760764406964239842753113421542261479209150649578765569."; - Aesi < 288 > second = "-498745418071599413408605505389886010320020785512859424562."; - EXPECT_EQ(first ^ second, "-14368021904913845827384721904233331845249241917922205669209149902159341349427."); - - Aesi < 384 > third = "-29772370083208158656820951633212619203489647539014778838295836849166551893138."; - Aesi < 256 > forth = "-4699632821134331348763640839601018929161677837571968153277."; - third ^= forth; EXPECT_EQ(third, "-29772370083208158654677955385288450043028670017325907684288990044761835663919."); - } - { - Aesi < 384 > first = "-63956352616214622268384774607904086103658742596606859479634863758158694829562."; - Aesi < 224 > second = "2908790816350979790454282162283424384790761299901562697349."; - EXPECT_EQ(first ^ second, "-63956352616214622271091047593635921646440571027110230321023776834009161988991."); - - Aesi < 320 > third = "-114147842447941408553196604185444481559011804842688383086934120663150726384467."; - Aesi < 288 > forth = "-4383082463925741735706770518132802704572068862785644561118."; - third ^= forth; EXPECT_EQ(third, "-114147842447941408550419867387355839485423818255075517901453923192390582536589."); - } - { - Aesi < 448 > first = "91269328977884516372662562520352552570071259823161411095149666656388038379762."; - Aesi < 288 > second = "1146008996583431140208982075471222282665452696645955741745."; - EXPECT_EQ(first ^ second, "91269328977884516372031520217149298430197152565935933475347794854205641859267."); - - Aesi < 352 > third = "95247181009699450490115958481452273190203959032032615618603904868838198575742."; - Aesi < 320 > forth = "5869892551767738400244831245111321115540754862820737396827."; - third ^= forth; EXPECT_EQ(third, "95247181009699450493956053954741811522994366353039940324060556042988795605541."); - } - { - Aesi < 448 > first = "-7438548282325391860559150295547835725390565035859209488235958114935059206199."; - Aesi < 320 > second = "-1442260574263586776485268035499744454834741611401590336496."; - EXPECT_EQ(first ^ second, "-7438548282325391861115580462051234195051365404837043084065596544273393433543."); - - Aesi < 352 > third = "-59858022913898207239847737374280826888103281430894219245907359653709969931649."; - Aesi < 256 > forth = "6050912656343368400621911653017065864161448053299600116145."; - third ^= forth; EXPECT_EQ(third, "-59858022913898207240184278886073366733624668154096435329709490097237877584944."); - } - { - Aesi < 416 > first = "114216889653717432506948448761204238653938270998706514140194067713783108574831."; - Aesi < 224 > second = "2999683497236945181789030557704938712965290241120462009539."; - EXPECT_EQ(first ^ second, "114216889653717432508366189790359373366878710208890735118819942585630140197548."); - - Aesi < 384 > third = "77609254042607545397349717995444569598315107315666295028581917028371247774266."; - Aesi < 224 > forth = "-4207344216287446072853916296007494580803166573324288512526."; - third ^= forth; EXPECT_EQ(third, "77609254042607545393563541513182036649880726558099863897191081411482458548276."); - } - { - Aesi < 320 > first = "109586265226808486248911061769344550794187251256552645874665079717319926311090."; - Aesi < 256 > second = "6121499926434696004340748522146589658293528248658715325381."; - EXPECT_EQ(first ^ second, "109586265226808486243183270045386306881106920853645984488373155693028495252343."); - - Aesi < 320 > third = "11974407202561979719303645244269208103804810443938426289252938280080906072001."; - Aesi < 288 > forth = "-1716810719556339174718834863262664101860046625237554983326."; - third ^= forth; EXPECT_EQ(third, "11974407202561979720922376172846655867693077224603644167775715832129811340895."); - } - { - Aesi < 416 > first = "-6340517594220183104289441247460414058213989826355852897025849060380245381218."; - Aesi < 320 > second = "2906644158211689113896901117390172112973478826449683611059."; - EXPECT_EQ(first ^ second, "-6340517594220183102267096515196597067512976355089325514198433982580168699345."); - - Aesi < 352 > third = "53561072822619458763935213792395363554870011019811995410013798578174981087174."; - Aesi < 256 > forth = "-6105120170834023382907261389795073830642137393421059562583."; - third ^= forth; EXPECT_EQ(third, "53561072822619458765709474245577276231834741300161977140205003037592897684369."); - } - { - Aesi < 320 > first = "-3497697060155725785486235281195456615574963972794243150378782002178894045459."; - Aesi < 192 > second = "128057515283375020238898814341003849452087595204778571056."; - EXPECT_EQ(first ^ second, "-3497697060155725785606549824923710034572387758852886627864151015587971929123."); - - Aesi < 352 > third = "-101225665448196163583646222271600374897047770083898167665535334893527816454508."; - Aesi < 288 > forth = "5851695208319018015419932819461373292935938187637558785475."; - third ^= forth; EXPECT_EQ(third, "-101225665448196163579388331551432738195604616713689067794391069641489272894639."); - } - { - Aesi < 416 > first = "65004167656690841174706626999933889672108294302303270843027672011710464666022."; - Aesi < 224 > second = "-1243025077294825789612555447213426477529905494851003049289."; - EXPECT_EQ(first ^ second, "65004167656690841175063676954872013417372015576470148256749391973213004451055."); - - Aesi < 448 > third = "12377424605630658178762033818300472461540920033947466610547993219128001828385."; - Aesi < 256 > forth = "4007231143134804401374426256540545783769137368102425763316."; - third ^= forth; EXPECT_EQ(third, "12377424605630658182767528358386061724592357150863968836566997059407654325205."); - } - { - Aesi < 320 > first = "-86118806024233802989558608026890603039362764260412020932991748140092353800863."; - Aesi < 288 > second = "-6156922909607417853799960807220935323246039793130092299660."; - EXPECT_EQ(first ^ second, "-86118806024233802985464428616740879948539575570179371098662340849911089262355."); - - Aesi < 384 > third = "99411515310250768548390580350768770527292041615044628685459302195798122336704."; - Aesi < 320 > forth = "2357066091775141782757821914279336949750155941647800223215."; - third ^= forth; EXPECT_EQ(third, "99411515310250768549172072660774399663587690169218112029116240003548639974447."); - } - { - Aesi < 448 > first = "30673161869447446087710628616293176713571067683470166504762926857499611250773."; - Aesi < 192 > second = "2086762364725935357926874189403209837075137709779509852862."; - EXPECT_EQ(first ^ second, "30673161869447446089547438148610373113657404068061276871708932932774935952107."); - - Aesi < 352 > third = "-18606004061941757684559089369235627286506576219348671817550700698218995290290."; - Aesi < 320 > forth = "2007712654228494578597700462776515414133079442783891300325."; - third ^= forth; EXPECT_EQ(third, "-18606004061941757682594510716044431610790072860373251943240233678904811687767."); - } - { - Aesi < 352 > first = "28289351542428413638056649093536079250855062821388649142803339599426226235365."; - Aesi < 224 > second = "-2756622692924885940520674220176630529075621475460154586687."; - EXPECT_EQ(first ^ second, "28289351542428413640014025927962398073580231786004824456716942071692659708378."); - - Aesi < 416 > third = "32177760742553569526643049849393443524837258038221432539898162317403539052736."; - Aesi < 256 > forth = "4867300341234196538583415668441962554059878465463517097555."; - third ^= forth; EXPECT_EQ(third, "32177760742553569524938826727809170563980273904426579323322200066311562311315."); - } - { - Aesi < 416 > first = "-73949397179831443490161161409930530926481370555899030118416353652880477185519."; - Aesi < 320 > second = "1378153897929082241371021509790661856798205471661757303965."; - EXPECT_EQ(first ^ second, "-73949397179831443489963124906300712665930653832676997403745494013174357092722."); - - Aesi < 416 > third = "65853188090826968330308076741895729884002142943728838242458563266589222320886."; - Aesi < 256 > forth = "-738229036379895933042910421420538087881352551578727742268."; - third ^= forth; EXPECT_EQ(third, "65853188090826968329672794664887202618235736445177456481256875477435895562698."); - } - { - Aesi < 448 > first = "81437156913239400956331548767454825964027849275285571654615160816395604261163."; - Aesi < 224 > second = "291210483635221278667370448706478446868323204890786040449."; - EXPECT_EQ(first ^ second, "81437156913239400956083272133689333980090718164908786035560728125503753450410."); - - Aesi < 352 > third = "-63826226824473130704565945284210924849342895139967320337043051375758750047201."; - Aesi < 320 > forth = "3529018893722821021503353055518307764491102980204076895315."; - third ^= forth; EXPECT_EQ(third, "-63826226824473130701061455298710853530197631453949179316517834810893664933810."); - } - { - Aesi < 352 > first = "2749575869579591329628629964591502015165500707827213567104471828740970969904."; - Aesi < 288 > second = "2911678920176451906885942355407509485204852884872583952392."; - EXPECT_EQ(first ^ second, "2749575869579591329203826522863066444817503875302595518546884711194585678648."); - - Aesi < 320 > third = "-43012010900528730941889803781908157518902156831388190474352149674439111838297."; - Aesi < 320 > forth = "-1955630495501632765094949870378340656532081244018908641924."; - third ^= forth; EXPECT_EQ(third, "-43012010900528730939946624836066107934996410772740244456338824350698174099677."); - } - { - Aesi < 448 > first = "82645724364138123132055837384889626455033423869266189335443260689832426052692."; - Aesi < 320 > second = "2378552689908353339100306766797941886836278724144465919993."; - EXPECT_EQ(first ^ second, "82645724364138123132865079094850790386367721775327029227039778766196628562861."); - - Aesi < 320 > third = "-65946550500353357297136099354099914031702818906061042688963674043975250769223."; - Aesi < 320 > forth = "-1745572081448783477986398824569942805178241380219676491279."; - third ^= forth; EXPECT_EQ(third, "-65946550500353357295488610963433331625328646963246225400363604324122099387208."); - } - { - Aesi < 352 > first = "-26276146569419674529288277161465912892398761765898095030213069395192703127139."; - Aesi < 256 > second = "-5780246864857993287054000139895578072418293929519046753648."; - EXPECT_EQ(first ^ second, "-26276146569419674533348968248500672387940579190809365833899985187382890918675."); - - Aesi < 320 > third = "48263791050037963478014884010701895571265128844352457800460804414924378550076."; - Aesi < 192 > forth = "2318082455823299195677719652341567427509309717528987283624."; - third ^= forth; EXPECT_EQ(third, "48263791050037963478958071872464070149083156196113962091652039759792266846100."); - } - { - Aesi < 384 > first = "96031357767415375111683166504963932533766477968582481170228124524738722534047."; - Aesi < 288 > second = "-3961347553144184275500960695051542046265395832726472706508."; - EXPECT_EQ(first ^ second, "96031357767415375107797681834238487852819378047499308055993682782550299990867."); - - Aesi < 384 > third = "-1541656332023294419039927617059536359269630729027228764980457421500371058563."; - Aesi < 256 > forth = "5176752448613683795935552654989429421451399522491351525774."; - third ^= forth; EXPECT_EQ(third, "-1541656332023294421028849138470606476249024343437759720642088363779981792781."); - } - { - Aesi < 384 > first = "94901637270971671318474898637997958094880595625409687936698108965884030002278."; - Aesi < 288 > second = "2778573104825540177599070888390218846661157776114052156296."; - EXPECT_EQ(first ^ second, "94901637270971671318102636864488431048948488687470447671255984319869719179246."); - - Aesi < 448 > third = "16337798837897417291447994002684014965700528011822036388339889761557514205149."; - Aesi < 224 > forth = "580619006620176335829094100137388914319230593697521957805."; - third ^= forth; EXPECT_EQ(third, "16337798837897417292019991703108853425159528601831973427504761108113427516528."); - } - { - Aesi < 320 > first = "19209640729299931085673249337785947581449107283995375051503436865418453650421."; - Aesi < 192 > second = "3960591960926673276811511147021682479416582490372430379208."; - EXPECT_EQ(first ^ second, "19209640729299931089632596017285470589566340527594670795428691601102693282621."); - - Aesi < 352 > third = "-94313446509853684373232414063588198568349280692486382078090952301584677582095."; - Aesi < 192 > forth = "5848677167581492631887032486688376278599195876282044504405."; - third ^= forth; EXPECT_EQ(third, "-94313446509853684375843118736035081071013234674577983460569609289782556126298."); - } - { - Aesi < 352 > first = "15266383949784996890984071368352160436368034598115907331733717596975510646546."; - Aesi < 320 > second = "-3897124490819619921682028222995909596438647531018520716779."; - EXPECT_EQ(first ^ second, "15266383949784996893573641917527477231446480009768281204151568815515103759097."); - - Aesi < 352 > third = "107916976661968908862023197626605272807363110937187123756980073261436544189233."; - Aesi < 256 > forth = "-4345265053790129409809621498212644821600610930387229933974."; - third ^= forth; EXPECT_EQ(third, "107916976661968908866308947511951264512156804255372810269219088200847681028775."); - } - { - Aesi < 352 > first = "-11960778347456109577076816575072769784515897426595693222021990635046241549173."; - Aesi < 288 > second = "5159243871137294986192744032761676612479968249261053126246."; - EXPECT_EQ(first ^ second, "-11960778347456109581432840986783813264560272422385540577132495058293234638099."); - - Aesi < 320 > third = "96374556157265769577401964640888353033102226767685450393568392159222742125274."; - Aesi < 288 > forth = "1099567263478431999083433604935975567872784936904523931042."; - third ^= forth; EXPECT_EQ(third, "96374556157265769576515414643432437558723494490201376183402676170490131666808."); - } - { - Aesi < 384 > first = "21210017189062563870675417266764464151145812124156987448194812096846278335687."; - Aesi < 288 > second = "-128243119559901777215716808123871146081922842487719066339."; - EXPECT_EQ(first ^ second, "21210017189062563870553454176355423529902317850273759007441668712851976447524."); - - Aesi < 384 > third = "-48727989445331916372580666525793356790269588776865532507353480146791816026765."; - Aesi < 288 > forth = "-1757658821920339410453582721934352836781099295679635019823."; - third ^= forth; EXPECT_EQ(third, "-48727989445331916374281526997489035598537328082932065358108113094599983268514."); - } - { - Aesi < 320 > first = "77250519992308600126649588221030942211235636842482333220550386364626143803296."; - Aesi < 224 > second = "1318036324507742804153107635878390455332046134233995061987."; - EXPECT_EQ(first ^ second, "77250519992308600125380628025492757616028422951196693185009783439721519209795."); - - Aesi < 320 > third = "-67890229666935805288050627706613771253727956534138460667642438447420606290437."; - Aesi < 320 > forth = "820936364922008051879798238888291351799585828242635186828."; - third ^= forth; EXPECT_EQ(third, "-67890229666935805288851114372122306139587254191409540647836215952738553559177."); - } - { - Aesi < 352 > first = "-90473006983603008810776981946961070347219210177360924253323412243003791697170."; - Aesi < 320 > second = "-4283115548412205313120704624605460670685718259838245230848."; - EXPECT_EQ(first ^ second, "-90473006983603008807114814447298988640586032733203153781840201882632591358994."); - - Aesi < 384 > third = "-56073621987417914210492311679179495173984469122489764259950247004470747105877."; - Aesi < 224 > forth = "-4816772669846485604260834224266777736407910096224966739240."; - third ^= forth; EXPECT_EQ(third, "-56073621987417914205691115389804371655402279545793629453134000977666556399485."); - } - { - Aesi < 448 > first = "-83193535780629828813482473320553306090705194973109999428338942404141078521744."; - Aesi < 224 > second = "-1690314085265694176975834022398157864770271982972028888303."; - EXPECT_EQ(first ^ second, "-83193535780629828815160023229271593480644507446949689266072905185025844773759."); - - Aesi < 384 > third = "-49940436120273954283422393760804600306598590122163994506019949013368622247686."; - Aesi < 288 > forth = "769263516266918279747556174867366615623267221838444462154."; - third ^= forth; EXPECT_EQ(third, "-49940436120273954283783354688322117576783303946175975910732141528008046341964."); - } - { - Aesi < 384 > first = "89451077944398504026161757568114570994145873940611634552002638658563226754335."; - Aesi < 288 > second = "4591820560991812797358034372077664626734528262713282120502."; - EXPECT_EQ(first ^ second, "89451077944398504029527565981399840431556675946331504927438261331779407812137."); - - Aesi < 352 > third = "-66282549291636009078051417574105178487893015402408617668283227391535859601499."; - Aesi < 224 > forth = "-568389082961950212184733899439435230753214915176787353646."; - third ^= forth; EXPECT_EQ(third, "-66282549291636009077686852105342182199340638515574798568399505399865336639605."); - } - { - Aesi < 352 > first = "48060135072505190598974202293968033511501917629059956486481039243357978650664."; - Aesi < 192 > second = "4694913037634202575528739587435934550665816594280177198458."; - EXPECT_EQ(first ^ second, "48060135072505190602530461785169171461851163843682018912523382755700189400402."); - - Aesi < 384 > third = "75323385331160001796895636900049014682561705005544415189938137604215021768174."; - Aesi < 320 > forth = "-3484967930148281169805980604707343704097115389040861372555."; - third ^= forth; EXPECT_EQ(third, "75323385331160001800374379031484065288229963472172902652510029146222425009509."); - } - { - Aesi < 320 > first = "109254473891992017158909066089113057924706686383217306075024847704343193572738."; - Aesi < 256 > second = "-3710899057450997415870270912984700338267900780385145001042."; - EXPECT_EQ(first ^ second, "109254473891992017156326472869069674096459368599288936398338959559999188812240."); - - Aesi < 416 > third = "-111270325754917620078207112649584570012154911019360372320003926218076334133596."; - Aesi < 224 > forth = "-3302007719739999073817680359924862347931186235771280429447."; - third ^= forth; EXPECT_EQ(third, "-111270325754917620074907129097920751757009735521451904004540494123803693875419."); - } - { - Aesi < 416 > first = "-110158920207354992921334322361076794696945492738569815695128704954407437615918."; - Aesi < 288 > second = "4844273801817723328025354796919748586575215704029072360614."; - EXPECT_EQ(first ^ second, "-110158920207354992922819270155580045211694811599034036755911557070944407963528."); - - Aesi < 320 > third = "3285826390047916477747590779228864567982795715661285355968136118075611753527."; - Aesi < 288 > forth = "-6066896152594693373644911525357257057680913375667341551901."; - third ^= forth; EXPECT_EQ(third, "3285826390047916483746224340985642559129344452520709776083334040513278493994."); - } -} \ No newline at end of file diff --git a/test/bitwise/manipulations/signed.cpp b/test/bitwise/manipulations/signed.cpp new file mode 100755 index 0000000..b305c61 --- /dev/null +++ b/test/bitwise/manipulations/signed.cpp @@ -0,0 +1,76 @@ +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Bitwise, GetSetBit) { + constexpr auto testsAmount = 2, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? -1 : 1) * Generation::getRandomWithBits(bitness - 20); + Aesi aeu = 1; + for (std::size_t j = 0; j < value.BitCount(); ++j) + aeu.setBit(j, value.GetBit(j)); + if(i % 2 == 0) aeu.inverse(); + EXPECT_EQ(aeu, value); + + aeu = value; + for (std::size_t j = 0; j < value.BitCount(); ++j) + EXPECT_EQ(aeu.getBit(j), value.GetBit(j)); + } +} + +TEST(Signed_Bitwise, GetSetByte) { + constexpr auto testsAmount = 2, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? -1 : 1) * Generation::getRandomWithBits(bitness - 20); + Aesi aeu = 1; + for (std::size_t j = 0; j < value.ByteCount(); ++j) + aeu.setByte(j, value.GetByte(j)); + if(i % 2 == 0) aeu.inverse(); + EXPECT_EQ(aeu, value); + + aeu = value; + for (std::size_t j = 0; j < value.ByteCount(); ++j) + EXPECT_EQ(aeu.getByte(j), value.GetByte(j)); + } +} + +TEST(Signed_Bitwise, GetSetBlock) { + constexpr auto testsAmount = 2, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? -1 : 1) * Generation::getRandomWithBits(bitness - 20); + Aesi aesi = 1; + + const auto totalBlocks = value.ByteCount() / 4, + remainingBytes = value.ByteCount() % 4; + for (std::size_t j = 0; j < totalBlocks; ++j) { + uint32_t block = 0; + for (std::size_t k = 0; k < 5; ++k) { + const auto byte = static_cast(value.GetByte((j + 1) * 4 - k)); + block <<= 8; + block |= byte; + } + aesi.setBlock(j, block); + } + + uint32_t block = 0; + for (std::size_t j = value.ByteCount() - 1; j >= totalBlocks * 4; --j) { + const auto byte = static_cast(value.GetByte(j)); + block <<= 8; + block |= byte; + } + aesi.setBlock(totalBlocks, block); + + if(i % 2 == 0) aesi.inverse(); + + EXPECT_EQ(aesi, value); + } +} + +TEST(Signed_Bitwise, CountBitsBytes) { + constexpr auto testsAmount = 2, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(bitness - 20); + Aesi aeu = value; + EXPECT_EQ(value.BitCount(), aeu.bitCount()); + } +} \ No newline at end of file diff --git a/test/bitwise/manipulations/unsigned.cpp b/test/bitwise/manipulations/unsigned.cpp new file mode 100755 index 0000000..11d6bfa --- /dev/null +++ b/test/bitwise/manipulations/unsigned.cpp @@ -0,0 +1,71 @@ +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Bitwise, GetSetBit) { + constexpr auto testsAmount = 2048, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(bitness - 20); + Aeu aeu {}; + for (std::size_t j = 0; j < value.BitCount(); ++j) + aeu.setBit(j, value.GetBit(j)); + EXPECT_EQ(aeu, value); + + aeu = value; + for (std::size_t j = 0; j < value.BitCount(); ++j) + EXPECT_EQ(aeu.getBit(j), value.GetBit(j)); + } +} + +TEST(Unsigned_Bitwise, GetSetByte) { + constexpr auto testsAmount = 2048, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(bitness - 20); + Aeu aeu {}; + for (std::size_t j = 0; j < value.ByteCount(); ++j) + aeu.setByte(j, value.GetByte(j)); + EXPECT_EQ(aeu, value); + + aeu = value; + for (std::size_t j = 0; j < value.ByteCount(); ++j) + EXPECT_EQ(aeu.getByte(j), value.GetByte(j)); + } +} + +TEST(Unsigned_Bitwise, GetSetBlock) { + constexpr auto testsAmount = 2048, bitness = 256; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(bitness - 20); + Aeu aeu {}; + + const auto totalBlocks = value.ByteCount() / 4; + for (std::size_t j = 0; j < totalBlocks; ++j) { + uint32_t block = 0; + for (std::size_t k = 1; k < 5; ++k) { + const auto byte = static_cast(value.GetByte((j + 1) * 4 - k)); + block <<= 8; + block |= byte; + } + aeu.setBlock(j, block); + } + + uint32_t block = 0; + for (std::size_t j = value.ByteCount() - 1; j >= totalBlocks * 4; --j) { + const auto byte = static_cast(value.GetByte(j)); + block <<= 8; + block |= byte; + } + aeu.setBlock(totalBlocks, block); + + EXPECT_EQ(aeu, value); + } +} + +TEST(Unsigned_Bitwise, CountBitsBytes) { + constexpr auto testsAmount = 2048, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(bitness - 20); + Aeu aeu = value; + EXPECT_EQ(value.BitCount(), aeu.bitCount()); + } +} \ No newline at end of file diff --git a/test/bitwise/not.cpp b/test/bitwise/not.cpp new file mode 100755 index 0000000..8278ccb --- /dev/null +++ b/test/bitwise/not.cpp @@ -0,0 +1,25 @@ +#include +#include +#include "../../Aeu.h" +#include "../../Aesi.h" +#include "../generation.h" + +TEST(Unsigned_Bitwise, NOT) { + constexpr auto testsAmount = 2048, blocksNumber = 8; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto value = Generation::getRandomWithBits(blocksNumber * 32); + if(value.BitCount() < blocksNumber * 32) + value <<= (blocksNumber * 32 - value.BitCount()); + + std::stringstream ss {}; + std::string binary {}; + for (auto byte = static_cast(~value.GetByte(value.ByteCount() - 1)); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << "0b" << std::string(binary.rbegin(), binary.rend()); + for(long long j = value.ByteCount() - 2; j >= 0; --j) + ss << std::bitset<8>(~value.GetByte(j)); + + Aeu aeu = value, notted = ss.str(); + EXPECT_EQ(~aeu, notted); + } +} diff --git a/test/bitwise/or.cpp b/test/bitwise/or.cpp new file mode 100755 index 0000000..b9ba7af --- /dev/null +++ b/test/bitwise/or.cpp @@ -0,0 +1,18 @@ +#include +#include "../../Aeu.h" +#include "../generation.h" + +TEST(Unsigned_Bitwise, OR) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + Aeu left = l, right = r; + EXPECT_EQ(left | right, l | r); + + l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + left = l, right = r; left |= right; + EXPECT_EQ(left, l | r); + } +} \ No newline at end of file diff --git a/test/bitwise/shift.cpp b/test/bitwise/shift.cpp new file mode 100755 index 0000000..fb299b4 --- /dev/null +++ b/test/bitwise/shift.cpp @@ -0,0 +1,29 @@ +#include +#include "../../Aeu.h" +#include "../generation.h" + +TEST(Unsigned_Bitwise, LeftShift) { + constexpr auto testsAmount = 1024, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto value = Generation::getRandomWithBits(512); + Aeu aeu = value; + EXPECT_EQ(aeu << (i + 512), value << (i + 512)); + + value = Generation::getRandomWithBits(512); + aeu = value; aeu <<= (i + 512); + EXPECT_EQ(aeu, value << (i + 512)); + } +} + +TEST(Unsigned_Bitwise, RightShift) { + constexpr auto testsAmount = 1024, bitness = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto value = Generation::getRandomWithBits(1800); + Aeu aeu = value; + EXPECT_EQ(aeu >> (i + 512), value >> (i + 512)); + + value = Generation::getRandomWithBits(1800); + aeu = value; aeu >>= (i + 512); + EXPECT_EQ(aeu, value >> (i + 512)); + } +} \ No newline at end of file diff --git a/test/bitwise/xor.cpp b/test/bitwise/xor.cpp new file mode 100755 index 0000000..b362897 --- /dev/null +++ b/test/bitwise/xor.cpp @@ -0,0 +1,18 @@ +#include +#include "../../Aeu.h" +#include "../generation.h" + +TEST(Unsigned_Bitwise, XOR) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + Aeu left = l, right = r; + EXPECT_EQ(left ^ right, l ^ r); + + l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + left = l, right = r; left ^= right; + EXPECT_EQ(left, l ^ r); + } +} \ No newline at end of file diff --git a/test/boolean/CMakeLists.txt b/test/boolean/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/test/boolean/boolean.cpp b/test/boolean/boolean.cpp deleted file mode 100644 index 809b2a5..0000000 --- a/test/boolean/boolean.cpp +++ /dev/null @@ -1,326 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(Boolean, ThreeWayComparasion) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = 414346834219605873, m1 = 6659613388634065159; EXPECT_EQ(m0 < m1, true); EXPECT_EQ(m0 > m1, false); EXPECT_EQ(m0 == m1, false); - Aesi512 m2 = 3777391648886866941, m3 = 6468128258198177311; EXPECT_EQ(m2 < m3, true); EXPECT_EQ(m2 > m3, false); EXPECT_EQ(m2 == m3, false); - Aesi512 m4 = 4972396199517127393, m5 = 2356794928604248388; EXPECT_EQ(m4 < m5, false); EXPECT_EQ(m4 > m5, true); EXPECT_EQ(m4 == m5, false); - Aesi512 m6 = 5698574201897137468, m7 = 6027866109546041412; EXPECT_EQ(m6 < m7, true); EXPECT_EQ(m6 > m7, false); EXPECT_EQ(m6 == m7, false); - Aesi512 m8 = 7239889242476444263, m9 = 6391130626438688626; EXPECT_EQ(m8 < m9, false); EXPECT_EQ(m8 > m9, true); EXPECT_EQ(m8 == m9, false); - Aesi512 m10 = 3438368610131831025, m11 = 17774641511006347; EXPECT_EQ(m10 < m11, false); EXPECT_EQ(m10 > m11, true); EXPECT_EQ(m10 == m11, false); - Aesi512 m12 = 7403892229775225334, m13 = 4792187032939839463; EXPECT_EQ(m12 < m13, false); EXPECT_EQ(m12 > m13, true); EXPECT_EQ(m12 == m13, false); - Aesi512 m14 = 7063460168526027038, m15 = 7073029733375674038; EXPECT_EQ(m14 < m15, true); EXPECT_EQ(m14 > m15, false); EXPECT_EQ(m14 == m15, false); - Aesi512 m16 = 3276326228016273221, m17 = 4684704472030591797; EXPECT_EQ(m16 < m17, true); EXPECT_EQ(m16 > m17, false); EXPECT_EQ(m16 == m17, false); - Aesi512 m18 = 4347413549370960786, m19 = 8261767534481581646; EXPECT_EQ(m18 < m19, true); EXPECT_EQ(m18 > m19, false); EXPECT_EQ(m18 == m19, false); - Aesi512 m20 = 3217208224507157627, m21 = 5343460665076815773; EXPECT_EQ(m20 < m21, true); EXPECT_EQ(m20 > m21, false); EXPECT_EQ(m20 == m21, false); - Aesi512 m22 = 3553831604978278739, m23 = 1956925562179864685; EXPECT_EQ(m22 < m23, false); EXPECT_EQ(m22 > m23, true); EXPECT_EQ(m22 == m23, false); - Aesi512 m24 = 4421788051285594566, m25 = 1307160148762376915; EXPECT_EQ(m24 < m25, false); EXPECT_EQ(m24 > m25, true); EXPECT_EQ(m24 == m25, false); - Aesi512 m26 = 4941475767464726707, m27 = 5096508184363427411; EXPECT_EQ(m26 < m27, true); EXPECT_EQ(m26 > m27, false); EXPECT_EQ(m26 == m27, false); - Aesi512 m28 = 2557138060934038665, m29 = 2645213282532565144; EXPECT_EQ(m28 < m29, true); EXPECT_EQ(m28 > m29, false); EXPECT_EQ(m28 == m29, false); - Aesi512 m30 = 6288879661041105803, m31 = 6168987288585263111; EXPECT_EQ(m30 < m31, false); EXPECT_EQ(m30 > m31, true); EXPECT_EQ(m30 == m31, false); - Aesi512 m32 = 972058579054229552, m33 = 1137174755634575008; EXPECT_EQ(m32 < m33, true); EXPECT_EQ(m32 > m33, false); EXPECT_EQ(m32 == m33, false); - Aesi512 m34 = 3492684949614696086, m35 = 1363828522052130623; EXPECT_EQ(m34 < m35, false); EXPECT_EQ(m34 > m35, true); EXPECT_EQ(m34 == m35, false); - Aesi512 m36 = 2436944419145784980, m37 = 5304314784521859337; EXPECT_EQ(m36 < m37, true); EXPECT_EQ(m36 > m37, false); EXPECT_EQ(m36 == m37, false); - Aesi512 m38 = 3170900660535921265, m39 = 660482510578155528; EXPECT_EQ(m38 < m39, false); EXPECT_EQ(m38 > m39, true); EXPECT_EQ(m38 == m39, false); - Aesi512 m40 = 3085504072638658500, m41 = 7007133823746771031; EXPECT_EQ(m40 < m41, true); EXPECT_EQ(m40 > m41, false); EXPECT_EQ(m40 == m41, false); - Aesi512 m42 = 3432511087466748985, m43 = 1255067700531598077; EXPECT_EQ(m42 < m43, false); EXPECT_EQ(m42 > m43, true); EXPECT_EQ(m42 == m43, false); - Aesi512 m44 = 7532364332456708765, m45 = 949591788854171522; EXPECT_EQ(m44 < m45, false); EXPECT_EQ(m44 > m45, true); EXPECT_EQ(m44 == m45, false); - Aesi512 m46 = 54939895533594070, m47 = 9101505712605303811; EXPECT_EQ(m46 < m47, true); EXPECT_EQ(m46 > m47, false); EXPECT_EQ(m46 == m47, false); - Aesi512 m48 = 3371042159109744935, m49 = 7589963848208471409; EXPECT_EQ(m48 < m49, true); EXPECT_EQ(m48 > m49, false); EXPECT_EQ(m48 == m49, false); - Aesi512 m50 = 38949621236659657, m51 = 4623324737003921866; EXPECT_EQ(m50 < m51, true); EXPECT_EQ(m50 > m51, false); EXPECT_EQ(m50 == m51, false); - Aesi512 m52 = 6269751571827533743, m53 = 705840858828118559; EXPECT_EQ(m52 < m53, false); EXPECT_EQ(m52 > m53, true); EXPECT_EQ(m52 == m53, false); - Aesi512 m54 = 2183551194768087143, m55 = 4335206954719021198; EXPECT_EQ(m54 < m55, true); EXPECT_EQ(m54 > m55, false); EXPECT_EQ(m54 == m55, false); - Aesi512 m56 = 1999204758953635755, m57 = 7365785092911923004; EXPECT_EQ(m56 < m57, true); EXPECT_EQ(m56 > m57, false); EXPECT_EQ(m56 == m57, false); - Aesi512 m58 = 8399168629459945903, m59 = 7121060735935892344; EXPECT_EQ(m58 < m59, false); EXPECT_EQ(m58 > m59, true); EXPECT_EQ(m58 == m59, false); - Aesi512 m60 = 5205307955382016007, m61 = 2701357050471651049; EXPECT_EQ(m60 < m61, false); EXPECT_EQ(m60 > m61, true); EXPECT_EQ(m60 == m61, false); - Aesi512 m62 = 8138856079182018445, m63 = 2649268548526188594; EXPECT_EQ(m62 < m63, false); EXPECT_EQ(m62 > m63, true); EXPECT_EQ(m62 == m63, false); - Aesi512 m64 = 770044563987128846, m65 = 1792903910217322047; EXPECT_EQ(m64 < m65, true); EXPECT_EQ(m64 > m65, false); EXPECT_EQ(m64 == m65, false); - Aesi512 m66 = 149780000886157566, m67 = 3286379546181327754; EXPECT_EQ(m66 < m67, true); EXPECT_EQ(m66 > m67, false); EXPECT_EQ(m66 == m67, false); - Aesi512 m68 = 3518911934789621791, m69 = 3007605772752747285; EXPECT_EQ(m68 < m69, false); EXPECT_EQ(m68 > m69, true); EXPECT_EQ(m68 == m69, false); - Aesi512 m70 = 8671267707460523770, m71 = 1086974085630165141; EXPECT_EQ(m70 < m71, false); EXPECT_EQ(m70 > m71, true); EXPECT_EQ(m70 == m71, false); - Aesi512 m72 = 5599330006900864892, m73 = 1312306540840205361; EXPECT_EQ(m72 < m73, false); EXPECT_EQ(m72 > m73, true); EXPECT_EQ(m72 == m73, false); - Aesi512 m74 = 6493662685566076910, m75 = 928471421419528716; EXPECT_EQ(m74 < m75, false); EXPECT_EQ(m74 > m75, true); EXPECT_EQ(m74 == m75, false); - Aesi512 m76 = 667356054549450309, m77 = 6272067595934850214; EXPECT_EQ(m76 < m77, true); EXPECT_EQ(m76 > m77, false); EXPECT_EQ(m76 == m77, false); - Aesi512 m78 = 8408798539754633924, m79 = 629762994379608327; EXPECT_EQ(m78 < m79, false); EXPECT_EQ(m78 > m79, true); EXPECT_EQ(m78 == m79, false); - Aesi512 m80 = 3914077811021313731, m81 = 638948969089289101; EXPECT_EQ(m80 < m81, false); EXPECT_EQ(m80 > m81, true); EXPECT_EQ(m80 == m81, false); - Aesi512 m82 = 9065483488715709442, m83 = 269056060969562416; EXPECT_EQ(m82 < m83, false); EXPECT_EQ(m82 > m83, true); EXPECT_EQ(m82 == m83, false); - Aesi512 m84 = 3640842096633396468, m85 = 6629450212748541735; EXPECT_EQ(m84 < m85, true); EXPECT_EQ(m84 > m85, false); EXPECT_EQ(m84 == m85, false); - Aesi512 m86 = 6244623324629960355, m87 = 8957975136903626022; EXPECT_EQ(m86 < m87, true); EXPECT_EQ(m86 > m87, false); EXPECT_EQ(m86 == m87, false); - Aesi512 m88 = 361777666027439923, m89 = 8473580075031122599; EXPECT_EQ(m88 < m89, true); EXPECT_EQ(m88 > m89, false); EXPECT_EQ(m88 == m89, false); - Aesi512 m90 = 2214964541608998768, m91 = 3916091209448393772; EXPECT_EQ(m90 < m91, true); EXPECT_EQ(m90 > m91, false); EXPECT_EQ(m90 == m91, false); - Aesi512 m92 = 8286608739462589926, m93 = 2211701376556461485; EXPECT_EQ(m92 < m93, false); EXPECT_EQ(m92 > m93, true); EXPECT_EQ(m92 == m93, false); - Aesi512 m94 = 6712142162915751904, m95 = 8688782718315824219; EXPECT_EQ(m94 < m95, true); EXPECT_EQ(m94 > m95, false); EXPECT_EQ(m94 == m95, false); - Aesi512 m96 = 1621146558575049424, m97 = 900422204676489270; EXPECT_EQ(m96 < m97, false); EXPECT_EQ(m96 > m97, true); EXPECT_EQ(m96 == m97, false); - Aesi512 m98 = 7221541927100992379, m99 = 5143259391773772944; EXPECT_EQ(m98 < m99, false); EXPECT_EQ(m98 > m99, true); EXPECT_EQ(m98 == m99, false); - - Aesi512 y0 = 7636576598697294436, y1 = 7636576598697294436; EXPECT_EQ(y0 < y1, false); EXPECT_EQ(y0 > y1, false); EXPECT_EQ(y0 == y1, true); - Aesi512 y2 = 1396390219352036105, y3 = 1396390219352036105; EXPECT_EQ(y2 < y3, false); EXPECT_EQ(y2 > y3, false); EXPECT_EQ(y2 == y3, true); - Aesi512 y4 = 1876370602312243611, y5 = 1876370602312243611; EXPECT_EQ(y4 < y5, false); EXPECT_EQ(y4 > y5, false); EXPECT_EQ(y4 == y5, true); - Aesi512 y6 = 4389894041997426185, y7 = 4389894041997426185; EXPECT_EQ(y6 < y7, false); EXPECT_EQ(y6 > y7, false); EXPECT_EQ(y6 == y7, true); - Aesi512 y8 = 8757835874326958730, y9 = 8757835874326958730; EXPECT_EQ(y8 < y9, false); EXPECT_EQ(y8 > y9, false); EXPECT_EQ(y8 == y9, true); - Aesi512 y10 = 7654701489846959904, y11 = 7654701489846959904; EXPECT_EQ(y10 < y11, false); EXPECT_EQ(y10 > y11, false); EXPECT_EQ(y10 == y11, true); - Aesi512 y12 = 7951596781520787173, y13 = 7951596781520787173; EXPECT_EQ(y12 < y13, false); EXPECT_EQ(y12 > y13, false); EXPECT_EQ(y12 == y13, true); - Aesi512 y14 = 3979006791513237631, y15 = 3979006791513237631; EXPECT_EQ(y14 < y15, false); EXPECT_EQ(y14 > y15, false); EXPECT_EQ(y14 == y15, true); - Aesi512 y16 = 8646789167372071802, y17 = 8646789167372071802; EXPECT_EQ(y16 < y17, false); EXPECT_EQ(y16 > y17, false); EXPECT_EQ(y16 == y17, true); - Aesi512 y18 = 93790031817935795, y19 = 93790031817935795; EXPECT_EQ(y18 < y19, false); EXPECT_EQ(y18 > y19, false); EXPECT_EQ(y18 == y19, true); - - Aesi512 t0 = "324939500766121887776989132520157389914.", t1 = "313651970083237033009921276535943692201."; EXPECT_EQ(t0 < t1, false); EXPECT_EQ(t0 > t1, true); EXPECT_EQ(t0 == t1, false); - Aesi512 t2 = "113525738071664729078943235110580655685.", t3 = "13929167430938083152246656926579649132."; EXPECT_EQ(t2 < t3, false); EXPECT_EQ(t2 > t3, true); EXPECT_EQ(t2 == t3, false); - Aesi512 t4 = "95573144668940997682867099911666029538.", t5 = "70541771947794926908949781993341392162."; EXPECT_EQ(t4 < t5, false); EXPECT_EQ(t4 > t5, true); EXPECT_EQ(t4 == t5, false); - Aesi512 t6 = "217753375092567613098572020793925951275.", t7 = "70989984400829639410577012954876470650."; EXPECT_EQ(t6 < t7, false); EXPECT_EQ(t6 > t7, true); EXPECT_EQ(t6 == t7, false); - Aesi512 t8 = "72343605821393319507823307883363815745.", t9 = "103744356900317989401006302403021123558."; EXPECT_EQ(t8 < t9, true); EXPECT_EQ(t8 > t9, false); EXPECT_EQ(t8 == t9, false); - Aesi512 t10 = "254408353941258204008073532779355501906.", t11 = "296434823387921938219937036586287595724."; EXPECT_EQ(t10 < t11, true); EXPECT_EQ(t10 > t11, false); EXPECT_EQ(t10 == t11, false); - Aesi512 t12 = "233106448577166852344552427720324076662.", t13 = "146998695685653522484527493024100140868."; EXPECT_EQ(t12 < t13, false); EXPECT_EQ(t12 > t13, true); EXPECT_EQ(t12 == t13, false); - Aesi512 t14 = "71065572425616389606933209832564494154.", t15 = "125952696820341424478881652454300412976."; EXPECT_EQ(t14 < t15, true); EXPECT_EQ(t14 > t15, false); EXPECT_EQ(t14 == t15, false); - Aesi512 t16 = "86981402744622618508794329665032117784.", t17 = "90062431767761460667132096232442477985."; EXPECT_EQ(t16 < t17, true); EXPECT_EQ(t16 > t17, false); EXPECT_EQ(t16 == t17, false); - Aesi512 t18 = "40794572753000119890755984109845385310.", t19 = "257764250778095484096536807614811739299."; EXPECT_EQ(t18 < t19, true); EXPECT_EQ(t18 > t19, false); EXPECT_EQ(t18 == t19, false); - Aesi512 t20 = "312774166924990695497923750357672208998.", t21 = "138619920625570134587678613476004938262."; EXPECT_EQ(t20 < t21, false); EXPECT_EQ(t20 > t21, true); EXPECT_EQ(t20 == t21, false); - Aesi512 t22 = "325975764569618235531390597703790209456.", t23 = "137912901742229895471269806999555976430."; EXPECT_EQ(t22 < t23, false); EXPECT_EQ(t22 > t23, true); EXPECT_EQ(t22 == t23, false); - Aesi512 t24 = "337442615207270184626713361248728817083.", t25 = "324000408147831083391287599791811201285."; EXPECT_EQ(t24 < t25, false); EXPECT_EQ(t24 > t25, true); EXPECT_EQ(t24 == t25, false); - Aesi512 t26 = "75953667207052653075645410180347682805.", t27 = "244397417632611308300332906532850228154."; EXPECT_EQ(t26 < t27, true); EXPECT_EQ(t26 > t27, false); EXPECT_EQ(t26 == t27, false); - Aesi512 t28 = "151174923469770731594949669687977333008.", t29 = "114372551977547693458467931975844458957."; EXPECT_EQ(t28 < t29, false); EXPECT_EQ(t28 > t29, true); EXPECT_EQ(t28 == t29, false); - Aesi512 t30 = "71282640392978365219042927132403007300.", t31 = "64776430772469175589245719046354753309."; EXPECT_EQ(t30 < t31, false); EXPECT_EQ(t30 > t31, true); EXPECT_EQ(t30 == t31, false); - Aesi512 t32 = "99873469711907571120093206888741228295.", t33 = "276637020477283033118710293236348206516."; EXPECT_EQ(t32 < t33, true); EXPECT_EQ(t32 > t33, false); EXPECT_EQ(t32 == t33, false); - Aesi512 t34 = "277798048861970991107500020599537058284.", t35 = "206461559777151460105973820516981920331."; EXPECT_EQ(t34 < t35, false); EXPECT_EQ(t34 > t35, true); EXPECT_EQ(t34 == t35, false); - Aesi512 t36 = "231338116801192999291775104728364884786.", t37 = "24086954687018060137824732538450701307."; EXPECT_EQ(t36 < t37, false); EXPECT_EQ(t36 > t37, true); EXPECT_EQ(t36 == t37, false); - Aesi512 t38 = "147455661854833613701634027019553261374.", t39 = "101447150847979598303315727908809952024."; EXPECT_EQ(t38 < t39, false); EXPECT_EQ(t38 > t39, true); EXPECT_EQ(t38 == t39, false); - Aesi512 t40 = "220118391480820413692978138215126754530.", t41 = "16042042494712438039600213355560636803."; EXPECT_EQ(t40 < t41, false); EXPECT_EQ(t40 > t41, true); EXPECT_EQ(t40 == t41, false); - Aesi512 t42 = "105857878112771122324277433293095047345.", t43 = "181190761266488384177216932916196598985."; EXPECT_EQ(t42 < t43, true); EXPECT_EQ(t42 > t43, false); EXPECT_EQ(t42 == t43, false); - Aesi512 t44 = "26444578214835905822403473389111521093.", t45 = "47754768225433710784305091293551132794."; EXPECT_EQ(t44 < t45, true); EXPECT_EQ(t44 > t45, false); EXPECT_EQ(t44 == t45, false); - Aesi512 t46 = "141590742635288855355090153355343954974.", t47 = "110970723510498957603667017570927953996."; EXPECT_EQ(t46 < t47, false); EXPECT_EQ(t46 > t47, true); EXPECT_EQ(t46 == t47, false); - Aesi512 t48 = "147103771560797877203312287440574994709.", t49 = "155568902714945936263413220822114199796."; EXPECT_EQ(t48 < t49, true); EXPECT_EQ(t48 > t49, false); EXPECT_EQ(t48 == t49, false); - Aesi512 t50 = "86166821637078430841876191320980816008.", t51 = "47447850811363226836906574751178707331."; EXPECT_EQ(t50 < t51, false); EXPECT_EQ(t50 > t51, true); EXPECT_EQ(t50 == t51, false); - Aesi512 t52 = "232410844136943063440793306378450174100.", t53 = "92738147185701937980784084818084849824."; EXPECT_EQ(t52 < t53, false); EXPECT_EQ(t52 > t53, true); EXPECT_EQ(t52 == t53, false); - Aesi512 t54 = "110993559123871965884413268130942500430.", t55 = "63477113954003042618257340487353738955."; EXPECT_EQ(t54 < t55, false); EXPECT_EQ(t54 > t55, true); EXPECT_EQ(t54 == t55, false); - Aesi512 t56 = "89998138274682985946382223651935379503.", t57 = "109368149949915834771162982692840347435."; EXPECT_EQ(t56 < t57, true); EXPECT_EQ(t56 > t57, false); EXPECT_EQ(t56 == t57, false); - Aesi512 t58 = "241738944914483206497826954846138803776.", t59 = "21017631577893517110835833222291387722."; EXPECT_EQ(t58 < t59, false); EXPECT_EQ(t58 > t59, true); EXPECT_EQ(t58 == t59, false); - Aesi512 t60 = "105812883288657769634427078438956637851.", t61 = "182490232501620116097581302468350430434."; EXPECT_EQ(t60 < t61, true); EXPECT_EQ(t60 > t61, false); EXPECT_EQ(t60 == t61, false); - Aesi512 t62 = "258347523703720138001693872816400860402.", t63 = "210548410397818372465483492374687954671."; EXPECT_EQ(t62 < t63, false); EXPECT_EQ(t62 > t63, true); EXPECT_EQ(t62 == t63, false); - Aesi512 t64 = "45933834983852240184271702028917988822.", t65 = "304271539279531203296635338827918527937."; EXPECT_EQ(t64 < t65, true); EXPECT_EQ(t64 > t65, false); EXPECT_EQ(t64 == t65, false); - Aesi512 t66 = "307051708410080545187705939745150947120.", t67 = "162108995280292283518002783834314209620."; EXPECT_EQ(t66 < t67, false); EXPECT_EQ(t66 > t67, true); EXPECT_EQ(t66 == t67, false); - Aesi512 t68 = "24730384800343530681380055881806738251.", t69 = "40985089774364269480143776962615168941."; EXPECT_EQ(t68 < t69, true); EXPECT_EQ(t68 > t69, false); EXPECT_EQ(t68 == t69, false); - Aesi512 t70 = "22458954845804307568549438283719976060.", t71 = "223032349646169984483889256932473799343."; EXPECT_EQ(t70 < t71, true); EXPECT_EQ(t70 > t71, false); EXPECT_EQ(t70 == t71, false); - Aesi512 t72 = "305060433655032032750655207149229870339.", t73 = "330661677566482326307184091739866399144."; EXPECT_EQ(t72 < t73, true); EXPECT_EQ(t72 > t73, false); EXPECT_EQ(t72 == t73, false); - Aesi512 t74 = "21830124334505988243416303696230675143.", t75 = "256975399875244308775605682125711072356."; EXPECT_EQ(t74 < t75, true); EXPECT_EQ(t74 > t75, false); EXPECT_EQ(t74 == t75, false); - Aesi512 t76 = "10106776841877628906556529998336851136.", t77 = "140499109957437765170588170443474618364."; EXPECT_EQ(t76 < t77, true); EXPECT_EQ(t76 > t77, false); EXPECT_EQ(t76 == t77, false); - Aesi512 t78 = "209320672993651306188546028442577005044.", t79 = "83940258953085319745707620636036242513."; EXPECT_EQ(t78 < t79, false); EXPECT_EQ(t78 > t79, true); EXPECT_EQ(t78 == t79, false); - Aesi512 t80 = "238629468242661113413937696337627500466.", t81 = "126241821422924508630309679727133947668."; EXPECT_EQ(t80 < t81, false); EXPECT_EQ(t80 > t81, true); EXPECT_EQ(t80 == t81, false); - Aesi512 t82 = "87018120690449434646662256705878145525.", t83 = "106118676359859726242661467865634124736."; EXPECT_EQ(t82 < t83, true); EXPECT_EQ(t82 > t83, false); EXPECT_EQ(t82 == t83, false); - Aesi512 t84 = "232579941974117855610802390067801527361.", t85 = "41743939125512799533874470956777949518."; EXPECT_EQ(t84 < t85, false); EXPECT_EQ(t84 > t85, true); EXPECT_EQ(t84 == t85, false); - Aesi512 t86 = "263226738725255548034061468044724111702.", t87 = "226823632790506485730758174277316748382."; EXPECT_EQ(t86 < t87, false); EXPECT_EQ(t86 > t87, true); EXPECT_EQ(t86 == t87, false); - Aesi512 t88 = "234850351049651862824225518842277550757.", t89 = "281202735026210035274953990562039211868."; EXPECT_EQ(t88 < t89, true); EXPECT_EQ(t88 > t89, false); EXPECT_EQ(t88 == t89, false); - Aesi512 t90 = "301038152691713146637055292994491703735.", t91 = "232168404248370260375257410501360850043."; EXPECT_EQ(t90 < t91, false); EXPECT_EQ(t90 > t91, true); EXPECT_EQ(t90 == t91, false); - Aesi512 t92 = "127921205057541692982811515555199038509.", t93 = "276167200383855274004255672376922644196."; EXPECT_EQ(t92 < t93, true); EXPECT_EQ(t92 > t93, false); EXPECT_EQ(t92 == t93, false); - Aesi512 t94 = "49102448900748317928120873911675600079.", t95 = "223935092686163445463267304296447179989."; EXPECT_EQ(t94 < t95, true); EXPECT_EQ(t94 > t95, false); EXPECT_EQ(t94 == t95, false); - Aesi512 t96 = "144552296102978508559535958878071314417.", t97 = "30940923099305680044090950664046154499."; EXPECT_EQ(t96 < t97, false); EXPECT_EQ(t96 > t97, true); EXPECT_EQ(t96 == t97, false); - Aesi512 t98 = "56929180182638190331988369488851676606.", t99 = "247716894024801826719771259223891013186."; EXPECT_EQ(t98 < t99, true); EXPECT_EQ(t98 > t99, false); EXPECT_EQ(t98 == t99, false); - - Aesi512 r0 = "201381435085756820979029715655075876997.", r1 = "201381435085756820979029715655075876997."; EXPECT_EQ(r0 < r1, false); EXPECT_EQ(r0 > r1, false); EXPECT_EQ(r0 == r1, true); - Aesi512 r2 = "229159202763006840583025892455270836892.", r3 = "229159202763006840583025892455270836892."; EXPECT_EQ(r2 < r3, false); EXPECT_EQ(r2 > r3, false); EXPECT_EQ(r2 == r3, true); - Aesi512 r4 = "339146412382362994754581190533478781018.", r5 = "339146412382362994754581190533478781018."; EXPECT_EQ(r4 < r5, false); EXPECT_EQ(r4 > r5, false); EXPECT_EQ(r4 == r5, true); - Aesi512 r6 = "124295398644758189113576493320032040275.", r7 = "124295398644758189113576493320032040275."; EXPECT_EQ(r6 < r7, false); EXPECT_EQ(r6 > r7, false); EXPECT_EQ(r6 == r7, true); - Aesi512 r8 = "295279518426728664929368296744239776609.", r9 = "295279518426728664929368296744239776609."; EXPECT_EQ(r8 < r9, false); EXPECT_EQ(r8 > r9, false); EXPECT_EQ(r8 == r9, true); - Aesi512 r10 = "319643158856528060426277248185756487060.", r11 = "319643158856528060426277248185756487060."; EXPECT_EQ(r10 < r11, false); EXPECT_EQ(r10 > r11, false); EXPECT_EQ(r10 == r11, true); - Aesi512 r12 = "127108996786283808267853584156702042675.", r13 = "127108996786283808267853584156702042675."; EXPECT_EQ(r12 < r13, false); EXPECT_EQ(r12 > r13, false); EXPECT_EQ(r12 == r13, true); - Aesi512 r14 = "123332376598963012950955571465063211860.", r15 = "123332376598963012950955571465063211860."; EXPECT_EQ(r14 < r15, false); EXPECT_EQ(r14 > r15, false); EXPECT_EQ(r14 == r15, true); - Aesi512 r16 = "307003963041772851243779066372380492627.", r17 = "307003963041772851243779066372380492627."; EXPECT_EQ(r16 < r17, false); EXPECT_EQ(r16 > r17, false); EXPECT_EQ(r16 == r17, true); - Aesi512 r18 = "194662908396084132647198018631066653076.", r19 = "194662908396084132647198018631066653076."; EXPECT_EQ(r18 < r19, false); EXPECT_EQ(r18 > r19, false); EXPECT_EQ(r18 == r19, true); - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(Boolean, ThreeWayEquallComparasion) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = 7036437650415461321, m1 = 3512521750905585604; EXPECT_EQ(m0 <= m1, false); EXPECT_EQ(m0 >= m1, true); EXPECT_EQ(m0 == m1, false); - Aesi512 m2 = 1383437920778735070, m3 = 8349814587438416033; EXPECT_EQ(m2 <= m3, true); EXPECT_EQ(m2 >= m3, false); EXPECT_EQ(m2 == m3, false); - Aesi512 m4 = 9113619168792656185, m5 = 4220142331454932859; EXPECT_EQ(m4 <= m5, false); EXPECT_EQ(m4 >= m5, true); EXPECT_EQ(m4 == m5, false); - Aesi512 m6 = 8854558742841206330, m7 = 9114810997037713198; EXPECT_EQ(m6 <= m7, true); EXPECT_EQ(m6 >= m7, false); EXPECT_EQ(m6 == m7, false); - Aesi512 m8 = 7889880532277012269, m9 = 510905311056591919; EXPECT_EQ(m8 <= m9, false); EXPECT_EQ(m8 >= m9, true); EXPECT_EQ(m8 == m9, false); - Aesi512 m10 = 4036861924531831555, m11 = 3838191133844808910; EXPECT_EQ(m10 <= m11, false); EXPECT_EQ(m10 >= m11, true); EXPECT_EQ(m10 == m11, false); - Aesi512 m12 = 4875137103990077450, m13 = 3398410533657158298; EXPECT_EQ(m12 <= m13, false); EXPECT_EQ(m12 >= m13, true); EXPECT_EQ(m12 == m13, false); - Aesi512 m14 = 5307900228590194215, m15 = 7272791637303292964; EXPECT_EQ(m14 <= m15, true); EXPECT_EQ(m14 >= m15, false); EXPECT_EQ(m14 == m15, false); - Aesi512 m16 = 3264831984244893683, m17 = 2045517973749331953; EXPECT_EQ(m16 <= m17, false); EXPECT_EQ(m16 >= m17, true); EXPECT_EQ(m16 == m17, false); - Aesi512 m18 = 5782470229611512575, m19 = 4797501343698587430; EXPECT_EQ(m18 <= m19, false); EXPECT_EQ(m18 >= m19, true); EXPECT_EQ(m18 == m19, false); - Aesi512 m20 = 418722049626410312, m21 = 6389665526464147971; EXPECT_EQ(m20 <= m21, true); EXPECT_EQ(m20 >= m21, false); EXPECT_EQ(m20 == m21, false); - Aesi512 m22 = 1136371225733026514, m23 = 4865828314681372077; EXPECT_EQ(m22 <= m23, true); EXPECT_EQ(m22 >= m23, false); EXPECT_EQ(m22 == m23, false); - Aesi512 m24 = 1289355361274959863, m25 = 2889754703404589325; EXPECT_EQ(m24 <= m25, true); EXPECT_EQ(m24 >= m25, false); EXPECT_EQ(m24 == m25, false); - Aesi512 m26 = 1765701753457030832, m27 = 3917563358976747341; EXPECT_EQ(m26 <= m27, true); EXPECT_EQ(m26 >= m27, false); EXPECT_EQ(m26 == m27, false); - Aesi512 m28 = 2221444770594720113, m29 = 6362993791298458990; EXPECT_EQ(m28 <= m29, true); EXPECT_EQ(m28 >= m29, false); EXPECT_EQ(m28 == m29, false); - Aesi512 m30 = 4675703906955057488, m31 = 7632776120455549467; EXPECT_EQ(m30 <= m31, true); EXPECT_EQ(m30 >= m31, false); EXPECT_EQ(m30 == m31, false); - Aesi512 m32 = 4134506495922632915, m33 = 7756013962571547686; EXPECT_EQ(m32 <= m33, true); EXPECT_EQ(m32 >= m33, false); EXPECT_EQ(m32 == m33, false); - Aesi512 m34 = 2549158072032400321, m35 = 4141043625639388388; EXPECT_EQ(m34 <= m35, true); EXPECT_EQ(m34 >= m35, false); EXPECT_EQ(m34 == m35, false); - Aesi512 m36 = 1541700670473320539, m37 = 8134880522594404560; EXPECT_EQ(m36 <= m37, true); EXPECT_EQ(m36 >= m37, false); EXPECT_EQ(m36 == m37, false); - Aesi512 m38 = 7623735422058825916, m39 = 8449121021456094098; EXPECT_EQ(m38 <= m39, true); EXPECT_EQ(m38 >= m39, false); EXPECT_EQ(m38 == m39, false); - Aesi512 m40 = 6553339632492361232, m41 = 6629792053215301617; EXPECT_EQ(m40 <= m41, true); EXPECT_EQ(m40 >= m41, false); EXPECT_EQ(m40 == m41, false); - Aesi512 m42 = 1313902652864581146, m43 = 2733413829789594072; EXPECT_EQ(m42 <= m43, true); EXPECT_EQ(m42 >= m43, false); EXPECT_EQ(m42 == m43, false); - Aesi512 m44 = 27343049037018, m45 = 8022928103331756098; EXPECT_EQ(m44 <= m45, true); EXPECT_EQ(m44 >= m45, false); EXPECT_EQ(m44 == m45, false); - Aesi512 m46 = 1055546162731508668, m47 = 7495329233645082183; EXPECT_EQ(m46 <= m47, true); EXPECT_EQ(m46 >= m47, false); EXPECT_EQ(m46 == m47, false); - Aesi512 m48 = 6664038168252544455, m49 = 8555906633884133989; EXPECT_EQ(m48 <= m49, true); EXPECT_EQ(m48 >= m49, false); EXPECT_EQ(m48 == m49, false); - Aesi512 m50 = 2472632171088761660, m51 = 4239713703857228583; EXPECT_EQ(m50 <= m51, true); EXPECT_EQ(m50 >= m51, false); EXPECT_EQ(m50 == m51, false); - Aesi512 m52 = 5431978097832685807, m53 = 4524383677364403319; EXPECT_EQ(m52 <= m53, false); EXPECT_EQ(m52 >= m53, true); EXPECT_EQ(m52 == m53, false); - Aesi512 m54 = 3079862986050289708, m55 = 4268174738292388808; EXPECT_EQ(m54 <= m55, true); EXPECT_EQ(m54 >= m55, false); EXPECT_EQ(m54 == m55, false); - Aesi512 m56 = 641845823960688083, m57 = 7034968042387272505; EXPECT_EQ(m56 <= m57, true); EXPECT_EQ(m56 >= m57, false); EXPECT_EQ(m56 == m57, false); - Aesi512 m58 = 5430749132593562075, m59 = 787085028870740916; EXPECT_EQ(m58 <= m59, false); EXPECT_EQ(m58 >= m59, true); EXPECT_EQ(m58 == m59, false); - Aesi512 m60 = 3282605692920022499, m61 = 1891317284651541150; EXPECT_EQ(m60 <= m61, false); EXPECT_EQ(m60 >= m61, true); EXPECT_EQ(m60 == m61, false); - Aesi512 m62 = 1632589097292541517, m63 = 3719141934289191346; EXPECT_EQ(m62 <= m63, true); EXPECT_EQ(m62 >= m63, false); EXPECT_EQ(m62 == m63, false); - Aesi512 m64 = 6786397205444165792, m65 = 2755389661894147555; EXPECT_EQ(m64 <= m65, false); EXPECT_EQ(m64 >= m65, true); EXPECT_EQ(m64 == m65, false); - Aesi512 m66 = 5319321008389350985, m67 = 5027760907621183804; EXPECT_EQ(m66 <= m67, false); EXPECT_EQ(m66 >= m67, true); EXPECT_EQ(m66 == m67, false); - Aesi512 m68 = 3057905351711841100, m69 = 5319542951096680267; EXPECT_EQ(m68 <= m69, true); EXPECT_EQ(m68 >= m69, false); EXPECT_EQ(m68 == m69, false); - Aesi512 m70 = 8290584765434739153, m71 = 7156475646933033928; EXPECT_EQ(m70 <= m71, false); EXPECT_EQ(m70 >= m71, true); EXPECT_EQ(m70 == m71, false); - Aesi512 m72 = 1804278281437860114, m73 = 3874846944632939529; EXPECT_EQ(m72 <= m73, true); EXPECT_EQ(m72 >= m73, false); EXPECT_EQ(m72 == m73, false); - Aesi512 m74 = 4435339296432742617, m75 = 3826128329360221616; EXPECT_EQ(m74 <= m75, false); EXPECT_EQ(m74 >= m75, true); EXPECT_EQ(m74 == m75, false); - Aesi512 m76 = 4849823403133616055, m77 = 4227365479133156265; EXPECT_EQ(m76 <= m77, false); EXPECT_EQ(m76 >= m77, true); EXPECT_EQ(m76 == m77, false); - Aesi512 m78 = 7814085883082274484, m79 = 1586816423217446834; EXPECT_EQ(m78 <= m79, false); EXPECT_EQ(m78 >= m79, true); EXPECT_EQ(m78 == m79, false); - Aesi512 m80 = 6915561085323458963, m81 = 8919970044012186390; EXPECT_EQ(m80 <= m81, true); EXPECT_EQ(m80 >= m81, false); EXPECT_EQ(m80 == m81, false); - Aesi512 m82 = 863830359948334177, m83 = 8031859615702342273; EXPECT_EQ(m82 <= m83, true); EXPECT_EQ(m82 >= m83, false); EXPECT_EQ(m82 == m83, false); - Aesi512 m84 = 7647248424213586535, m85 = 5145220418143791522; EXPECT_EQ(m84 <= m85, false); EXPECT_EQ(m84 >= m85, true); EXPECT_EQ(m84 == m85, false); - Aesi512 m86 = 7650383719166469560, m87 = 2697335060357100546; EXPECT_EQ(m86 <= m87, false); EXPECT_EQ(m86 >= m87, true); EXPECT_EQ(m86 == m87, false); - Aesi512 m88 = 3418727692309630758, m89 = 4565820036200988802; EXPECT_EQ(m88 <= m89, true); EXPECT_EQ(m88 >= m89, false); EXPECT_EQ(m88 == m89, false); - Aesi512 m90 = 1058630988227384955, m91 = 3340050044751465241; EXPECT_EQ(m90 <= m91, true); EXPECT_EQ(m90 >= m91, false); EXPECT_EQ(m90 == m91, false); - Aesi512 m92 = 5387697094388614096, m93 = 3575048537199532815; EXPECT_EQ(m92 <= m93, false); EXPECT_EQ(m92 >= m93, true); EXPECT_EQ(m92 == m93, false); - Aesi512 m94 = 4397879065975679902, m95 = 8811926327123716778; EXPECT_EQ(m94 <= m95, true); EXPECT_EQ(m94 >= m95, false); EXPECT_EQ(m94 == m95, false); - Aesi512 m96 = 5799331155986527125, m97 = 1611068058870554462; EXPECT_EQ(m96 <= m97, false); EXPECT_EQ(m96 >= m97, true); EXPECT_EQ(m96 == m97, false); - Aesi512 m98 = 4522770317319881104, m99 = 6068149046362325559; EXPECT_EQ(m98 <= m99, true); EXPECT_EQ(m98 >= m99, false); EXPECT_EQ(m98 == m99, false); - - Aesi512 y0 = 8320029752368312075, y1 = 8320029752368312075; EXPECT_EQ(y0 <= y1, true); EXPECT_EQ(y0 >= y1, true); EXPECT_EQ(y0 == y1, true); - Aesi512 y2 = 6007933271507275273, y3 = 6007933271507275273; EXPECT_EQ(y2 <= y3, true); EXPECT_EQ(y2 >= y3, true); EXPECT_EQ(y2 == y3, true); - Aesi512 y4 = 6897640772815461899, y5 = 6897640772815461899; EXPECT_EQ(y4 <= y5, true); EXPECT_EQ(y4 >= y5, true); EXPECT_EQ(y4 == y5, true); - Aesi512 y6 = 4713449543757671635, y7 = 4713449543757671635; EXPECT_EQ(y6 <= y7, true); EXPECT_EQ(y6 >= y7, true); EXPECT_EQ(y6 == y7, true); - Aesi512 y8 = 6120601015759926660, y9 = 6120601015759926660; EXPECT_EQ(y8 <= y9, true); EXPECT_EQ(y8 >= y9, true); EXPECT_EQ(y8 == y9, true); - Aesi512 y10 = 4229106820843609546, y11 = 4229106820843609546; EXPECT_EQ(y10 <= y11, true); EXPECT_EQ(y10 >= y11, true); EXPECT_EQ(y10 == y11, true); - Aesi512 y12 = 1172940937011946395, y13 = 1172940937011946395; EXPECT_EQ(y12 <= y13, true); EXPECT_EQ(y12 >= y13, true); EXPECT_EQ(y12 == y13, true); - Aesi512 y14 = 704072415315244208, y15 = 704072415315244208; EXPECT_EQ(y14 <= y15, true); EXPECT_EQ(y14 >= y15, true); EXPECT_EQ(y14 == y15, true); - Aesi512 y16 = 4553526324210963857, y17 = 4553526324210963857; EXPECT_EQ(y16 <= y17, true); EXPECT_EQ(y16 >= y17, true); EXPECT_EQ(y16 == y17, true); - Aesi512 y18 = 776440877943110513, y19 = 776440877943110513; EXPECT_EQ(y18 <= y19, true); EXPECT_EQ(y18 >= y19, true); EXPECT_EQ(y18 == y19, true); - - Aesi512 t0 = "208178955502460206467631162528747068372.", t1 = "64981800032079918457319292521675272736."; EXPECT_EQ(t0 <= t1, false); EXPECT_EQ(t0 >= t1, true); EXPECT_EQ(t0 == t1, false); - Aesi512 t2 = "247814987693152079030780184492208251996.", t3 = "263966279329761097462235094975616920228."; EXPECT_EQ(t2 <= t3, true); EXPECT_EQ(t2 >= t3, false); EXPECT_EQ(t2 == t3, false); - Aesi512 t4 = "73465800505654103611807329939469945681.", t5 = "202601819576953010517566255364071174458."; EXPECT_EQ(t4 <= t5, true); EXPECT_EQ(t4 >= t5, false); EXPECT_EQ(t4 == t5, false); - Aesi512 t6 = "303173562626122256842896980282946724738.", t7 = "331011772716112637416978127054830470731."; EXPECT_EQ(t6 <= t7, true); EXPECT_EQ(t6 >= t7, false); EXPECT_EQ(t6 == t7, false); - Aesi512 t8 = "3864637642025520502134647523005910787.", t9 = "291611647171610687777257063206651343864."; EXPECT_EQ(t8 <= t9, true); EXPECT_EQ(t8 >= t9, false); EXPECT_EQ(t8 == t9, false); - Aesi512 t10 = "122681455111830759530897853957557799691.", t11 = "21641807652291780444162905870086714666."; EXPECT_EQ(t10 <= t11, false); EXPECT_EQ(t10 >= t11, true); EXPECT_EQ(t10 == t11, false); - Aesi512 t12 = "97308622932868025182709416240848250195.", t13 = "238139569623611316248210436094742215198."; EXPECT_EQ(t12 <= t13, true); EXPECT_EQ(t12 >= t13, false); EXPECT_EQ(t12 == t13, false); - Aesi512 t14 = "165769368746015872918155972307362125984.", t15 = "68178607115076858297662910821149107358."; EXPECT_EQ(t14 <= t15, false); EXPECT_EQ(t14 >= t15, true); EXPECT_EQ(t14 == t15, false); - Aesi512 t16 = "178390421905730097597571154601274281252.", t17 = "294270823573701404652144634939099894142."; EXPECT_EQ(t16 <= t17, true); EXPECT_EQ(t16 >= t17, false); EXPECT_EQ(t16 == t17, false); - Aesi512 t18 = "270522884533698161207117283333044357457.", t19 = "332228325662812845891288989202713144893."; EXPECT_EQ(t18 <= t19, true); EXPECT_EQ(t18 >= t19, false); EXPECT_EQ(t18 == t19, false); - Aesi512 t20 = "127746910442939694123228128880004185590.", t21 = "103398316016400342831112711945912658719."; EXPECT_EQ(t20 <= t21, false); EXPECT_EQ(t20 >= t21, true); EXPECT_EQ(t20 == t21, false); - Aesi512 t22 = "54774663531144817080078282547682586930.", t23 = "130413125151251178830927334536077329589."; EXPECT_EQ(t22 <= t23, true); EXPECT_EQ(t22 >= t23, false); EXPECT_EQ(t22 == t23, false); - Aesi512 t24 = "334479938792989469847436357030676468810.", t25 = "267907787639591756586953273853480160347."; EXPECT_EQ(t24 <= t25, false); EXPECT_EQ(t24 >= t25, true); EXPECT_EQ(t24 == t25, false); - Aesi512 t26 = "289808373193873595805994672251677165856.", t27 = "3415547954405977649762544065718077144."; EXPECT_EQ(t26 <= t27, false); EXPECT_EQ(t26 >= t27, true); EXPECT_EQ(t26 == t27, false); - Aesi512 t28 = "162488969672369099691132364320325400428.", t29 = "232487890714257578245292317189848461700."; EXPECT_EQ(t28 <= t29, true); EXPECT_EQ(t28 >= t29, false); EXPECT_EQ(t28 == t29, false); - Aesi512 t30 = "204999338095425558358401431492357370900.", t31 = "336883581398081627324000171683559598628."; EXPECT_EQ(t30 <= t31, true); EXPECT_EQ(t30 >= t31, false); EXPECT_EQ(t30 == t31, false); - Aesi512 t32 = "83540011534078051356779928573776410534.", t33 = "118739334326883846992070775753049735427."; EXPECT_EQ(t32 <= t33, true); EXPECT_EQ(t32 >= t33, false); EXPECT_EQ(t32 == t33, false); - Aesi512 t34 = "152959503051887842064759736988976887088.", t35 = "333792111201188240171052490312883410582."; EXPECT_EQ(t34 <= t35, true); EXPECT_EQ(t34 >= t35, false); EXPECT_EQ(t34 == t35, false); - Aesi512 t36 = "114051205063069345868250766308095892531.", t37 = "248649722932539943073363213842946493241."; EXPECT_EQ(t36 <= t37, true); EXPECT_EQ(t36 >= t37, false); EXPECT_EQ(t36 == t37, false); - Aesi512 t38 = "337120456781515583909613006093331569117.", t39 = "144251080727274199354551341876378161295."; EXPECT_EQ(t38 <= t39, false); EXPECT_EQ(t38 >= t39, true); EXPECT_EQ(t38 == t39, false); - Aesi512 t40 = "37774293832387647731692596131818426719.", t41 = "53546713384905846788672780538046522671."; EXPECT_EQ(t40 <= t41, true); EXPECT_EQ(t40 >= t41, false); EXPECT_EQ(t40 == t41, false); - Aesi512 t42 = "139075906209510717792673497349319723211.", t43 = "111442717559114847694016330744146925731."; EXPECT_EQ(t42 <= t43, false); EXPECT_EQ(t42 >= t43, true); EXPECT_EQ(t42 == t43, false); - Aesi512 t44 = "292688889761974795557125715195177869596.", t45 = "132711250091382643551347632051872217567."; EXPECT_EQ(t44 <= t45, false); EXPECT_EQ(t44 >= t45, true); EXPECT_EQ(t44 == t45, false); - Aesi512 t46 = "41491796239465277320441567743123820097.", t47 = "91816927434564343790138528288558716997."; EXPECT_EQ(t46 <= t47, true); EXPECT_EQ(t46 >= t47, false); EXPECT_EQ(t46 == t47, false); - Aesi512 t48 = "291971345364142638878677933211972184737.", t49 = "206243892964298824128620955370119376329."; EXPECT_EQ(t48 <= t49, false); EXPECT_EQ(t48 >= t49, true); EXPECT_EQ(t48 == t49, false); - Aesi512 t50 = "24645829244555005526680646607873625323.", t51 = "10775560883385758906125651743021888782."; EXPECT_EQ(t50 <= t51, false); EXPECT_EQ(t50 >= t51, true); EXPECT_EQ(t50 == t51, false); - Aesi512 t52 = "7003801105694981005673402708023678568.", t53 = "190840390076578379023945645793163805932."; EXPECT_EQ(t52 <= t53, true); EXPECT_EQ(t52 >= t53, false); EXPECT_EQ(t52 == t53, false); - Aesi512 t54 = "251232285614817420724156791115728998761.", t55 = "263529632892159387032858900123842651849."; EXPECT_EQ(t54 <= t55, true); EXPECT_EQ(t54 >= t55, false); EXPECT_EQ(t54 == t55, false); - Aesi512 t56 = "96191384646058857857362178296763852617.", t57 = "335647084617490565938717853751076352386."; EXPECT_EQ(t56 <= t57, true); EXPECT_EQ(t56 >= t57, false); EXPECT_EQ(t56 == t57, false); - Aesi512 t58 = "293050967895956966286094450281947760937.", t59 = "178933352163580864276338519437241931046."; EXPECT_EQ(t58 <= t59, false); EXPECT_EQ(t58 >= t59, true); EXPECT_EQ(t58 == t59, false); - Aesi512 t60 = "315179377666218076788266525028181292242.", t61 = "288773657905479367055458565004106921337."; EXPECT_EQ(t60 <= t61, false); EXPECT_EQ(t60 >= t61, true); EXPECT_EQ(t60 == t61, false); - Aesi512 t62 = "126265593080703247475104064649681422296.", t63 = "307000106429701483226411030503732947911."; EXPECT_EQ(t62 <= t63, true); EXPECT_EQ(t62 >= t63, false); EXPECT_EQ(t62 == t63, false); - Aesi512 t64 = "167816843344401231614364966510184716739.", t65 = "222321877185087567501723893111885827385."; EXPECT_EQ(t64 <= t65, true); EXPECT_EQ(t64 >= t65, false); EXPECT_EQ(t64 == t65, false); - Aesi512 t66 = "104282391626031999571561771580323500695.", t67 = "222756463486846559832316141772451875887."; EXPECT_EQ(t66 <= t67, true); EXPECT_EQ(t66 >= t67, false); EXPECT_EQ(t66 == t67, false); - Aesi512 t68 = "17997094960580244957400505408057125382.", t69 = "316417801448472732167088789201944144756."; EXPECT_EQ(t68 <= t69, true); EXPECT_EQ(t68 >= t69, false); EXPECT_EQ(t68 == t69, false); - Aesi512 t70 = "134556065539850228911098327637041204211.", t71 = "209721104206992009604574465620419979422."; EXPECT_EQ(t70 <= t71, true); EXPECT_EQ(t70 >= t71, false); EXPECT_EQ(t70 == t71, false); - Aesi512 t72 = "205241037529658252216054135112031485594.", t73 = "9864779801465999028881839523391943268."; EXPECT_EQ(t72 <= t73, false); EXPECT_EQ(t72 >= t73, true); EXPECT_EQ(t72 == t73, false); - Aesi512 t74 = "241202103888975299969663208658547593183.", t75 = "212288238739844738441258242445949163873."; EXPECT_EQ(t74 <= t75, false); EXPECT_EQ(t74 >= t75, true); EXPECT_EQ(t74 == t75, false); - Aesi512 t76 = "232331673189501438306001832568018677301.", t77 = "76331239888774617908673969833728656188."; EXPECT_EQ(t76 <= t77, false); EXPECT_EQ(t76 >= t77, true); EXPECT_EQ(t76 == t77, false); - Aesi512 t78 = "43924280150439249317128440109694328115.", t79 = "129108133465465422576743107973955337270."; EXPECT_EQ(t78 <= t79, true); EXPECT_EQ(t78 >= t79, false); EXPECT_EQ(t78 == t79, false); - Aesi512 t80 = "255862437061125287488737469784464274573.", t81 = "62357692322648131714769605195885804904."; EXPECT_EQ(t80 <= t81, false); EXPECT_EQ(t80 >= t81, true); EXPECT_EQ(t80 == t81, false); - Aesi512 t82 = "112561266536434499306206990301059330593.", t83 = "326017950097690434318148233964394076673."; EXPECT_EQ(t82 <= t83, true); EXPECT_EQ(t82 >= t83, false); EXPECT_EQ(t82 == t83, false); - Aesi512 t84 = "222241455631770559213894398905676480069.", t85 = "151820972597868329692659902440689692379."; EXPECT_EQ(t84 <= t85, false); EXPECT_EQ(t84 >= t85, true); EXPECT_EQ(t84 == t85, false); - Aesi512 t86 = "306142081957961427681481143717050986531.", t87 = "231686084540554484494636335450945903916."; EXPECT_EQ(t86 <= t87, false); EXPECT_EQ(t86 >= t87, true); EXPECT_EQ(t86 == t87, false); - Aesi512 t88 = "7565614444721577425346826132104632935.", t89 = "73470575329522004281847524465554770404."; EXPECT_EQ(t88 <= t89, true); EXPECT_EQ(t88 >= t89, false); EXPECT_EQ(t88 == t89, false); - Aesi512 t90 = "220569596388830516545779277402514793825.", t91 = "85872645794402465167428474711438097609."; EXPECT_EQ(t90 <= t91, false); EXPECT_EQ(t90 >= t91, true); EXPECT_EQ(t90 == t91, false); - Aesi512 t92 = "157019109965222568769746309494072859572.", t93 = "231750307093221080640225639270898356561."; EXPECT_EQ(t92 <= t93, true); EXPECT_EQ(t92 >= t93, false); EXPECT_EQ(t92 == t93, false); - Aesi512 t94 = "113921713842257195800459812940056209470.", t95 = "14518241355168892446903560766155181648."; EXPECT_EQ(t94 <= t95, false); EXPECT_EQ(t94 >= t95, true); EXPECT_EQ(t94 == t95, false); - Aesi512 t96 = "18527046028903835094982733458489101248.", t97 = "152271184099105487470260317025548245352."; EXPECT_EQ(t96 <= t97, true); EXPECT_EQ(t96 >= t97, false); EXPECT_EQ(t96 == t97, false); - Aesi512 t98 = "254913423786573833959243458222189175211.", t99 = "275475203663087425583025836375912300601."; EXPECT_EQ(t98 <= t99, true); EXPECT_EQ(t98 >= t99, false); EXPECT_EQ(t98 == t99, false); - - Aesi512 r0 = "83006263052236882911121475505611961913.", r1 = "83006263052236882911121475505611961913."; EXPECT_EQ(r0 <= r1, true); EXPECT_EQ(r0 >= r1, true); EXPECT_EQ(r0 == r1, true); - Aesi512 r2 = "199698210511787993107305336800962904524.", r3 = "199698210511787993107305336800962904524."; EXPECT_EQ(r2 <= r3, true); EXPECT_EQ(r2 >= r3, true); EXPECT_EQ(r2 == r3, true); - Aesi512 r4 = "228638879319713518826345372075158184593.", r5 = "228638879319713518826345372075158184593."; EXPECT_EQ(r4 <= r5, true); EXPECT_EQ(r4 >= r5, true); EXPECT_EQ(r4 == r5, true); - Aesi512 r6 = "37529917404847993371235177141408471919.", r7 = "37529917404847993371235177141408471919."; EXPECT_EQ(r6 <= r7, true); EXPECT_EQ(r6 >= r7, true); EXPECT_EQ(r6 == r7, true); - Aesi512 r8 = "106660348004922217465060626445787085234.", r9 = "106660348004922217465060626445787085234."; EXPECT_EQ(r8 <= r9, true); EXPECT_EQ(r8 >= r9, true); EXPECT_EQ(r8 == r9, true); - Aesi512 r10 = "8579128344801168593923881076976628369.", r11 = "8579128344801168593923881076976628369."; EXPECT_EQ(r10 <= r11, true); EXPECT_EQ(r10 >= r11, true); EXPECT_EQ(r10 == r11, true); - Aesi512 r12 = "251066078475156807493829303417733687485.", r13 = "251066078475156807493829303417733687485."; EXPECT_EQ(r12 <= r13, true); EXPECT_EQ(r12 >= r13, true); EXPECT_EQ(r12 == r13, true); - Aesi512 r14 = "69755181066514875766033619263437644053.", r15 = "69755181066514875766033619263437644053."; EXPECT_EQ(r14 <= r15, true); EXPECT_EQ(r14 >= r15, true); EXPECT_EQ(r14 == r15, true); - Aesi512 r16 = "66735372581418058067234560346509638865.", r17 = "66735372581418058067234560346509638865."; EXPECT_EQ(r16 <= r17, true); EXPECT_EQ(r16 >= r17, true); EXPECT_EQ(r16 == r17, true); - Aesi512 r18 = "168496873235580456218434496216410553403.", r19 = "168496873235580456218434496216410553403."; EXPECT_EQ(r18 <= r19, true); EXPECT_EQ(r18 >= r19, true); EXPECT_EQ(r18 == r19, true); - - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count());; -} - -TEST(Boolean, DifferentPrecisions) { - unsigned long long iv = 9112537908201049656; - Aesi < 256 > o1 = iv; Aesi < 288 > o2 = iv; Aesi < 320 > o3 = iv; Aesi < 352 > o4 = iv; Aesi < 384 > o5 = iv; Aesi < 416 > o6 = iv; Aesi < 448 > o7 = iv; Aesi < 480 > o8 = iv; Aesi < 512 > o9 = iv; Aesi < 544 > o10 = iv; - EXPECT_EQ(o1, o2); - - - EXPECT_EQ(o1, o3); EXPECT_EQ(o1, o4); EXPECT_EQ(o1, o5); EXPECT_EQ(o1, o6); EXPECT_EQ(o1, o7); EXPECT_EQ(o1, o8); EXPECT_EQ(o1, o9); EXPECT_EQ(o1, o10); EXPECT_EQ(o2, o1); EXPECT_EQ(o2, o3); EXPECT_EQ(o2, o4); EXPECT_EQ(o2, o5); EXPECT_EQ(o2, o6); EXPECT_EQ(o2, o7); - EXPECT_EQ(o2, o8); EXPECT_EQ(o2, o9); EXPECT_EQ(o2, o10); EXPECT_EQ(o3, o1); EXPECT_EQ(o3, o2); EXPECT_EQ(o3, o4); EXPECT_EQ(o3, o5); EXPECT_EQ(o3, o6); EXPECT_EQ(o3, o7); EXPECT_EQ(o3, o8); EXPECT_EQ(o3, o9); EXPECT_EQ(o3, o10); EXPECT_EQ(o4, o1); EXPECT_EQ(o4, o2); EXPECT_EQ(o4, o3); - EXPECT_EQ(o4, o5); EXPECT_EQ(o4, o6); EXPECT_EQ(o4, o7); EXPECT_EQ(o4, o8); EXPECT_EQ(o4, o9); EXPECT_EQ(o4, o10); EXPECT_EQ(o5, o1); EXPECT_EQ(o5, o2); EXPECT_EQ(o5, o3); EXPECT_EQ(o5, o4); EXPECT_EQ(o5, o6); EXPECT_EQ(o5, o7); EXPECT_EQ(o5, o8); EXPECT_EQ(o5, o9); EXPECT_EQ(o5, o10); - EXPECT_EQ(o6, o1); EXPECT_EQ(o6, o2); EXPECT_EQ(o6, o3); EXPECT_EQ(o6, o4); EXPECT_EQ(o6, o5); EXPECT_EQ(o6, o7); EXPECT_EQ(o6, o8); EXPECT_EQ(o6, o9); EXPECT_EQ(o6, o10); EXPECT_EQ(o7, o1); EXPECT_EQ(o7, o2); EXPECT_EQ(o7, o3); EXPECT_EQ(o7, o4); EXPECT_EQ(o7, o5); EXPECT_EQ(o7, o6); - EXPECT_EQ(o7, o8); EXPECT_EQ(o7, o9); EXPECT_EQ(o7, o10); EXPECT_EQ(o8, o1); EXPECT_EQ(o8, o2); EXPECT_EQ(o8, o3); EXPECT_EQ(o8, o4); EXPECT_EQ(o8, o5); EXPECT_EQ(o8, o6); EXPECT_EQ(o8, o7); EXPECT_EQ(o8, o9); EXPECT_EQ(o8, o10); EXPECT_EQ(o9, o1); EXPECT_EQ(o9, o2); EXPECT_EQ(o9, o3); - EXPECT_EQ(o9, o4); EXPECT_EQ(o9, o5); EXPECT_EQ(o9, o6); EXPECT_EQ(o9, o7); EXPECT_EQ(o9, o8); EXPECT_EQ(o9, o10); EXPECT_EQ(o10, o1); EXPECT_EQ(o10, o2); EXPECT_EQ(o10, o3); EXPECT_EQ(o10, o4); EXPECT_EQ(o10, o5); EXPECT_EQ(o10, o6); EXPECT_EQ(o10, o7); EXPECT_EQ(o10, o8); EXPECT_EQ(o10, o9); - - Aesi < 608 > w0 = "3893509674364240296565817966808751172691002783248199782541334351863333341009161236129113001785247442885856708616220103577302425545750798795713950025251102."; - Aesi < 832 > w1 = "1904621738309688096963972747021004236006856501929784086088263854997343616028245335782672717133232796105937497394115918619762108507459190371110761436019731."; - EXPECT_EQ(w0 > w1, true); EXPECT_EQ(w0 < w1, false); EXPECT_EQ(w0 == w1, false); EXPECT_EQ(w0 <= w1, false); EXPECT_EQ(w0 >= w1, true); - - Aesi < 832 > w2 = "1608527768883990322596558903852740582856946676239724229707184450409975434453026393098859529161823808676893875886977515885103566841259965348621271025402377."; - Aesi < 928 > w3 = "9264537525192961492920807673589586458619947286002969570716001383731181872666750009284817729212607927865438777724068672750499683225134178232460618168854653."; - EXPECT_EQ(w2 > w3, false); EXPECT_EQ(w2 < w3, true); EXPECT_EQ(w2 == w3, false); EXPECT_EQ(w2 <= w3, true); EXPECT_EQ(w2 >= w3, false); - - Aesi < 672 > w4 = "8579827921780022714884547290034378163774108129266616834606286594438931625536525596709068697345341040201100448364689826680071893580936937957610052613081503."; - Aesi < 704 > w5 = "4353932857600256560604450130831729241817180433084663548890401953025274643710608816125275143869421043054941642599587128920529537059916068803843833176187770."; - EXPECT_EQ(w4 > w5, true); EXPECT_EQ(w4 < w5, false); EXPECT_EQ(w4 == w5, false); EXPECT_EQ(w4 <= w5, false); EXPECT_EQ(w4 >= w5, true); - - Aesi < 576 > w6 = "837363882469384814164952858984059650355806238701150383913125321024093714315545932995066845284083699573306282442802270246233059081589269545802183534735843."; - Aesi < 704 > w7 = "7731750803156293935191942144055527377474680976937305234083822329607259619397574929801911408641020544442317524152432769460529344525963935880147268229930508."; - EXPECT_EQ(w6 > w7, false); EXPECT_EQ(w6 < w7, true); EXPECT_EQ(w6 == w7, false); EXPECT_EQ(w6 <= w7, true); EXPECT_EQ(w6 >= w7, false); - - Aesi < 704 > w8 = "7536263050490565784722454436897360691124905272644727501491606897904633953254516480728770377343185025733063180690756799587717934894237741180009108826737672."; - Aesi < 960 > w9 = "9785117833891594297302388093439791408341957957429923557391375696070213737091713543379508965659146178208818274995583845378946146343828812972191399400454209."; - EXPECT_EQ(w8 > w9, false); EXPECT_EQ(w8 < w9, true); EXPECT_EQ(w8 == w9, false); EXPECT_EQ(w8 <= w9, true); EXPECT_EQ(w8 >= w9, false); - - Aesi < 928 > w10 = "2331423915028866101033025839817989074357888329399814943542917056620393570067871432936269852626341295886857789978014171435135791877059796516711485550203465."; - Aesi < 672 > w11 = "7745825910141249499725353135181692628097643206488293885369721934127831738767685201042473212522535630556399221231683431142973470757582916543147215295832944."; - EXPECT_EQ(w10 > w11, false); EXPECT_EQ(w10 < w11, true); EXPECT_EQ(w10 == w11, false); EXPECT_EQ(w10 <= w11, true); EXPECT_EQ(w10 >= w11, false); - - Aesi < 672 > w12 = "6010689247913118750914877951714565850358068476829349002827096996500473540734241191493186757836276265003354018849837858648044157237137147977356603462247976."; - Aesi < 896 > w13 = "11766646147627630263492856923292408536109594279314009411863240172215973616085233468086875968110723620529952527224499208633039077550993487371141270612368284."; - EXPECT_EQ(w12 > w13, false); EXPECT_EQ(w12 < w13, true); EXPECT_EQ(w12 == w13, false); EXPECT_EQ(w12 <= w13, true); EXPECT_EQ(w12 >= w13, false); - - Aesi < 960 > w14 = "8949677366818190842842495948207569603637256225586182954474638379962428855694788650192065845847312450317154319571908874868168565693565381410614023897487213."; - Aesi < 640 > w15 = "6792756248103380558712593145548796869130188720614777583924722213964574779639694879660794884491993053072747273195944643404339093226397445288317353333298087."; - EXPECT_EQ(w14 > w15, true); EXPECT_EQ(w14 < w15, false); EXPECT_EQ(w14 == w15, false); EXPECT_EQ(w14 <= w15, false); EXPECT_EQ(w14 >= w15, true); - - Aesi < 896 > w16 = "4853564780444502345664478180652531083639882443619084538577328261540801292330371663846790980477997252068354682938446302512986164360263653532392761778201023."; - Aesi < 736 > w17 = "6770098789183303901383314637059158698365510308472153618337470099663190699149619628833529996140272095038275426499167720943531633548912498771362668845338366."; - EXPECT_EQ(w16 > w17, false); EXPECT_EQ(w16 < w17, true); EXPECT_EQ(w16 == w17, false); EXPECT_EQ(w16 <= w17, true); EXPECT_EQ(w16 >= w17, false); - - Aesi < 864 > w18 = "5123332965425726020415728284273984554396243365593103938510645377065224253429268341674095065301111253055817672749359490965436163881090516328866147747617388."; - Aesi < 832 > w19 = "3348664783594785907997655989843079164997608599512229561090714178899335579893590368913874350327704267510582884132085125234569970394461817996218403044545554."; - EXPECT_EQ(w18 > w19, true); EXPECT_EQ(w18 < w19, false); EXPECT_EQ(w18 == w19, false); EXPECT_EQ(w18 <= w19, false); EXPECT_EQ(w18 >= w19, true); -} \ No newline at end of file diff --git a/test/boolean/boolean_device.cpp b/test/boolean/boolean_device.cpp deleted file mode 100644 index a7481e8..0000000 --- a/test/boolean/boolean_device.cpp +++ /dev/null @@ -1,313 +0,0 @@ -#include -#define DEVICE_TESTING -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" - -TEST(Boolean, ThreeWayComparasionDevice) { - Aesi512 m0 = 414346834219605873, m1 = 6659613388634065159; - EXPECT_EQ(m0 < m1, true); - - EXPECT_EQ(m0 > m1, false); EXPECT_EQ(m0 == m1, false); - Aesi512 m2 = 3777391648886866941, m3 = 6468128258198177311; EXPECT_EQ(m2 < m3, true); EXPECT_EQ(m2 > m3, false); EXPECT_EQ(m2 == m3, false); - Aesi512 m4 = 4972396199517127393, m5 = 2356794928604248388; EXPECT_EQ(m4 < m5, false); EXPECT_EQ(m4 > m5, true); EXPECT_EQ(m4 == m5, false); - Aesi512 m6 = 5698574201897137468, m7 = 6027866109546041412; EXPECT_EQ(m6 < m7, true); EXPECT_EQ(m6 > m7, false); EXPECT_EQ(m6 == m7, false); - Aesi512 m8 = 7239889242476444263, m9 = 6391130626438688626; EXPECT_EQ(m8 < m9, false); EXPECT_EQ(m8 > m9, true); EXPECT_EQ(m8 == m9, false); - Aesi512 m10 = 3438368610131831025, m11 = 17774641511006347; EXPECT_EQ(m10 < m11, false); EXPECT_EQ(m10 > m11, true); EXPECT_EQ(m10 == m11, false); - Aesi512 m12 = 7403892229775225334, m13 = 4792187032939839463; EXPECT_EQ(m12 < m13, false); EXPECT_EQ(m12 > m13, true); EXPECT_EQ(m12 == m13, false); - Aesi512 m14 = 7063460168526027038, m15 = 7073029733375674038; EXPECT_EQ(m14 < m15, true); EXPECT_EQ(m14 > m15, false); EXPECT_EQ(m14 == m15, false); - Aesi512 m16 = 3276326228016273221, m17 = 4684704472030591797; EXPECT_EQ(m16 < m17, true); EXPECT_EQ(m16 > m17, false); EXPECT_EQ(m16 == m17, false); - Aesi512 m18 = 4347413549370960786, m19 = 8261767534481581646; EXPECT_EQ(m18 < m19, true); EXPECT_EQ(m18 > m19, false); EXPECT_EQ(m18 == m19, false); - Aesi512 m20 = 3217208224507157627, m21 = 5343460665076815773; EXPECT_EQ(m20 < m21, true); EXPECT_EQ(m20 > m21, false); EXPECT_EQ(m20 == m21, false); - Aesi512 m22 = 3553831604978278739, m23 = 1956925562179864685; EXPECT_EQ(m22 < m23, false); EXPECT_EQ(m22 > m23, true); EXPECT_EQ(m22 == m23, false); - Aesi512 m24 = 4421788051285594566, m25 = 1307160148762376915; EXPECT_EQ(m24 < m25, false); EXPECT_EQ(m24 > m25, true); EXPECT_EQ(m24 == m25, false); - Aesi512 m26 = 4941475767464726707, m27 = 5096508184363427411; EXPECT_EQ(m26 < m27, true); EXPECT_EQ(m26 > m27, false); EXPECT_EQ(m26 == m27, false); - Aesi512 m28 = 2557138060934038665, m29 = 2645213282532565144; EXPECT_EQ(m28 < m29, true); EXPECT_EQ(m28 > m29, false); EXPECT_EQ(m28 == m29, false); - Aesi512 m30 = 6288879661041105803, m31 = 6168987288585263111; EXPECT_EQ(m30 < m31, false); EXPECT_EQ(m30 > m31, true); EXPECT_EQ(m30 == m31, false); - Aesi512 m32 = 972058579054229552, m33 = 1137174755634575008; EXPECT_EQ(m32 < m33, true); EXPECT_EQ(m32 > m33, false); EXPECT_EQ(m32 == m33, false); - Aesi512 m34 = 3492684949614696086, m35 = 1363828522052130623; EXPECT_EQ(m34 < m35, false); EXPECT_EQ(m34 > m35, true); EXPECT_EQ(m34 == m35, false); - Aesi512 m36 = 2436944419145784980, m37 = 5304314784521859337; EXPECT_EQ(m36 < m37, true); EXPECT_EQ(m36 > m37, false); EXPECT_EQ(m36 == m37, false); - Aesi512 m38 = 3170900660535921265, m39 = 660482510578155528; EXPECT_EQ(m38 < m39, false); EXPECT_EQ(m38 > m39, true); EXPECT_EQ(m38 == m39, false); - Aesi512 m40 = 3085504072638658500, m41 = 7007133823746771031; EXPECT_EQ(m40 < m41, true); EXPECT_EQ(m40 > m41, false); EXPECT_EQ(m40 == m41, false); - Aesi512 m42 = 3432511087466748985, m43 = 1255067700531598077; EXPECT_EQ(m42 < m43, false); EXPECT_EQ(m42 > m43, true); EXPECT_EQ(m42 == m43, false); - Aesi512 m44 = 7532364332456708765, m45 = 949591788854171522; EXPECT_EQ(m44 < m45, false); EXPECT_EQ(m44 > m45, true); EXPECT_EQ(m44 == m45, false); - Aesi512 m46 = 54939895533594070, m47 = 9101505712605303811; EXPECT_EQ(m46 < m47, true); EXPECT_EQ(m46 > m47, false); EXPECT_EQ(m46 == m47, false); - Aesi512 m48 = 3371042159109744935, m49 = 7589963848208471409; EXPECT_EQ(m48 < m49, true); EXPECT_EQ(m48 > m49, false); EXPECT_EQ(m48 == m49, false); - Aesi512 m50 = 38949621236659657, m51 = 4623324737003921866; EXPECT_EQ(m50 < m51, true); EXPECT_EQ(m50 > m51, false); EXPECT_EQ(m50 == m51, false); - Aesi512 m52 = 6269751571827533743, m53 = 705840858828118559; EXPECT_EQ(m52 < m53, false); EXPECT_EQ(m52 > m53, true); EXPECT_EQ(m52 == m53, false); - Aesi512 m54 = 2183551194768087143, m55 = 4335206954719021198; EXPECT_EQ(m54 < m55, true); EXPECT_EQ(m54 > m55, false); EXPECT_EQ(m54 == m55, false); - Aesi512 m56 = 1999204758953635755, m57 = 7365785092911923004; EXPECT_EQ(m56 < m57, true); EXPECT_EQ(m56 > m57, false); EXPECT_EQ(m56 == m57, false); - Aesi512 m58 = 8399168629459945903, m59 = 7121060735935892344; EXPECT_EQ(m58 < m59, false); EXPECT_EQ(m58 > m59, true); EXPECT_EQ(m58 == m59, false); - Aesi512 m60 = 5205307955382016007, m61 = 2701357050471651049; EXPECT_EQ(m60 < m61, false); EXPECT_EQ(m60 > m61, true); EXPECT_EQ(m60 == m61, false); - Aesi512 m62 = 8138856079182018445, m63 = 2649268548526188594; EXPECT_EQ(m62 < m63, false); EXPECT_EQ(m62 > m63, true); EXPECT_EQ(m62 == m63, false); - Aesi512 m64 = 770044563987128846, m65 = 1792903910217322047; EXPECT_EQ(m64 < m65, true); EXPECT_EQ(m64 > m65, false); EXPECT_EQ(m64 == m65, false); - Aesi512 m66 = 149780000886157566, m67 = 3286379546181327754; EXPECT_EQ(m66 < m67, true); EXPECT_EQ(m66 > m67, false); EXPECT_EQ(m66 == m67, false); - Aesi512 m68 = 3518911934789621791, m69 = 3007605772752747285; EXPECT_EQ(m68 < m69, false); EXPECT_EQ(m68 > m69, true); EXPECT_EQ(m68 == m69, false); - Aesi512 m70 = 8671267707460523770, m71 = 1086974085630165141; EXPECT_EQ(m70 < m71, false); EXPECT_EQ(m70 > m71, true); EXPECT_EQ(m70 == m71, false); - Aesi512 m72 = 5599330006900864892, m73 = 1312306540840205361; EXPECT_EQ(m72 < m73, false); EXPECT_EQ(m72 > m73, true); EXPECT_EQ(m72 == m73, false); - Aesi512 m74 = 6493662685566076910, m75 = 928471421419528716; EXPECT_EQ(m74 < m75, false); EXPECT_EQ(m74 > m75, true); EXPECT_EQ(m74 == m75, false); - Aesi512 m76 = 667356054549450309, m77 = 6272067595934850214; EXPECT_EQ(m76 < m77, true); EXPECT_EQ(m76 > m77, false); EXPECT_EQ(m76 == m77, false); - Aesi512 m78 = 8408798539754633924, m79 = 629762994379608327; EXPECT_EQ(m78 < m79, false); EXPECT_EQ(m78 > m79, true); EXPECT_EQ(m78 == m79, false); - Aesi512 m80 = 3914077811021313731, m81 = 638948969089289101; EXPECT_EQ(m80 < m81, false); EXPECT_EQ(m80 > m81, true); EXPECT_EQ(m80 == m81, false); - Aesi512 m82 = 9065483488715709442, m83 = 269056060969562416; EXPECT_EQ(m82 < m83, false); EXPECT_EQ(m82 > m83, true); EXPECT_EQ(m82 == m83, false); - Aesi512 m84 = 3640842096633396468, m85 = 6629450212748541735; EXPECT_EQ(m84 < m85, true); EXPECT_EQ(m84 > m85, false); EXPECT_EQ(m84 == m85, false); - Aesi512 m86 = 6244623324629960355, m87 = 8957975136903626022; EXPECT_EQ(m86 < m87, true); EXPECT_EQ(m86 > m87, false); EXPECT_EQ(m86 == m87, false); - Aesi512 m88 = 361777666027439923, m89 = 8473580075031122599; EXPECT_EQ(m88 < m89, true); EXPECT_EQ(m88 > m89, false); EXPECT_EQ(m88 == m89, false); - Aesi512 m90 = 2214964541608998768, m91 = 3916091209448393772; EXPECT_EQ(m90 < m91, true); EXPECT_EQ(m90 > m91, false); EXPECT_EQ(m90 == m91, false); - Aesi512 m92 = 8286608739462589926, m93 = 2211701376556461485; EXPECT_EQ(m92 < m93, false); EXPECT_EQ(m92 > m93, true); EXPECT_EQ(m92 == m93, false); - Aesi512 m94 = 6712142162915751904, m95 = 8688782718315824219; EXPECT_EQ(m94 < m95, true); EXPECT_EQ(m94 > m95, false); EXPECT_EQ(m94 == m95, false); - Aesi512 m96 = 1621146558575049424, m97 = 900422204676489270; EXPECT_EQ(m96 < m97, false); EXPECT_EQ(m96 > m97, true); EXPECT_EQ(m96 == m97, false); - Aesi512 m98 = 7221541927100992379, m99 = 5143259391773772944; EXPECT_EQ(m98 < m99, false); EXPECT_EQ(m98 > m99, true); EXPECT_EQ(m98 == m99, false); - - Aesi512 y0 = 7636576598697294436, y1 = 7636576598697294436; EXPECT_EQ(y0 < y1, false); EXPECT_EQ(y0 > y1, false); EXPECT_EQ(y0 == y1, true); - Aesi512 y2 = 1396390219352036105, y3 = 1396390219352036105; EXPECT_EQ(y2 < y3, false); EXPECT_EQ(y2 > y3, false); EXPECT_EQ(y2 == y3, true); - Aesi512 y4 = 1876370602312243611, y5 = 1876370602312243611; EXPECT_EQ(y4 < y5, false); EXPECT_EQ(y4 > y5, false); EXPECT_EQ(y4 == y5, true); - Aesi512 y6 = 4389894041997426185, y7 = 4389894041997426185; EXPECT_EQ(y6 < y7, false); EXPECT_EQ(y6 > y7, false); EXPECT_EQ(y6 == y7, true); - Aesi512 y8 = 8757835874326958730, y9 = 8757835874326958730; EXPECT_EQ(y8 < y9, false); EXPECT_EQ(y8 > y9, false); EXPECT_EQ(y8 == y9, true); - Aesi512 y10 = 7654701489846959904, y11 = 7654701489846959904; EXPECT_EQ(y10 < y11, false); EXPECT_EQ(y10 > y11, false); EXPECT_EQ(y10 == y11, true); - Aesi512 y12 = 7951596781520787173, y13 = 7951596781520787173; EXPECT_EQ(y12 < y13, false); EXPECT_EQ(y12 > y13, false); EXPECT_EQ(y12 == y13, true); - Aesi512 y14 = 3979006791513237631, y15 = 3979006791513237631; EXPECT_EQ(y14 < y15, false); EXPECT_EQ(y14 > y15, false); EXPECT_EQ(y14 == y15, true); - Aesi512 y16 = 8646789167372071802, y17 = 8646789167372071802; EXPECT_EQ(y16 < y17, false); EXPECT_EQ(y16 > y17, false); EXPECT_EQ(y16 == y17, true); - Aesi512 y18 = 93790031817935795, y19 = 93790031817935795; EXPECT_EQ(y18 < y19, false); EXPECT_EQ(y18 > y19, false); EXPECT_EQ(y18 == y19, true); - - Aesi512 t0 = "324939500766121887776989132520157389914.", t1 = "313651970083237033009921276535943692201."; EXPECT_EQ(t0 < t1, false); EXPECT_EQ(t0 > t1, true); EXPECT_EQ(t0 == t1, false); - Aesi512 t2 = "113525738071664729078943235110580655685.", t3 = "13929167430938083152246656926579649132."; EXPECT_EQ(t2 < t3, false); EXPECT_EQ(t2 > t3, true); EXPECT_EQ(t2 == t3, false); - Aesi512 t4 = "95573144668940997682867099911666029538.", t5 = "70541771947794926908949781993341392162."; EXPECT_EQ(t4 < t5, false); EXPECT_EQ(t4 > t5, true); EXPECT_EQ(t4 == t5, false); - Aesi512 t6 = "217753375092567613098572020793925951275.", t7 = "70989984400829639410577012954876470650."; EXPECT_EQ(t6 < t7, false); EXPECT_EQ(t6 > t7, true); EXPECT_EQ(t6 == t7, false); - Aesi512 t8 = "72343605821393319507823307883363815745.", t9 = "103744356900317989401006302403021123558."; EXPECT_EQ(t8 < t9, true); EXPECT_EQ(t8 > t9, false); EXPECT_EQ(t8 == t9, false); - Aesi512 t10 = "254408353941258204008073532779355501906.", t11 = "296434823387921938219937036586287595724."; EXPECT_EQ(t10 < t11, true); EXPECT_EQ(t10 > t11, false); EXPECT_EQ(t10 == t11, false); - Aesi512 t12 = "233106448577166852344552427720324076662.", t13 = "146998695685653522484527493024100140868."; EXPECT_EQ(t12 < t13, false); EXPECT_EQ(t12 > t13, true); EXPECT_EQ(t12 == t13, false); - Aesi512 t14 = "71065572425616389606933209832564494154.", t15 = "125952696820341424478881652454300412976."; EXPECT_EQ(t14 < t15, true); EXPECT_EQ(t14 > t15, false); EXPECT_EQ(t14 == t15, false); - Aesi512 t16 = "86981402744622618508794329665032117784.", t17 = "90062431767761460667132096232442477985."; EXPECT_EQ(t16 < t17, true); EXPECT_EQ(t16 > t17, false); EXPECT_EQ(t16 == t17, false); - Aesi512 t18 = "40794572753000119890755984109845385310.", t19 = "257764250778095484096536807614811739299."; EXPECT_EQ(t18 < t19, true); EXPECT_EQ(t18 > t19, false); EXPECT_EQ(t18 == t19, false); - Aesi512 t20 = "312774166924990695497923750357672208998.", t21 = "138619920625570134587678613476004938262."; EXPECT_EQ(t20 < t21, false); EXPECT_EQ(t20 > t21, true); EXPECT_EQ(t20 == t21, false); - Aesi512 t22 = "325975764569618235531390597703790209456.", t23 = "137912901742229895471269806999555976430."; EXPECT_EQ(t22 < t23, false); EXPECT_EQ(t22 > t23, true); EXPECT_EQ(t22 == t23, false); - Aesi512 t24 = "337442615207270184626713361248728817083.", t25 = "324000408147831083391287599791811201285."; EXPECT_EQ(t24 < t25, false); EXPECT_EQ(t24 > t25, true); EXPECT_EQ(t24 == t25, false); - Aesi512 t26 = "75953667207052653075645410180347682805.", t27 = "244397417632611308300332906532850228154."; EXPECT_EQ(t26 < t27, true); EXPECT_EQ(t26 > t27, false); EXPECT_EQ(t26 == t27, false); - Aesi512 t28 = "151174923469770731594949669687977333008.", t29 = "114372551977547693458467931975844458957."; EXPECT_EQ(t28 < t29, false); EXPECT_EQ(t28 > t29, true); EXPECT_EQ(t28 == t29, false); - Aesi512 t30 = "71282640392978365219042927132403007300.", t31 = "64776430772469175589245719046354753309."; EXPECT_EQ(t30 < t31, false); EXPECT_EQ(t30 > t31, true); EXPECT_EQ(t30 == t31, false); - Aesi512 t32 = "99873469711907571120093206888741228295.", t33 = "276637020477283033118710293236348206516."; EXPECT_EQ(t32 < t33, true); EXPECT_EQ(t32 > t33, false); EXPECT_EQ(t32 == t33, false); - Aesi512 t34 = "277798048861970991107500020599537058284.", t35 = "206461559777151460105973820516981920331."; EXPECT_EQ(t34 < t35, false); EXPECT_EQ(t34 > t35, true); EXPECT_EQ(t34 == t35, false); - Aesi512 t36 = "231338116801192999291775104728364884786.", t37 = "24086954687018060137824732538450701307."; EXPECT_EQ(t36 < t37, false); EXPECT_EQ(t36 > t37, true); EXPECT_EQ(t36 == t37, false); - Aesi512 t38 = "147455661854833613701634027019553261374.", t39 = "101447150847979598303315727908809952024."; EXPECT_EQ(t38 < t39, false); EXPECT_EQ(t38 > t39, true); EXPECT_EQ(t38 == t39, false); - Aesi512 t40 = "220118391480820413692978138215126754530.", t41 = "16042042494712438039600213355560636803."; EXPECT_EQ(t40 < t41, false); EXPECT_EQ(t40 > t41, true); EXPECT_EQ(t40 == t41, false); - Aesi512 t42 = "105857878112771122324277433293095047345.", t43 = "181190761266488384177216932916196598985."; EXPECT_EQ(t42 < t43, true); EXPECT_EQ(t42 > t43, false); EXPECT_EQ(t42 == t43, false); - Aesi512 t44 = "26444578214835905822403473389111521093.", t45 = "47754768225433710784305091293551132794."; EXPECT_EQ(t44 < t45, true); EXPECT_EQ(t44 > t45, false); EXPECT_EQ(t44 == t45, false); - Aesi512 t46 = "141590742635288855355090153355343954974.", t47 = "110970723510498957603667017570927953996."; EXPECT_EQ(t46 < t47, false); EXPECT_EQ(t46 > t47, true); EXPECT_EQ(t46 == t47, false); - Aesi512 t48 = "147103771560797877203312287440574994709.", t49 = "155568902714945936263413220822114199796."; EXPECT_EQ(t48 < t49, true); EXPECT_EQ(t48 > t49, false); EXPECT_EQ(t48 == t49, false); - Aesi512 t50 = "86166821637078430841876191320980816008.", t51 = "47447850811363226836906574751178707331."; EXPECT_EQ(t50 < t51, false); EXPECT_EQ(t50 > t51, true); EXPECT_EQ(t50 == t51, false); - Aesi512 t52 = "232410844136943063440793306378450174100.", t53 = "92738147185701937980784084818084849824."; EXPECT_EQ(t52 < t53, false); EXPECT_EQ(t52 > t53, true); EXPECT_EQ(t52 == t53, false); - Aesi512 t54 = "110993559123871965884413268130942500430.", t55 = "63477113954003042618257340487353738955."; EXPECT_EQ(t54 < t55, false); EXPECT_EQ(t54 > t55, true); EXPECT_EQ(t54 == t55, false); - Aesi512 t56 = "89998138274682985946382223651935379503.", t57 = "109368149949915834771162982692840347435."; EXPECT_EQ(t56 < t57, true); EXPECT_EQ(t56 > t57, false); EXPECT_EQ(t56 == t57, false); - Aesi512 t58 = "241738944914483206497826954846138803776.", t59 = "21017631577893517110835833222291387722."; EXPECT_EQ(t58 < t59, false); EXPECT_EQ(t58 > t59, true); EXPECT_EQ(t58 == t59, false); - Aesi512 t60 = "105812883288657769634427078438956637851.", t61 = "182490232501620116097581302468350430434."; EXPECT_EQ(t60 < t61, true); EXPECT_EQ(t60 > t61, false); EXPECT_EQ(t60 == t61, false); - Aesi512 t62 = "258347523703720138001693872816400860402.", t63 = "210548410397818372465483492374687954671."; EXPECT_EQ(t62 < t63, false); EXPECT_EQ(t62 > t63, true); EXPECT_EQ(t62 == t63, false); - Aesi512 t64 = "45933834983852240184271702028917988822.", t65 = "304271539279531203296635338827918527937."; EXPECT_EQ(t64 < t65, true); EXPECT_EQ(t64 > t65, false); EXPECT_EQ(t64 == t65, false); - Aesi512 t66 = "307051708410080545187705939745150947120.", t67 = "162108995280292283518002783834314209620."; EXPECT_EQ(t66 < t67, false); EXPECT_EQ(t66 > t67, true); EXPECT_EQ(t66 == t67, false); - Aesi512 t68 = "24730384800343530681380055881806738251.", t69 = "40985089774364269480143776962615168941."; EXPECT_EQ(t68 < t69, true); EXPECT_EQ(t68 > t69, false); EXPECT_EQ(t68 == t69, false); - Aesi512 t70 = "22458954845804307568549438283719976060.", t71 = "223032349646169984483889256932473799343."; EXPECT_EQ(t70 < t71, true); EXPECT_EQ(t70 > t71, false); EXPECT_EQ(t70 == t71, false); - Aesi512 t72 = "305060433655032032750655207149229870339.", t73 = "330661677566482326307184091739866399144."; EXPECT_EQ(t72 < t73, true); EXPECT_EQ(t72 > t73, false); EXPECT_EQ(t72 == t73, false); - Aesi512 t74 = "21830124334505988243416303696230675143.", t75 = "256975399875244308775605682125711072356."; EXPECT_EQ(t74 < t75, true); EXPECT_EQ(t74 > t75, false); EXPECT_EQ(t74 == t75, false); - Aesi512 t76 = "10106776841877628906556529998336851136.", t77 = "140499109957437765170588170443474618364."; EXPECT_EQ(t76 < t77, true); EXPECT_EQ(t76 > t77, false); EXPECT_EQ(t76 == t77, false); - Aesi512 t78 = "209320672993651306188546028442577005044.", t79 = "83940258953085319745707620636036242513."; EXPECT_EQ(t78 < t79, false); EXPECT_EQ(t78 > t79, true); EXPECT_EQ(t78 == t79, false); - Aesi512 t80 = "238629468242661113413937696337627500466.", t81 = "126241821422924508630309679727133947668."; EXPECT_EQ(t80 < t81, false); EXPECT_EQ(t80 > t81, true); EXPECT_EQ(t80 == t81, false); - Aesi512 t82 = "87018120690449434646662256705878145525.", t83 = "106118676359859726242661467865634124736."; EXPECT_EQ(t82 < t83, true); EXPECT_EQ(t82 > t83, false); EXPECT_EQ(t82 == t83, false); - Aesi512 t84 = "232579941974117855610802390067801527361.", t85 = "41743939125512799533874470956777949518."; EXPECT_EQ(t84 < t85, false); EXPECT_EQ(t84 > t85, true); EXPECT_EQ(t84 == t85, false); - Aesi512 t86 = "263226738725255548034061468044724111702.", t87 = "226823632790506485730758174277316748382."; EXPECT_EQ(t86 < t87, false); EXPECT_EQ(t86 > t87, true); EXPECT_EQ(t86 == t87, false); - Aesi512 t88 = "234850351049651862824225518842277550757.", t89 = "281202735026210035274953990562039211868."; EXPECT_EQ(t88 < t89, true); EXPECT_EQ(t88 > t89, false); EXPECT_EQ(t88 == t89, false); - Aesi512 t90 = "301038152691713146637055292994491703735.", t91 = "232168404248370260375257410501360850043."; EXPECT_EQ(t90 < t91, false); EXPECT_EQ(t90 > t91, true); EXPECT_EQ(t90 == t91, false); - Aesi512 t92 = "127921205057541692982811515555199038509.", t93 = "276167200383855274004255672376922644196."; EXPECT_EQ(t92 < t93, true); EXPECT_EQ(t92 > t93, false); EXPECT_EQ(t92 == t93, false); - Aesi512 t94 = "49102448900748317928120873911675600079.", t95 = "223935092686163445463267304296447179989."; EXPECT_EQ(t94 < t95, true); EXPECT_EQ(t94 > t95, false); EXPECT_EQ(t94 == t95, false); - Aesi512 t96 = "144552296102978508559535958878071314417.", t97 = "30940923099305680044090950664046154499."; EXPECT_EQ(t96 < t97, false); EXPECT_EQ(t96 > t97, true); EXPECT_EQ(t96 == t97, false); - Aesi512 t98 = "56929180182638190331988369488851676606.", t99 = "247716894024801826719771259223891013186."; EXPECT_EQ(t98 < t99, true); EXPECT_EQ(t98 > t99, false); EXPECT_EQ(t98 == t99, false); - - Aesi512 r0 = "201381435085756820979029715655075876997.", r1 = "201381435085756820979029715655075876997."; EXPECT_EQ(r0 < r1, false); EXPECT_EQ(r0 > r1, false); EXPECT_EQ(r0 == r1, true); - Aesi512 r2 = "229159202763006840583025892455270836892.", r3 = "229159202763006840583025892455270836892."; EXPECT_EQ(r2 < r3, false); EXPECT_EQ(r2 > r3, false); EXPECT_EQ(r2 == r3, true); - Aesi512 r4 = "339146412382362994754581190533478781018.", r5 = "339146412382362994754581190533478781018."; EXPECT_EQ(r4 < r5, false); EXPECT_EQ(r4 > r5, false); EXPECT_EQ(r4 == r5, true); - Aesi512 r6 = "124295398644758189113576493320032040275.", r7 = "124295398644758189113576493320032040275."; EXPECT_EQ(r6 < r7, false); EXPECT_EQ(r6 > r7, false); EXPECT_EQ(r6 == r7, true); - Aesi512 r8 = "295279518426728664929368296744239776609.", r9 = "295279518426728664929368296744239776609."; EXPECT_EQ(r8 < r9, false); EXPECT_EQ(r8 > r9, false); EXPECT_EQ(r8 == r9, true); - Aesi512 r10 = "319643158856528060426277248185756487060.", r11 = "319643158856528060426277248185756487060."; EXPECT_EQ(r10 < r11, false); EXPECT_EQ(r10 > r11, false); EXPECT_EQ(r10 == r11, true); - Aesi512 r12 = "127108996786283808267853584156702042675.", r13 = "127108996786283808267853584156702042675."; EXPECT_EQ(r12 < r13, false); EXPECT_EQ(r12 > r13, false); EXPECT_EQ(r12 == r13, true); - Aesi512 r14 = "123332376598963012950955571465063211860.", r15 = "123332376598963012950955571465063211860."; EXPECT_EQ(r14 < r15, false); EXPECT_EQ(r14 > r15, false); EXPECT_EQ(r14 == r15, true); - Aesi512 r16 = "307003963041772851243779066372380492627.", r17 = "307003963041772851243779066372380492627."; EXPECT_EQ(r16 < r17, false); EXPECT_EQ(r16 > r17, false); EXPECT_EQ(r16 == r17, true); - Aesi512 r18 = "194662908396084132647198018631066653076.", r19 = "194662908396084132647198018631066653076."; EXPECT_EQ(r18 < r19, false); EXPECT_EQ(r18 > r19, false); EXPECT_EQ(r18 == r19, true); -} - -TEST(Boolean, ThreeWayEquallComparasionDevice) { - Aesi512 m0 = 7036437650415461321, m1 = 3512521750905585604; EXPECT_EQ(m0 <= m1, false); EXPECT_EQ(m0 >= m1, true); EXPECT_EQ(m0 == m1, false); - Aesi512 m2 = 1383437920778735070, m3 = 8349814587438416033; EXPECT_EQ(m2 <= m3, true); EXPECT_EQ(m2 >= m3, false); EXPECT_EQ(m2 == m3, false); - Aesi512 m4 = 9113619168792656185, m5 = 4220142331454932859; EXPECT_EQ(m4 <= m5, false); EXPECT_EQ(m4 >= m5, true); EXPECT_EQ(m4 == m5, false); - Aesi512 m6 = 8854558742841206330, m7 = 9114810997037713198; EXPECT_EQ(m6 <= m7, true); EXPECT_EQ(m6 >= m7, false); EXPECT_EQ(m6 == m7, false); - Aesi512 m8 = 7889880532277012269, m9 = 510905311056591919; EXPECT_EQ(m8 <= m9, false); EXPECT_EQ(m8 >= m9, true); EXPECT_EQ(m8 == m9, false); - Aesi512 m10 = 4036861924531831555, m11 = 3838191133844808910; EXPECT_EQ(m10 <= m11, false); EXPECT_EQ(m10 >= m11, true); EXPECT_EQ(m10 == m11, false); - Aesi512 m12 = 4875137103990077450, m13 = 3398410533657158298; EXPECT_EQ(m12 <= m13, false); EXPECT_EQ(m12 >= m13, true); EXPECT_EQ(m12 == m13, false); - Aesi512 m14 = 5307900228590194215, m15 = 7272791637303292964; EXPECT_EQ(m14 <= m15, true); EXPECT_EQ(m14 >= m15, false); EXPECT_EQ(m14 == m15, false); - Aesi512 m16 = 3264831984244893683, m17 = 2045517973749331953; EXPECT_EQ(m16 <= m17, false); EXPECT_EQ(m16 >= m17, true); EXPECT_EQ(m16 == m17, false); - Aesi512 m18 = 5782470229611512575, m19 = 4797501343698587430; EXPECT_EQ(m18 <= m19, false); EXPECT_EQ(m18 >= m19, true); EXPECT_EQ(m18 == m19, false); - Aesi512 m20 = 418722049626410312, m21 = 6389665526464147971; EXPECT_EQ(m20 <= m21, true); EXPECT_EQ(m20 >= m21, false); EXPECT_EQ(m20 == m21, false); - Aesi512 m22 = 1136371225733026514, m23 = 4865828314681372077; EXPECT_EQ(m22 <= m23, true); EXPECT_EQ(m22 >= m23, false); EXPECT_EQ(m22 == m23, false); - Aesi512 m24 = 1289355361274959863, m25 = 2889754703404589325; EXPECT_EQ(m24 <= m25, true); EXPECT_EQ(m24 >= m25, false); EXPECT_EQ(m24 == m25, false); - Aesi512 m26 = 1765701753457030832, m27 = 3917563358976747341; EXPECT_EQ(m26 <= m27, true); EXPECT_EQ(m26 >= m27, false); EXPECT_EQ(m26 == m27, false); - Aesi512 m28 = 2221444770594720113, m29 = 6362993791298458990; EXPECT_EQ(m28 <= m29, true); EXPECT_EQ(m28 >= m29, false); EXPECT_EQ(m28 == m29, false); - Aesi512 m30 = 4675703906955057488, m31 = 7632776120455549467; EXPECT_EQ(m30 <= m31, true); EXPECT_EQ(m30 >= m31, false); EXPECT_EQ(m30 == m31, false); - Aesi512 m32 = 4134506495922632915, m33 = 7756013962571547686; EXPECT_EQ(m32 <= m33, true); EXPECT_EQ(m32 >= m33, false); EXPECT_EQ(m32 == m33, false); - Aesi512 m34 = 2549158072032400321, m35 = 4141043625639388388; EXPECT_EQ(m34 <= m35, true); EXPECT_EQ(m34 >= m35, false); EXPECT_EQ(m34 == m35, false); - Aesi512 m36 = 1541700670473320539, m37 = 8134880522594404560; EXPECT_EQ(m36 <= m37, true); EXPECT_EQ(m36 >= m37, false); EXPECT_EQ(m36 == m37, false); - Aesi512 m38 = 7623735422058825916, m39 = 8449121021456094098; EXPECT_EQ(m38 <= m39, true); EXPECT_EQ(m38 >= m39, false); EXPECT_EQ(m38 == m39, false); - Aesi512 m40 = 6553339632492361232, m41 = 6629792053215301617; EXPECT_EQ(m40 <= m41, true); EXPECT_EQ(m40 >= m41, false); EXPECT_EQ(m40 == m41, false); - Aesi512 m42 = 1313902652864581146, m43 = 2733413829789594072; EXPECT_EQ(m42 <= m43, true); EXPECT_EQ(m42 >= m43, false); EXPECT_EQ(m42 == m43, false); - Aesi512 m44 = 27343049037018, m45 = 8022928103331756098; EXPECT_EQ(m44 <= m45, true); EXPECT_EQ(m44 >= m45, false); EXPECT_EQ(m44 == m45, false); - Aesi512 m46 = 1055546162731508668, m47 = 7495329233645082183; EXPECT_EQ(m46 <= m47, true); EXPECT_EQ(m46 >= m47, false); EXPECT_EQ(m46 == m47, false); - Aesi512 m48 = 6664038168252544455, m49 = 8555906633884133989; EXPECT_EQ(m48 <= m49, true); EXPECT_EQ(m48 >= m49, false); EXPECT_EQ(m48 == m49, false); - Aesi512 m50 = 2472632171088761660, m51 = 4239713703857228583; EXPECT_EQ(m50 <= m51, true); EXPECT_EQ(m50 >= m51, false); EXPECT_EQ(m50 == m51, false); - Aesi512 m52 = 5431978097832685807, m53 = 4524383677364403319; EXPECT_EQ(m52 <= m53, false); EXPECT_EQ(m52 >= m53, true); EXPECT_EQ(m52 == m53, false); - Aesi512 m54 = 3079862986050289708, m55 = 4268174738292388808; EXPECT_EQ(m54 <= m55, true); EXPECT_EQ(m54 >= m55, false); EXPECT_EQ(m54 == m55, false); - Aesi512 m56 = 641845823960688083, m57 = 7034968042387272505; EXPECT_EQ(m56 <= m57, true); EXPECT_EQ(m56 >= m57, false); EXPECT_EQ(m56 == m57, false); - Aesi512 m58 = 5430749132593562075, m59 = 787085028870740916; EXPECT_EQ(m58 <= m59, false); EXPECT_EQ(m58 >= m59, true); EXPECT_EQ(m58 == m59, false); - Aesi512 m60 = 3282605692920022499, m61 = 1891317284651541150; EXPECT_EQ(m60 <= m61, false); EXPECT_EQ(m60 >= m61, true); EXPECT_EQ(m60 == m61, false); - Aesi512 m62 = 1632589097292541517, m63 = 3719141934289191346; EXPECT_EQ(m62 <= m63, true); EXPECT_EQ(m62 >= m63, false); EXPECT_EQ(m62 == m63, false); - Aesi512 m64 = 6786397205444165792, m65 = 2755389661894147555; EXPECT_EQ(m64 <= m65, false); EXPECT_EQ(m64 >= m65, true); EXPECT_EQ(m64 == m65, false); - Aesi512 m66 = 5319321008389350985, m67 = 5027760907621183804; EXPECT_EQ(m66 <= m67, false); EXPECT_EQ(m66 >= m67, true); EXPECT_EQ(m66 == m67, false); - Aesi512 m68 = 3057905351711841100, m69 = 5319542951096680267; EXPECT_EQ(m68 <= m69, true); EXPECT_EQ(m68 >= m69, false); EXPECT_EQ(m68 == m69, false); - Aesi512 m70 = 8290584765434739153, m71 = 7156475646933033928; EXPECT_EQ(m70 <= m71, false); EXPECT_EQ(m70 >= m71, true); EXPECT_EQ(m70 == m71, false); - Aesi512 m72 = 1804278281437860114, m73 = 3874846944632939529; EXPECT_EQ(m72 <= m73, true); EXPECT_EQ(m72 >= m73, false); EXPECT_EQ(m72 == m73, false); - Aesi512 m74 = 4435339296432742617, m75 = 3826128329360221616; EXPECT_EQ(m74 <= m75, false); EXPECT_EQ(m74 >= m75, true); EXPECT_EQ(m74 == m75, false); - Aesi512 m76 = 4849823403133616055, m77 = 4227365479133156265; EXPECT_EQ(m76 <= m77, false); EXPECT_EQ(m76 >= m77, true); EXPECT_EQ(m76 == m77, false); - Aesi512 m78 = 7814085883082274484, m79 = 1586816423217446834; EXPECT_EQ(m78 <= m79, false); EXPECT_EQ(m78 >= m79, true); EXPECT_EQ(m78 == m79, false); - Aesi512 m80 = 6915561085323458963, m81 = 8919970044012186390; EXPECT_EQ(m80 <= m81, true); EXPECT_EQ(m80 >= m81, false); EXPECT_EQ(m80 == m81, false); - Aesi512 m82 = 863830359948334177, m83 = 8031859615702342273; EXPECT_EQ(m82 <= m83, true); EXPECT_EQ(m82 >= m83, false); EXPECT_EQ(m82 == m83, false); - Aesi512 m84 = 7647248424213586535, m85 = 5145220418143791522; EXPECT_EQ(m84 <= m85, false); EXPECT_EQ(m84 >= m85, true); EXPECT_EQ(m84 == m85, false); - Aesi512 m86 = 7650383719166469560, m87 = 2697335060357100546; EXPECT_EQ(m86 <= m87, false); EXPECT_EQ(m86 >= m87, true); EXPECT_EQ(m86 == m87, false); - Aesi512 m88 = 3418727692309630758, m89 = 4565820036200988802; EXPECT_EQ(m88 <= m89, true); EXPECT_EQ(m88 >= m89, false); EXPECT_EQ(m88 == m89, false); - Aesi512 m90 = 1058630988227384955, m91 = 3340050044751465241; EXPECT_EQ(m90 <= m91, true); EXPECT_EQ(m90 >= m91, false); EXPECT_EQ(m90 == m91, false); - Aesi512 m92 = 5387697094388614096, m93 = 3575048537199532815; EXPECT_EQ(m92 <= m93, false); EXPECT_EQ(m92 >= m93, true); EXPECT_EQ(m92 == m93, false); - Aesi512 m94 = 4397879065975679902, m95 = 8811926327123716778; EXPECT_EQ(m94 <= m95, true); EXPECT_EQ(m94 >= m95, false); EXPECT_EQ(m94 == m95, false); - Aesi512 m96 = 5799331155986527125, m97 = 1611068058870554462; EXPECT_EQ(m96 <= m97, false); EXPECT_EQ(m96 >= m97, true); EXPECT_EQ(m96 == m97, false); - Aesi512 m98 = 4522770317319881104, m99 = 6068149046362325559; EXPECT_EQ(m98 <= m99, true); EXPECT_EQ(m98 >= m99, false); EXPECT_EQ(m98 == m99, false); - - Aesi512 y0 = 8320029752368312075, y1 = 8320029752368312075; EXPECT_EQ(y0 <= y1, true); EXPECT_EQ(y0 >= y1, true); EXPECT_EQ(y0 == y1, true); - Aesi512 y2 = 6007933271507275273, y3 = 6007933271507275273; EXPECT_EQ(y2 <= y3, true); EXPECT_EQ(y2 >= y3, true); EXPECT_EQ(y2 == y3, true); - Aesi512 y4 = 6897640772815461899, y5 = 6897640772815461899; EXPECT_EQ(y4 <= y5, true); EXPECT_EQ(y4 >= y5, true); EXPECT_EQ(y4 == y5, true); - Aesi512 y6 = 4713449543757671635, y7 = 4713449543757671635; EXPECT_EQ(y6 <= y7, true); EXPECT_EQ(y6 >= y7, true); EXPECT_EQ(y6 == y7, true); - Aesi512 y8 = 6120601015759926660, y9 = 6120601015759926660; EXPECT_EQ(y8 <= y9, true); EXPECT_EQ(y8 >= y9, true); EXPECT_EQ(y8 == y9, true); - Aesi512 y10 = 4229106820843609546, y11 = 4229106820843609546; EXPECT_EQ(y10 <= y11, true); EXPECT_EQ(y10 >= y11, true); EXPECT_EQ(y10 == y11, true); - Aesi512 y12 = 1172940937011946395, y13 = 1172940937011946395; EXPECT_EQ(y12 <= y13, true); EXPECT_EQ(y12 >= y13, true); EXPECT_EQ(y12 == y13, true); - Aesi512 y14 = 704072415315244208, y15 = 704072415315244208; EXPECT_EQ(y14 <= y15, true); EXPECT_EQ(y14 >= y15, true); EXPECT_EQ(y14 == y15, true); - Aesi512 y16 = 4553526324210963857, y17 = 4553526324210963857; EXPECT_EQ(y16 <= y17, true); EXPECT_EQ(y16 >= y17, true); EXPECT_EQ(y16 == y17, true); - Aesi512 y18 = 776440877943110513, y19 = 776440877943110513; EXPECT_EQ(y18 <= y19, true); EXPECT_EQ(y18 >= y19, true); EXPECT_EQ(y18 == y19, true); - - Aesi512 t0 = "208178955502460206467631162528747068372.", t1 = "64981800032079918457319292521675272736."; EXPECT_EQ(t0 <= t1, false); EXPECT_EQ(t0 >= t1, true); EXPECT_EQ(t0 == t1, false); - Aesi512 t2 = "247814987693152079030780184492208251996.", t3 = "263966279329761097462235094975616920228."; EXPECT_EQ(t2 <= t3, true); EXPECT_EQ(t2 >= t3, false); EXPECT_EQ(t2 == t3, false); - Aesi512 t4 = "73465800505654103611807329939469945681.", t5 = "202601819576953010517566255364071174458."; EXPECT_EQ(t4 <= t5, true); EXPECT_EQ(t4 >= t5, false); EXPECT_EQ(t4 == t5, false); - Aesi512 t6 = "303173562626122256842896980282946724738.", t7 = "331011772716112637416978127054830470731."; EXPECT_EQ(t6 <= t7, true); EXPECT_EQ(t6 >= t7, false); EXPECT_EQ(t6 == t7, false); - Aesi512 t8 = "3864637642025520502134647523005910787.", t9 = "291611647171610687777257063206651343864."; EXPECT_EQ(t8 <= t9, true); EXPECT_EQ(t8 >= t9, false); EXPECT_EQ(t8 == t9, false); - Aesi512 t10 = "122681455111830759530897853957557799691.", t11 = "21641807652291780444162905870086714666."; EXPECT_EQ(t10 <= t11, false); EXPECT_EQ(t10 >= t11, true); EXPECT_EQ(t10 == t11, false); - Aesi512 t12 = "97308622932868025182709416240848250195.", t13 = "238139569623611316248210436094742215198."; EXPECT_EQ(t12 <= t13, true); EXPECT_EQ(t12 >= t13, false); EXPECT_EQ(t12 == t13, false); - Aesi512 t14 = "165769368746015872918155972307362125984.", t15 = "68178607115076858297662910821149107358."; EXPECT_EQ(t14 <= t15, false); EXPECT_EQ(t14 >= t15, true); EXPECT_EQ(t14 == t15, false); - Aesi512 t16 = "178390421905730097597571154601274281252.", t17 = "294270823573701404652144634939099894142."; EXPECT_EQ(t16 <= t17, true); EXPECT_EQ(t16 >= t17, false); EXPECT_EQ(t16 == t17, false); - Aesi512 t18 = "270522884533698161207117283333044357457.", t19 = "332228325662812845891288989202713144893."; EXPECT_EQ(t18 <= t19, true); EXPECT_EQ(t18 >= t19, false); EXPECT_EQ(t18 == t19, false); - Aesi512 t20 = "127746910442939694123228128880004185590.", t21 = "103398316016400342831112711945912658719."; EXPECT_EQ(t20 <= t21, false); EXPECT_EQ(t20 >= t21, true); EXPECT_EQ(t20 == t21, false); - Aesi512 t22 = "54774663531144817080078282547682586930.", t23 = "130413125151251178830927334536077329589."; EXPECT_EQ(t22 <= t23, true); EXPECT_EQ(t22 >= t23, false); EXPECT_EQ(t22 == t23, false); - Aesi512 t24 = "334479938792989469847436357030676468810.", t25 = "267907787639591756586953273853480160347."; EXPECT_EQ(t24 <= t25, false); EXPECT_EQ(t24 >= t25, true); EXPECT_EQ(t24 == t25, false); - Aesi512 t26 = "289808373193873595805994672251677165856.", t27 = "3415547954405977649762544065718077144."; EXPECT_EQ(t26 <= t27, false); EXPECT_EQ(t26 >= t27, true); EXPECT_EQ(t26 == t27, false); - Aesi512 t28 = "162488969672369099691132364320325400428.", t29 = "232487890714257578245292317189848461700."; EXPECT_EQ(t28 <= t29, true); EXPECT_EQ(t28 >= t29, false); EXPECT_EQ(t28 == t29, false); - Aesi512 t30 = "204999338095425558358401431492357370900.", t31 = "336883581398081627324000171683559598628."; EXPECT_EQ(t30 <= t31, true); EXPECT_EQ(t30 >= t31, false); EXPECT_EQ(t30 == t31, false); - Aesi512 t32 = "83540011534078051356779928573776410534.", t33 = "118739334326883846992070775753049735427."; EXPECT_EQ(t32 <= t33, true); EXPECT_EQ(t32 >= t33, false); EXPECT_EQ(t32 == t33, false); - Aesi512 t34 = "152959503051887842064759736988976887088.", t35 = "333792111201188240171052490312883410582."; EXPECT_EQ(t34 <= t35, true); EXPECT_EQ(t34 >= t35, false); EXPECT_EQ(t34 == t35, false); - Aesi512 t36 = "114051205063069345868250766308095892531.", t37 = "248649722932539943073363213842946493241."; EXPECT_EQ(t36 <= t37, true); EXPECT_EQ(t36 >= t37, false); EXPECT_EQ(t36 == t37, false); - Aesi512 t38 = "337120456781515583909613006093331569117.", t39 = "144251080727274199354551341876378161295."; EXPECT_EQ(t38 <= t39, false); EXPECT_EQ(t38 >= t39, true); EXPECT_EQ(t38 == t39, false); - Aesi512 t40 = "37774293832387647731692596131818426719.", t41 = "53546713384905846788672780538046522671."; EXPECT_EQ(t40 <= t41, true); EXPECT_EQ(t40 >= t41, false); EXPECT_EQ(t40 == t41, false); - Aesi512 t42 = "139075906209510717792673497349319723211.", t43 = "111442717559114847694016330744146925731."; EXPECT_EQ(t42 <= t43, false); EXPECT_EQ(t42 >= t43, true); EXPECT_EQ(t42 == t43, false); - Aesi512 t44 = "292688889761974795557125715195177869596.", t45 = "132711250091382643551347632051872217567."; EXPECT_EQ(t44 <= t45, false); EXPECT_EQ(t44 >= t45, true); EXPECT_EQ(t44 == t45, false); - Aesi512 t46 = "41491796239465277320441567743123820097.", t47 = "91816927434564343790138528288558716997."; EXPECT_EQ(t46 <= t47, true); EXPECT_EQ(t46 >= t47, false); EXPECT_EQ(t46 == t47, false); - Aesi512 t48 = "291971345364142638878677933211972184737.", t49 = "206243892964298824128620955370119376329."; EXPECT_EQ(t48 <= t49, false); EXPECT_EQ(t48 >= t49, true); EXPECT_EQ(t48 == t49, false); - Aesi512 t50 = "24645829244555005526680646607873625323.", t51 = "10775560883385758906125651743021888782."; EXPECT_EQ(t50 <= t51, false); EXPECT_EQ(t50 >= t51, true); EXPECT_EQ(t50 == t51, false); - Aesi512 t52 = "7003801105694981005673402708023678568.", t53 = "190840390076578379023945645793163805932."; EXPECT_EQ(t52 <= t53, true); EXPECT_EQ(t52 >= t53, false); EXPECT_EQ(t52 == t53, false); - Aesi512 t54 = "251232285614817420724156791115728998761.", t55 = "263529632892159387032858900123842651849."; EXPECT_EQ(t54 <= t55, true); EXPECT_EQ(t54 >= t55, false); EXPECT_EQ(t54 == t55, false); - Aesi512 t56 = "96191384646058857857362178296763852617.", t57 = "335647084617490565938717853751076352386."; EXPECT_EQ(t56 <= t57, true); EXPECT_EQ(t56 >= t57, false); EXPECT_EQ(t56 == t57, false); - Aesi512 t58 = "293050967895956966286094450281947760937.", t59 = "178933352163580864276338519437241931046."; EXPECT_EQ(t58 <= t59, false); EXPECT_EQ(t58 >= t59, true); EXPECT_EQ(t58 == t59, false); - Aesi512 t60 = "315179377666218076788266525028181292242.", t61 = "288773657905479367055458565004106921337."; EXPECT_EQ(t60 <= t61, false); EXPECT_EQ(t60 >= t61, true); EXPECT_EQ(t60 == t61, false); - Aesi512 t62 = "126265593080703247475104064649681422296.", t63 = "307000106429701483226411030503732947911."; EXPECT_EQ(t62 <= t63, true); EXPECT_EQ(t62 >= t63, false); EXPECT_EQ(t62 == t63, false); - Aesi512 t64 = "167816843344401231614364966510184716739.", t65 = "222321877185087567501723893111885827385."; EXPECT_EQ(t64 <= t65, true); EXPECT_EQ(t64 >= t65, false); EXPECT_EQ(t64 == t65, false); - Aesi512 t66 = "104282391626031999571561771580323500695.", t67 = "222756463486846559832316141772451875887."; EXPECT_EQ(t66 <= t67, true); EXPECT_EQ(t66 >= t67, false); EXPECT_EQ(t66 == t67, false); - Aesi512 t68 = "17997094960580244957400505408057125382.", t69 = "316417801448472732167088789201944144756."; EXPECT_EQ(t68 <= t69, true); EXPECT_EQ(t68 >= t69, false); EXPECT_EQ(t68 == t69, false); - Aesi512 t70 = "134556065539850228911098327637041204211.", t71 = "209721104206992009604574465620419979422."; EXPECT_EQ(t70 <= t71, true); EXPECT_EQ(t70 >= t71, false); EXPECT_EQ(t70 == t71, false); - Aesi512 t72 = "205241037529658252216054135112031485594.", t73 = "9864779801465999028881839523391943268."; EXPECT_EQ(t72 <= t73, false); EXPECT_EQ(t72 >= t73, true); EXPECT_EQ(t72 == t73, false); - Aesi512 t74 = "241202103888975299969663208658547593183.", t75 = "212288238739844738441258242445949163873."; EXPECT_EQ(t74 <= t75, false); EXPECT_EQ(t74 >= t75, true); EXPECT_EQ(t74 == t75, false); - Aesi512 t76 = "232331673189501438306001832568018677301.", t77 = "76331239888774617908673969833728656188."; EXPECT_EQ(t76 <= t77, false); EXPECT_EQ(t76 >= t77, true); EXPECT_EQ(t76 == t77, false); - Aesi512 t78 = "43924280150439249317128440109694328115.", t79 = "129108133465465422576743107973955337270."; EXPECT_EQ(t78 <= t79, true); EXPECT_EQ(t78 >= t79, false); EXPECT_EQ(t78 == t79, false); - Aesi512 t80 = "255862437061125287488737469784464274573.", t81 = "62357692322648131714769605195885804904."; EXPECT_EQ(t80 <= t81, false); EXPECT_EQ(t80 >= t81, true); EXPECT_EQ(t80 == t81, false); - Aesi512 t82 = "112561266536434499306206990301059330593.", t83 = "326017950097690434318148233964394076673."; EXPECT_EQ(t82 <= t83, true); EXPECT_EQ(t82 >= t83, false); EXPECT_EQ(t82 == t83, false); - Aesi512 t84 = "222241455631770559213894398905676480069.", t85 = "151820972597868329692659902440689692379."; EXPECT_EQ(t84 <= t85, false); EXPECT_EQ(t84 >= t85, true); EXPECT_EQ(t84 == t85, false); - Aesi512 t86 = "306142081957961427681481143717050986531.", t87 = "231686084540554484494636335450945903916."; EXPECT_EQ(t86 <= t87, false); EXPECT_EQ(t86 >= t87, true); EXPECT_EQ(t86 == t87, false); - Aesi512 t88 = "7565614444721577425346826132104632935.", t89 = "73470575329522004281847524465554770404."; EXPECT_EQ(t88 <= t89, true); EXPECT_EQ(t88 >= t89, false); EXPECT_EQ(t88 == t89, false); - Aesi512 t90 = "220569596388830516545779277402514793825.", t91 = "85872645794402465167428474711438097609."; EXPECT_EQ(t90 <= t91, false); EXPECT_EQ(t90 >= t91, true); EXPECT_EQ(t90 == t91, false); - Aesi512 t92 = "157019109965222568769746309494072859572.", t93 = "231750307093221080640225639270898356561."; EXPECT_EQ(t92 <= t93, true); EXPECT_EQ(t92 >= t93, false); EXPECT_EQ(t92 == t93, false); - Aesi512 t94 = "113921713842257195800459812940056209470.", t95 = "14518241355168892446903560766155181648."; EXPECT_EQ(t94 <= t95, false); EXPECT_EQ(t94 >= t95, true); EXPECT_EQ(t94 == t95, false); - Aesi512 t96 = "18527046028903835094982733458489101248.", t97 = "152271184099105487470260317025548245352."; EXPECT_EQ(t96 <= t97, true); EXPECT_EQ(t96 >= t97, false); EXPECT_EQ(t96 == t97, false); - Aesi512 t98 = "254913423786573833959243458222189175211.", t99 = "275475203663087425583025836375912300601."; EXPECT_EQ(t98 <= t99, true); EXPECT_EQ(t98 >= t99, false); EXPECT_EQ(t98 == t99, false); - - Aesi512 r0 = "83006263052236882911121475505611961913.", r1 = "83006263052236882911121475505611961913."; EXPECT_EQ(r0 <= r1, true); EXPECT_EQ(r0 >= r1, true); EXPECT_EQ(r0 == r1, true); - Aesi512 r2 = "199698210511787993107305336800962904524.", r3 = "199698210511787993107305336800962904524."; EXPECT_EQ(r2 <= r3, true); EXPECT_EQ(r2 >= r3, true); EXPECT_EQ(r2 == r3, true); - Aesi512 r4 = "228638879319713518826345372075158184593.", r5 = "228638879319713518826345372075158184593."; EXPECT_EQ(r4 <= r5, true); EXPECT_EQ(r4 >= r5, true); EXPECT_EQ(r4 == r5, true); - Aesi512 r6 = "37529917404847993371235177141408471919.", r7 = "37529917404847993371235177141408471919."; EXPECT_EQ(r6 <= r7, true); EXPECT_EQ(r6 >= r7, true); EXPECT_EQ(r6 == r7, true); - Aesi512 r8 = "106660348004922217465060626445787085234.", r9 = "106660348004922217465060626445787085234."; EXPECT_EQ(r8 <= r9, true); EXPECT_EQ(r8 >= r9, true); EXPECT_EQ(r8 == r9, true); - Aesi512 r10 = "8579128344801168593923881076976628369.", r11 = "8579128344801168593923881076976628369."; EXPECT_EQ(r10 <= r11, true); EXPECT_EQ(r10 >= r11, true); EXPECT_EQ(r10 == r11, true); - Aesi512 r12 = "251066078475156807493829303417733687485.", r13 = "251066078475156807493829303417733687485."; EXPECT_EQ(r12 <= r13, true); EXPECT_EQ(r12 >= r13, true); EXPECT_EQ(r12 == r13, true); - Aesi512 r14 = "69755181066514875766033619263437644053.", r15 = "69755181066514875766033619263437644053."; EXPECT_EQ(r14 <= r15, true); EXPECT_EQ(r14 >= r15, true); EXPECT_EQ(r14 == r15, true); - Aesi512 r16 = "66735372581418058067234560346509638865.", r17 = "66735372581418058067234560346509638865."; EXPECT_EQ(r16 <= r17, true); EXPECT_EQ(r16 >= r17, true); EXPECT_EQ(r16 == r17, true); - Aesi512 r18 = "168496873235580456218434496216410553403.", r19 = "168496873235580456218434496216410553403."; EXPECT_EQ(r18 <= r19, true); EXPECT_EQ(r18 >= r19, true); EXPECT_EQ(r18 == r19, true); -} - -TEST(Boolean, DifferentPrecisionsDevice) { - unsigned long long iv = 9112537908201049656; - Aesi < 256 > o1 = iv; Aesi < 288 > o2 = iv; Aesi < 320 > o3 = iv; Aesi < 352 > o4 = iv; Aesi < 384 > o5 = iv; Aesi < 416 > o6 = iv; Aesi < 448 > o7 = iv; Aesi < 480 > o8 = iv; Aesi < 512 > o9 = iv; Aesi < 544 > o10 = iv; - EXPECT_EQ(o1, o2); - - - EXPECT_EQ(o1, o3); EXPECT_EQ(o1, o4); EXPECT_EQ(o1, o5); EXPECT_EQ(o1, o6); EXPECT_EQ(o1, o7); EXPECT_EQ(o1, o8); EXPECT_EQ(o1, o9); EXPECT_EQ(o1, o10); EXPECT_EQ(o2, o1); EXPECT_EQ(o2, o3); EXPECT_EQ(o2, o4); EXPECT_EQ(o2, o5); EXPECT_EQ(o2, o6); EXPECT_EQ(o2, o7); - EXPECT_EQ(o2, o8); EXPECT_EQ(o2, o9); EXPECT_EQ(o2, o10); EXPECT_EQ(o3, o1); EXPECT_EQ(o3, o2); EXPECT_EQ(o3, o4); EXPECT_EQ(o3, o5); EXPECT_EQ(o3, o6); EXPECT_EQ(o3, o7); EXPECT_EQ(o3, o8); EXPECT_EQ(o3, o9); EXPECT_EQ(o3, o10); EXPECT_EQ(o4, o1); EXPECT_EQ(o4, o2); EXPECT_EQ(o4, o3); - EXPECT_EQ(o4, o5); EXPECT_EQ(o4, o6); EXPECT_EQ(o4, o7); EXPECT_EQ(o4, o8); EXPECT_EQ(o4, o9); EXPECT_EQ(o4, o10); EXPECT_EQ(o5, o1); EXPECT_EQ(o5, o2); EXPECT_EQ(o5, o3); EXPECT_EQ(o5, o4); EXPECT_EQ(o5, o6); EXPECT_EQ(o5, o7); EXPECT_EQ(o5, o8); EXPECT_EQ(o5, o9); EXPECT_EQ(o5, o10); - EXPECT_EQ(o6, o1); EXPECT_EQ(o6, o2); EXPECT_EQ(o6, o3); EXPECT_EQ(o6, o4); EXPECT_EQ(o6, o5); EXPECT_EQ(o6, o7); EXPECT_EQ(o6, o8); EXPECT_EQ(o6, o9); EXPECT_EQ(o6, o10); EXPECT_EQ(o7, o1); EXPECT_EQ(o7, o2); EXPECT_EQ(o7, o3); EXPECT_EQ(o7, o4); EXPECT_EQ(o7, o5); EXPECT_EQ(o7, o6); - EXPECT_EQ(o7, o8); EXPECT_EQ(o7, o9); EXPECT_EQ(o7, o10); EXPECT_EQ(o8, o1); EXPECT_EQ(o8, o2); EXPECT_EQ(o8, o3); EXPECT_EQ(o8, o4); EXPECT_EQ(o8, o5); EXPECT_EQ(o8, o6); EXPECT_EQ(o8, o7); EXPECT_EQ(o8, o9); EXPECT_EQ(o8, o10); EXPECT_EQ(o9, o1); EXPECT_EQ(o9, o2); EXPECT_EQ(o9, o3); - EXPECT_EQ(o9, o4); EXPECT_EQ(o9, o5); EXPECT_EQ(o9, o6); EXPECT_EQ(o9, o7); EXPECT_EQ(o9, o8); EXPECT_EQ(o9, o10); EXPECT_EQ(o10, o1); EXPECT_EQ(o10, o2); EXPECT_EQ(o10, o3); EXPECT_EQ(o10, o4); EXPECT_EQ(o10, o5); EXPECT_EQ(o10, o6); EXPECT_EQ(o10, o7); EXPECT_EQ(o10, o8); EXPECT_EQ(o10, o9); - - Aesi < 608 > w0 = "3893509674364240296565817966808751172691002783248199782541334351863333341009161236129113001785247442885856708616220103577302425545750798795713950025251102."; - Aesi < 832 > w1 = "1904621738309688096963972747021004236006856501929784086088263854997343616028245335782672717133232796105937497394115918619762108507459190371110761436019731."; - EXPECT_EQ(w0 > w1, true); EXPECT_EQ(w0 < w1, false); EXPECT_EQ(w0 == w1, false); EXPECT_EQ(w0 <= w1, false); EXPECT_EQ(w0 >= w1, true); - - Aesi < 832 > w2 = "1608527768883990322596558903852740582856946676239724229707184450409975434453026393098859529161823808676893875886977515885103566841259965348621271025402377."; - Aesi < 928 > w3 = "9264537525192961492920807673589586458619947286002969570716001383731181872666750009284817729212607927865438777724068672750499683225134178232460618168854653."; - EXPECT_EQ(w2 > w3, false); EXPECT_EQ(w2 < w3, true); EXPECT_EQ(w2 == w3, false); EXPECT_EQ(w2 <= w3, true); EXPECT_EQ(w2 >= w3, false); - - Aesi < 672 > w4 = "8579827921780022714884547290034378163774108129266616834606286594438931625536525596709068697345341040201100448364689826680071893580936937957610052613081503."; - Aesi < 704 > w5 = "4353932857600256560604450130831729241817180433084663548890401953025274643710608816125275143869421043054941642599587128920529537059916068803843833176187770."; - EXPECT_EQ(w4 > w5, true); EXPECT_EQ(w4 < w5, false); EXPECT_EQ(w4 == w5, false); EXPECT_EQ(w4 <= w5, false); EXPECT_EQ(w4 >= w5, true); - - Aesi < 576 > w6 = "837363882469384814164952858984059650355806238701150383913125321024093714315545932995066845284083699573306282442802270246233059081589269545802183534735843."; - Aesi < 704 > w7 = "7731750803156293935191942144055527377474680976937305234083822329607259619397574929801911408641020544442317524152432769460529344525963935880147268229930508."; - EXPECT_EQ(w6 > w7, false); EXPECT_EQ(w6 < w7, true); EXPECT_EQ(w6 == w7, false); EXPECT_EQ(w6 <= w7, true); EXPECT_EQ(w6 >= w7, false); - - Aesi < 704 > w8 = "7536263050490565784722454436897360691124905272644727501491606897904633953254516480728770377343185025733063180690756799587717934894237741180009108826737672."; - Aesi < 960 > w9 = "9785117833891594297302388093439791408341957957429923557391375696070213737091713543379508965659146178208818274995583845378946146343828812972191399400454209."; - EXPECT_EQ(w8 > w9, false); EXPECT_EQ(w8 < w9, true); EXPECT_EQ(w8 == w9, false); EXPECT_EQ(w8 <= w9, true); EXPECT_EQ(w8 >= w9, false); - - Aesi < 928 > w10 = "2331423915028866101033025839817989074357888329399814943542917056620393570067871432936269852626341295886857789978014171435135791877059796516711485550203465."; - Aesi < 672 > w11 = "7745825910141249499725353135181692628097643206488293885369721934127831738767685201042473212522535630556399221231683431142973470757582916543147215295832944."; - EXPECT_EQ(w10 > w11, false); EXPECT_EQ(w10 < w11, true); EXPECT_EQ(w10 == w11, false); EXPECT_EQ(w10 <= w11, true); EXPECT_EQ(w10 >= w11, false); - - Aesi < 672 > w12 = "6010689247913118750914877951714565850358068476829349002827096996500473540734241191493186757836276265003354018849837858648044157237137147977356603462247976."; - Aesi < 896 > w13 = "11766646147627630263492856923292408536109594279314009411863240172215973616085233468086875968110723620529952527224499208633039077550993487371141270612368284."; - EXPECT_EQ(w12 > w13, false); EXPECT_EQ(w12 < w13, true); EXPECT_EQ(w12 == w13, false); EXPECT_EQ(w12 <= w13, true); EXPECT_EQ(w12 >= w13, false); - - Aesi < 960 > w14 = "8949677366818190842842495948207569603637256225586182954474638379962428855694788650192065845847312450317154319571908874868168565693565381410614023897487213."; - Aesi < 640 > w15 = "6792756248103380558712593145548796869130188720614777583924722213964574779639694879660794884491993053072747273195944643404339093226397445288317353333298087."; - EXPECT_EQ(w14 > w15, true); EXPECT_EQ(w14 < w15, false); EXPECT_EQ(w14 == w15, false); EXPECT_EQ(w14 <= w15, false); EXPECT_EQ(w14 >= w15, true); - - Aesi < 896 > w16 = "4853564780444502345664478180652531083639882443619084538577328261540801292330371663846790980477997252068354682938446302512986164360263653532392761778201023."; - Aesi < 736 > w17 = "6770098789183303901383314637059158698365510308472153618337470099663190699149619628833529996140272095038275426499167720943531633548912498771362668845338366."; - EXPECT_EQ(w16 > w17, false); EXPECT_EQ(w16 < w17, true); EXPECT_EQ(w16 == w17, false); EXPECT_EQ(w16 <= w17, true); EXPECT_EQ(w16 >= w17, false); - - Aesi < 864 > w18 = "5123332965425726020415728284273984554396243365593103938510645377065224253429268341674095065301111253055817672749359490965436163881090516328866147747617388."; - Aesi < 832 > w19 = "3348664783594785907997655989843079164997608599512229561090714178899335579893590368913874350327704267510582884132085125234569970394461817996218403044545554."; - EXPECT_EQ(w18 > w19, true); EXPECT_EQ(w18 < w19, false); EXPECT_EQ(w18 == w19, false); EXPECT_EQ(w18 <= w19, false); EXPECT_EQ(w18 >= w19, true); -} \ No newline at end of file diff --git a/test/boolean/signed.cpp b/test/boolean/signed.cpp new file mode 100755 index 0000000..0c8c28c --- /dev/null +++ b/test/boolean/signed.cpp @@ -0,0 +1,85 @@ +#include +#include "../../Aesi.h" +#include "../generation.h" +#include + +TEST(Signed_Boolean, ThreeWayComparasion) { + constexpr auto testsAmount = 2, blocksNumber = 8; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = ((i % 4) > 1 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = ((i % 4) < 2 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + Aesi lA = l, rA = r; + EXPECT_EQ(lA < rA, l < r); + EXPECT_EQ(lA <= rA, l <= r); + EXPECT_EQ(lA > rA, l > r); + EXPECT_EQ(lA >= rA, l >= r); + EXPECT_EQ(lA == rA, l == r); + } +} + +TEST(Signed_Boolean, DifferentPrecisions) { + unsigned long long iv = 9112537908201049656; + Aesi < 256 > o1 = iv; Aesi < 288 > o2 = iv; Aesi < 320 > o3 = iv; Aesi < 352 > o4 = iv; Aesi < 384 > o5 = iv; Aesi < 416 > o6 = iv; Aesi < 448 > o7 = iv; Aesi < 480 > o8 = iv; Aesi < 512 > o9 = iv; Aesi < 544 > o10 = iv; + EXPECT_EQ(o1, o2); EXPECT_EQ(o1, o3); EXPECT_EQ(o1, o4); EXPECT_EQ(o1, o5); EXPECT_EQ(o1, o6); EXPECT_EQ(o1, o7); + EXPECT_EQ(o1, o8); EXPECT_EQ(o1, o9); EXPECT_EQ(o1, o10);EXPECT_EQ(o2, o1); EXPECT_EQ(o2, o3); EXPECT_EQ(o2, o4); EXPECT_EQ(o2, o5); EXPECT_EQ(o2, o6); EXPECT_EQ(o2, o7); + EXPECT_EQ(o2, o8); EXPECT_EQ(o2, o9); EXPECT_EQ(o2, o10); EXPECT_EQ(o3, o1); EXPECT_EQ(o3, o2); EXPECT_EQ(o3, o4); EXPECT_EQ(o3, o5); EXPECT_EQ(o3, o6); EXPECT_EQ(o3, o7); EXPECT_EQ(o3, o8); EXPECT_EQ(o3, o9); EXPECT_EQ(o3, o10); EXPECT_EQ(o4, o1); EXPECT_EQ(o4, o2); EXPECT_EQ(o4, o3); + EXPECT_EQ(o4, o5); EXPECT_EQ(o4, o6); EXPECT_EQ(o4, o7); EXPECT_EQ(o4, o8); EXPECT_EQ(o4, o9); EXPECT_EQ(o4, o10); EXPECT_EQ(o5, o1); EXPECT_EQ(o5, o2); EXPECT_EQ(o5, o3); EXPECT_EQ(o5, o4); EXPECT_EQ(o5, o6); EXPECT_EQ(o5, o7); EXPECT_EQ(o5, o8); EXPECT_EQ(o5, o9); EXPECT_EQ(o5, o10); + EXPECT_EQ(o6, o1); EXPECT_EQ(o6, o2); EXPECT_EQ(o6, o3); EXPECT_EQ(o6, o4); EXPECT_EQ(o6, o5); EXPECT_EQ(o6, o7); EXPECT_EQ(o6, o8); EXPECT_EQ(o6, o9); EXPECT_EQ(o6, o10); EXPECT_EQ(o7, o1); EXPECT_EQ(o7, o2); EXPECT_EQ(o7, o3); EXPECT_EQ(o7, o4); EXPECT_EQ(o7, o5); EXPECT_EQ(o7, o6); + EXPECT_EQ(o7, o8); EXPECT_EQ(o7, o9); EXPECT_EQ(o7, o10); EXPECT_EQ(o8, o1); EXPECT_EQ(o8, o2); EXPECT_EQ(o8, o3); EXPECT_EQ(o8, o4); EXPECT_EQ(o8, o5); EXPECT_EQ(o8, o6); EXPECT_EQ(o8, o7); EXPECT_EQ(o8, o9); EXPECT_EQ(o8, o10); EXPECT_EQ(o9, o1); EXPECT_EQ(o9, o2); EXPECT_EQ(o9, o3); + EXPECT_EQ(o9, o4); EXPECT_EQ(o9, o5); EXPECT_EQ(o9, o6); EXPECT_EQ(o9, o7); EXPECT_EQ(o9, o8); EXPECT_EQ(o9, o10); EXPECT_EQ(o10, o1); EXPECT_EQ(o10, o2); EXPECT_EQ(o10, o3); EXPECT_EQ(o10, o4); EXPECT_EQ(o10, o5); EXPECT_EQ(o10, o6); EXPECT_EQ(o10, o7); EXPECT_EQ(o10, o8); EXPECT_EQ(o10, o9); + + EXPECT_EQ(o1, 9112537908201049656ULL); EXPECT_EQ(o2, 9112537908201049656ULL); EXPECT_EQ(o3, 9112537908201049656ULL); EXPECT_EQ(o4, 9112537908201049656ULL); EXPECT_EQ(o5, 9112537908201049656ULL); + EXPECT_EQ(o6, 9112537908201049656ULL); EXPECT_EQ(o7, 9112537908201049656ULL); EXPECT_EQ(o8, 9112537908201049656ULL); EXPECT_EQ(o9, 9112537908201049656ULL); EXPECT_EQ(o10, 9112537908201049656ULL); + EXPECT_GT(o1, 9112537908201000000ULL); EXPECT_GT(o2, 9112537908201000000ULL); EXPECT_GT(o3, 9112537908201000000ULL); EXPECT_GT(o4, 9112537908201000000ULL); EXPECT_GT(o5, 9112537908201000000ULL); + EXPECT_GT(o6, 9112537908201000000ULL); EXPECT_GT(o7, 9112537908201000000ULL); EXPECT_GT(o8, 9112537908201000000ULL); EXPECT_GT(o9, 9112537908201000000ULL); EXPECT_GT(o10, 9112537908201000000ULL); + EXPECT_LT(o1, 9999999999999999999ULL); EXPECT_LT(o2, 9999999999999999999ULL); EXPECT_LT(o3, 9999999999999999999ULL); EXPECT_LT(o4, 9999999999999999999ULL); EXPECT_LT(o5, 9999999999999999999ULL); + EXPECT_LT(o6, 9999999999999999999ULL); EXPECT_LT(o7, 9999999999999999999ULL); EXPECT_LT(o8, 9999999999999999999ULL); EXPECT_LT(o9, 9999999999999999999ULL); EXPECT_LT(o10, 9999999999999999999ULL); + + Aesi < 608 > w0 = "3893509674364240296565817966808751172691002783248199782541334351863333341009161236129113001785247442885856708616220103577302425545750798795713950025251102."; + Aesi < 832 > w1 = "1904621738309688096963972747021004236006856501929784086088263854997343616028245335782672717133232796105937497394115918619762108507459190371110761436019731."; + EXPECT_EQ(w0 > w1, true); EXPECT_EQ(w0 < w1, false); EXPECT_EQ(w0 == w1, false); EXPECT_EQ(w0 <= w1, false); EXPECT_EQ(w0 >= w1, true); + + Aesi < 832 > w2 = "-0x1EB651E8ACA7DBB7D7AA485F3FEB2DF33908F679F803E97A52D65DD5933AFD196870992F433FFCA43E3C9143572A7636A12E674469F5284EB3795569BD714209."; + Aesi < 928 > w3 = "-0xB0E41DBA3874A14776D1AEC13F135D9073DC86BF5280F0CC50CB5BE87C619715F6C4223377EA6BE98AEACAD4247629084E387A3DAB1FD214F71186707E80E87D."; + EXPECT_EQ(w2 > w3, true); EXPECT_EQ(w2 < w3, false); EXPECT_EQ(w2 == w3, false); EXPECT_EQ(w2 <= w3, false); EXPECT_EQ(w2 >= w3, true); + + Aesi < 672 > w4 = "8579827921780022714884547290034378163774108129266616834606286594438931625536525596709068697345341040201100448364689826680071893580936937957610052613081503."; + Aesi < 704 > w5 = "4353932857600256560604450130831729241817180433084663548890401953025274643710608816125275143869421043054941642599587128920529537059916068803843833176187770."; + EXPECT_EQ(w4 > w5, true); EXPECT_EQ(w4 < w5, false); EXPECT_EQ(w4 == w5, false); EXPECT_EQ(w4 <= w5, false); EXPECT_EQ(w4 >= w5, true); + + Aesi < 576 > w6 = "-837363882469384814164952858984059650355806238701150383913125321024093714315545932995066845284083699573306282442802270246233059081589269545802183534735843."; + Aesi < 704 > w7 = "-7731750803156293935191942144055527377474680976937305234083822329607259619397574929801911408641020544442317524152432769460529344525963935880147268229930508."; + EXPECT_EQ(w6 > w7, true); EXPECT_EQ(w6 < w7, false); EXPECT_EQ(w6 == w7, false); EXPECT_EQ(w6 <= w7, false); EXPECT_EQ(w6 >= w7, true); + + Aesi < 704 > w8 = "7536263050490565784722454436897360691124905272644727501491606897904633953254516480728770377343185025733063180690756799587717934894237741180009108826737672."; + Aesi < 960 > w9 = "9785117833891594297302388093439791408341957957429923557391375696070213737091713543379508965659146178208818274995583845378946146343828812972191399400454209."; + EXPECT_EQ(w8 > w9, false); EXPECT_EQ(w8 < w9, true); EXPECT_EQ(w8 == w9, false); EXPECT_EQ(w8 <= w9, true); EXPECT_EQ(w8 >= w9, false); + + Aesi < 928 > w10 = "-2331423915028866101033025839817989074357888329399814943542917056620393570067871432936269852626341295886857789978014171435135791877059796516711485550203465."; + Aesi < 672 > w11 = "-7745825910141249499725353135181692628097643206488293885369721934127831738767685201042473212522535630556399221231683431142973470757582916543147215295832944."; + EXPECT_EQ(w10 > w11, true); EXPECT_EQ(w10 < w11, false); EXPECT_EQ(w10 == w11, false); EXPECT_EQ(w10 <= w11, false); EXPECT_EQ(w10 >= w11, true); + + Aesi < 672 > w12 = "6010689247913118750914877951714565850358068476829349002827096996500473540734241191493186757836276265003354018849837858648044157237137147977356603462247976."; + Aesi < 896 > w13 = "11766646147627630263492856923292408536109594279314009411863240172215973616085233468086875968110723620529952527224499208633039077550993487371141270612368284."; + EXPECT_EQ(w12 > w13, false); EXPECT_EQ(w12 < w13, true); EXPECT_EQ(w12 == w13, false); EXPECT_EQ(w12 <= w13, true); EXPECT_EQ(w12 >= w13, false); + + Aesi < 960 > w14 = "-8949677366818190842842495948207569603637256225586182954474638379962428855694788650192065845847312450317154319571908874868168565693565381410614023897487213."; + Aesi < 640 > w15 = "-6792756248103380558712593145548796869130188720614777583924722213964574779639694879660794884491993053072747273195944643404339093226397445288317353333298087."; + EXPECT_EQ(w14 > w15, false); EXPECT_EQ(w14 < w15, true); EXPECT_EQ(w14 == w15, false); EXPECT_EQ(w14 <= w15, true); EXPECT_EQ(w14 >= w15, false); + + Aesi < 896 > w16 = "4853564780444502345664478180652531083639882443619084538577328261540801292330371663846790980477997252068354682938446302512986164360263653532392761778201023."; + Aesi < 736 > w17 = "6770098789183303901383314637059158698365510308472153618337470099663190699149619628833529996140272095038275426499167720943531633548912498771362668845338366."; + EXPECT_EQ(w16 > w17, false); EXPECT_EQ(w16 < w17, true); EXPECT_EQ(w16 == w17, false); EXPECT_EQ(w16 <= w17, true); EXPECT_EQ(w16 >= w17, false); + + Aesi < 864 > w18 = "-5123332965425726020415728284273984554396243365593103938510645377065224253429268341674095065301111253055817672749359490965436163881090516328866147747617388."; + Aesi < 832 > w19 = "-3348664783594785907997655989843079164997608599512229561090714178899335579893590368913874350327704267510582884132085125234569970394461817996218403044545554."; + EXPECT_EQ(w18 > w19, false); EXPECT_EQ(w18 < w19, true); EXPECT_EQ(w18 == w19, false); EXPECT_EQ(w18 <= w19, true); EXPECT_EQ(w18 >= w19, false); + + Aesi < 896 > w20 = "4853564780444502345664478180652531083639882443619084538577328261540801292330371663846790980477997252068354682938446302512986164360263653532392761778201023."; + Aesi < 736 > w21 = "-6770098789183303901383314637059158698365510308472153618337470099663190699149619628833529996140272095038275426499167720943531633548912498771362668845338366."; + EXPECT_EQ(w20 > w21, true); EXPECT_EQ(w20 < w21, false); EXPECT_EQ(w20 == w21, false); EXPECT_EQ(w20 <= w21, false); EXPECT_EQ(w20 >= w21, true); + + Aesi < 672 > w22 = "-6010689247913118750914877951714565850358068476829349002827096996500473540734241191493186757836276265003354018849837858648044157237137147977356603462247976."; + Aesi < 896 > w23 = "11766646147627630263492856923292408536109594279314009411863240172215973616085233468086875968110723620529952527224499208633039077550993487371141270612368284."; + EXPECT_EQ(w22 > w23, false); EXPECT_EQ(w22 < w23, true); EXPECT_EQ(w22 == w23, false); EXPECT_EQ(w22 <= w23, true); EXPECT_EQ(w22 >= w23, false); +} diff --git a/test/boolean/unsigned.cpp b/test/boolean/unsigned.cpp new file mode 100755 index 0000000..0e83470 --- /dev/null +++ b/test/boolean/unsigned.cpp @@ -0,0 +1,76 @@ +#include +#include "../../Aeu.h" +#include "../generation.h" +#include + +TEST(Unsigned_Boolean, ThreeWayComparasion) { + constexpr auto testsAmount = 2048, blocksNumber = 8; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto l = Generation::getRandomWithBits(blocksNumber * 32 - 20), + r = Generation::getRandomWithBits(blocksNumber * 32 - 20); + Aeu lA = l, rA = r; + EXPECT_EQ(lA < rA, l < r); + EXPECT_EQ(lA <= rA, l <= r); + EXPECT_EQ(lA > rA, l > r); + EXPECT_EQ(lA >= rA, l >= r); + EXPECT_EQ(lA == rA, l == r); + } +} + +TEST(Unsigned_Boolean, DifferentPrecisions) { + unsigned long long iv = 9112537908201049656; + Aeu < 256 > o1 = iv; Aeu < 288 > o2 = iv; Aeu < 320 > o3 = iv; Aeu < 352 > o4 = iv; Aeu < 384 > o5 = iv; Aeu < 416 > o6 = iv; Aeu < 448 > o7 = iv; Aeu < 480 > o8 = iv; Aeu < 512 > o9 = iv; Aeu < 544 > o10 = iv; + EXPECT_EQ(o1, o2); EXPECT_EQ(o1, o3); EXPECT_EQ(o1, o4); EXPECT_EQ(o1, o5); EXPECT_EQ(o1, o6); EXPECT_EQ(o1, o7); EXPECT_EQ(o1, o8); EXPECT_EQ(o1, o9); EXPECT_EQ(o1, o10);EXPECT_EQ(o2, o1); EXPECT_EQ(o2, o3); EXPECT_EQ(o2, o4); EXPECT_EQ(o2, o5); EXPECT_EQ(o2, o6); EXPECT_EQ(o2, o7); + EXPECT_EQ(o2, o8); EXPECT_EQ(o2, o9); EXPECT_EQ(o2, o10); EXPECT_EQ(o3, o1); EXPECT_EQ(o3, o2); EXPECT_EQ(o3, o4); EXPECT_EQ(o3, o5); EXPECT_EQ(o3, o6); EXPECT_EQ(o3, o7); EXPECT_EQ(o3, o8); EXPECT_EQ(o3, o9); EXPECT_EQ(o3, o10); EXPECT_EQ(o4, o1); EXPECT_EQ(o4, o2); EXPECT_EQ(o4, o3); + EXPECT_EQ(o4, o5); EXPECT_EQ(o4, o6); EXPECT_EQ(o4, o7); EXPECT_EQ(o4, o8); EXPECT_EQ(o4, o9); EXPECT_EQ(o4, o10); EXPECT_EQ(o5, o1); EXPECT_EQ(o5, o2); EXPECT_EQ(o5, o3); EXPECT_EQ(o5, o4); EXPECT_EQ(o5, o6); EXPECT_EQ(o5, o7); EXPECT_EQ(o5, o8); EXPECT_EQ(o5, o9); EXPECT_EQ(o5, o10); + EXPECT_EQ(o6, o1); EXPECT_EQ(o6, o2); EXPECT_EQ(o6, o3); EXPECT_EQ(o6, o4); EXPECT_EQ(o6, o5); EXPECT_EQ(o6, o7); EXPECT_EQ(o6, o8); EXPECT_EQ(o6, o9); EXPECT_EQ(o6, o10); EXPECT_EQ(o7, o1); EXPECT_EQ(o7, o2); EXPECT_EQ(o7, o3); EXPECT_EQ(o7, o4); EXPECT_EQ(o7, o5); EXPECT_EQ(o7, o6); + EXPECT_EQ(o7, o8); EXPECT_EQ(o7, o9); EXPECT_EQ(o7, o10); EXPECT_EQ(o8, o1); EXPECT_EQ(o8, o2); EXPECT_EQ(o8, o3); EXPECT_EQ(o8, o4); EXPECT_EQ(o8, o5); EXPECT_EQ(o8, o6); EXPECT_EQ(o8, o7); EXPECT_EQ(o8, o9); EXPECT_EQ(o8, o10); EXPECT_EQ(o9, o1); EXPECT_EQ(o9, o2); EXPECT_EQ(o9, o3); + EXPECT_EQ(o9, o4); EXPECT_EQ(o9, o5); EXPECT_EQ(o9, o6); EXPECT_EQ(o9, o7); EXPECT_EQ(o9, o8); EXPECT_EQ(o9, o10); EXPECT_EQ(o10, o1); EXPECT_EQ(o10, o2); EXPECT_EQ(o10, o3); EXPECT_EQ(o10, o4); EXPECT_EQ(o10, o5); EXPECT_EQ(o10, o6); EXPECT_EQ(o10, o7); EXPECT_EQ(o10, o8); EXPECT_EQ(o10, o9); + + EXPECT_EQ(o1, 9112537908201049656ULL); EXPECT_EQ(o2, 9112537908201049656ULL); EXPECT_EQ(o3, 9112537908201049656ULL); EXPECT_EQ(o4, 9112537908201049656ULL); EXPECT_EQ(o5, 9112537908201049656ULL); + EXPECT_EQ(o6, 9112537908201049656ULL); EXPECT_EQ(o7, 9112537908201049656ULL); EXPECT_EQ(o8, 9112537908201049656ULL); EXPECT_EQ(o9, 9112537908201049656ULL); EXPECT_EQ(o10, 9112537908201049656ULL); + EXPECT_GT(o1, 9112537908201000000ULL); EXPECT_GT(o2, 9112537908201000000ULL); EXPECT_GT(o3, 9112537908201000000ULL); EXPECT_GT(o4, 9112537908201000000ULL); EXPECT_GT(o5, 9112537908201000000ULL); + EXPECT_GT(o6, 9112537908201000000ULL); EXPECT_GT(o7, 9112537908201000000ULL); EXPECT_GT(o8, 9112537908201000000ULL); EXPECT_GT(o9, 9112537908201000000ULL); EXPECT_GT(o10, 9112537908201000000ULL); + EXPECT_LT(o1, 9999999999999999999ULL); EXPECT_LT(o2, 9999999999999999999ULL); EXPECT_LT(o3, 9999999999999999999ULL); EXPECT_LT(o4, 9999999999999999999ULL); EXPECT_LT(o5, 9999999999999999999ULL); + EXPECT_LT(o6, 9999999999999999999ULL); EXPECT_LT(o7, 9999999999999999999ULL); EXPECT_LT(o8, 9999999999999999999ULL); EXPECT_LT(o9, 9999999999999999999ULL); EXPECT_LT(o10, 9999999999999999999ULL); + + Aeu < 608 > w0 = "3893509674364240296565817966808751172691002783248199782541334351863333341009161236129113001785247442885856708616220103577302425545750798795713950025251102."; + Aeu < 832 > w1 = "1904621738309688096963972747021004236006856501929784086088263854997343616028245335782672717133232796105937497394115918619762108507459190371110761436019731."; + EXPECT_EQ(w0 > w1, true); EXPECT_EQ(w0 < w1, false); EXPECT_EQ(w0 == w1, false); EXPECT_EQ(w0 <= w1, false); EXPECT_EQ(w0 >= w1, true); + + Aeu < 832 > w2 = "1608527768883990322596558903852740582856946676239724229707184450409975434453026393098859529161823808676893875886977515885103566841259965348621271025402377."; + Aeu < 928 > w3 = "9264537525192961492920807673589586458619947286002969570716001383731181872666750009284817729212607927865438777724068672750499683225134178232460618168854653."; + EXPECT_EQ(w2 > w3, false); EXPECT_EQ(w2 < w3, true); EXPECT_EQ(w2 == w3, false); EXPECT_EQ(w2 <= w3, true); EXPECT_EQ(w2 >= w3, false); + + Aeu < 672 > w4 = "8579827921780022714884547290034378163774108129266616834606286594438931625536525596709068697345341040201100448364689826680071893580936937957610052613081503."; + Aeu < 704 > w5 = "4353932857600256560604450130831729241817180433084663548890401953025274643710608816125275143869421043054941642599587128920529537059916068803843833176187770."; + EXPECT_EQ(w4 > w5, true); EXPECT_EQ(w4 < w5, false); EXPECT_EQ(w4 == w5, false); EXPECT_EQ(w4 <= w5, false); EXPECT_EQ(w4 >= w5, true); + + Aeu < 576 > w6 = "837363882469384814164952858984059650355806238701150383913125321024093714315545932995066845284083699573306282442802270246233059081589269545802183534735843."; + Aeu < 704 > w7 = "7731750803156293935191942144055527377474680976937305234083822329607259619397574929801911408641020544442317524152432769460529344525963935880147268229930508."; + EXPECT_EQ(w6 > w7, false); EXPECT_EQ(w6 < w7, true); EXPECT_EQ(w6 == w7, false); EXPECT_EQ(w6 <= w7, true); EXPECT_EQ(w6 >= w7, false); + + Aeu < 704 > w8 = "7536263050490565784722454436897360691124905272644727501491606897904633953254516480728770377343185025733063180690756799587717934894237741180009108826737672."; + Aeu < 960 > w9 = "9785117833891594297302388093439791408341957957429923557391375696070213737091713543379508965659146178208818274995583845378946146343828812972191399400454209."; + EXPECT_EQ(w8 > w9, false); EXPECT_EQ(w8 < w9, true); EXPECT_EQ(w8 == w9, false); EXPECT_EQ(w8 <= w9, true); EXPECT_EQ(w8 >= w9, false); + + Aeu < 928 > w10 = "2331423915028866101033025839817989074357888329399814943542917056620393570067871432936269852626341295886857789978014171435135791877059796516711485550203465."; + Aeu < 672 > w11 = "7745825910141249499725353135181692628097643206488293885369721934127831738767685201042473212522535630556399221231683431142973470757582916543147215295832944."; + EXPECT_EQ(w10 > w11, false); EXPECT_EQ(w10 < w11, true); EXPECT_EQ(w10 == w11, false); EXPECT_EQ(w10 <= w11, true); EXPECT_EQ(w10 >= w11, false); + + Aeu < 672 > w12 = "6010689247913118750914877951714565850358068476829349002827096996500473540734241191493186757836276265003354018849837858648044157237137147977356603462247976."; + Aeu < 896 > w13 = "11766646147627630263492856923292408536109594279314009411863240172215973616085233468086875968110723620529952527224499208633039077550993487371141270612368284."; + EXPECT_EQ(w12 > w13, false); EXPECT_EQ(w12 < w13, true); EXPECT_EQ(w12 == w13, false); EXPECT_EQ(w12 <= w13, true); EXPECT_EQ(w12 >= w13, false); + + Aeu < 960 > w14 = "8949677366818190842842495948207569603637256225586182954474638379962428855694788650192065845847312450317154319571908874868168565693565381410614023897487213."; + Aeu < 640 > w15 = "6792756248103380558712593145548796869130188720614777583924722213964574779639694879660794884491993053072747273195944643404339093226397445288317353333298087."; + EXPECT_EQ(w14 > w15, true); EXPECT_EQ(w14 < w15, false); EXPECT_EQ(w14 == w15, false); EXPECT_EQ(w14 <= w15, false); EXPECT_EQ(w14 >= w15, true); + + Aeu < 896 > w16 = "4853564780444502345664478180652531083639882443619084538577328261540801292330371663846790980477997252068354682938446302512986164360263653532392761778201023."; + Aeu < 736 > w17 = "6770098789183303901383314637059158698365510308472153618337470099663190699149619628833529996140272095038275426499167720943531633548912498771362668845338366."; + EXPECT_EQ(w16 > w17, false); EXPECT_EQ(w16 < w17, true); EXPECT_EQ(w16 == w17, false); EXPECT_EQ(w16 <= w17, true); EXPECT_EQ(w16 >= w17, false); + + Aeu < 864 > w18 = "5123332965425726020415728284273984554396243365593103938510645377065224253429268341674095065301111253055817672749359490965436163881090516328866147747617388."; + Aeu < 832 > w19 = "3348664783594785907997655989843079164997608599512229561090714178899335579893590368913874350327704267510582884132085125234569970394461817996218403044545554."; + EXPECT_EQ(w18 > w19, true); EXPECT_EQ(w18 < w19, false); EXPECT_EQ(w18 == w19, false); EXPECT_EQ(w18 <= w19, false); EXPECT_EQ(w18 >= w19, true); +} diff --git a/test/generation.h b/test/generation.h new file mode 100755 index 0000000..472b2b4 --- /dev/null +++ b/test/generation.h @@ -0,0 +1,54 @@ +#ifndef AESIMULTIPRECISION_GENERATION_H +#define AESIMULTIPRECISION_GENERATION_H + +#include +#include +#include +#include +#include + +namespace Generation { + using CryptoPP::Integer; + using UnsPP = Integer; + using UnsGmp = mpz_class; + + static std::random_device dev; + static std::mt19937 rng(dev()); + + template + Out getRandom() { + std::uniform_int_distribution dist(std::numeric_limits::min(), + std::numeric_limits::max()); + return dist(rng); + } + + inline UnsPP getRandomWithBits(std::size_t bitLength, bool prime = false) { + static CryptoPP::AutoSeededRandomPool prng; + + UnsPP value{}; + value.Randomize(prng, + UnsPP::Zero(), + UnsPP::Power2(bitLength), + prime ? + UnsPP::RandomNumberType::PRIME + : + UnsPP::RandomNumberType::ANY); + return value; + } + + inline gmp_randstate_t& getRandstate() { + static gmp_randstate_t state; + gmp_randinit_default (state); + return state; + } + + inline UnsGmp getRandom(std::size_t bitLength) { + mpz_class result {}; + mpz_rrandomb(result.get_mpz_t(), getRandstate(), bitLength); + return result; + } +} + + + +#endif //AESIMULTIPRECISION_GENERATION_H diff --git a/test/gpu/CMakeLists.txt b/test/gpu/CMakeLists.txt deleted file mode 100644 index 0957eee..0000000 --- a/test/gpu/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB GpuTests *.cpp) -target_sources(AesiMultiprecision PRIVATE ${GpuTests}) \ No newline at end of file diff --git a/test/gpu/cuda.cpp b/test/gpu/cuda.cpp deleted file mode 100644 index 033a396..0000000 --- a/test/gpu/cuda.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include "../../Aesi.h" -#ifdef __CUDACC__ -#include "thrust/device_vector.h" -#endif - -TEST(Cuda, ComplexTesting) { -#ifdef __CUDACC__ - constexpr auto closure = [] __global__ (Aesi512* const number) { - const auto tid = blockIdx.x * blockDim.x + threadIdx.x; - if(tid != 0) return; - - //(2^502) + (3 * 2^498) - (5 * 2^496) + (7 * 2^494) - (11 * 2^490) + 987654321 - *number = Aesi512::power2(502) + 3 * Aesi512::power2(498) - 5 * Aesi512::power2(496) - 11 * Aesi512::power2(490) + 1234567890; - }; - - thrust::device_ptr number = thrust::device_malloc(1); - - closure<<<32, 32>>>(thrust::raw_pointer_cast(number.get())); - const auto code = cudaDeviceSynchronize(); - if(code != cudaSuccess) - FAIL() << "Execution failed: " << cudaGetErrorString(code) << '.'; - - EXPECT_EQ(*number, Aesi512("14848534544607010728721939591566599669967092093623081979638562895318888168261438776789833573099438290982293601340348173669740387359021143293664083994801")); -#else - SUCCEED() << "Everything's fine, just different compiler."; -#endif -} \ No newline at end of file diff --git a/test/gpu/opencl.cpp b/test/gpu/opencl.cpp deleted file mode 100644 index 02e36b3..0000000 --- a/test/gpu/opencl.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "../../Aesi.h" - -TEST(OpenCL, ComplexTesting) { -#ifdef __OPENCL_VERSION__ - -#else - SUCCEED() << "Everything's fine, just different compiler."; -#endif -} \ No newline at end of file diff --git a/test/number-theory.cpp b/test/number-theory.cpp new file mode 100755 index 0000000..8bf9ba2 --- /dev/null +++ b/test/number-theory.cpp @@ -0,0 +1,67 @@ +#include +#include "../Aeu.h" +#include "generation.h" + +TEST(NumberTheory, PowerByModulo) { + constexpr auto testsAmount = 256, blocksNumber = 8; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto base = Generation::getRandomWithBits(blocksNumber * 12 - 10), + power = Generation::getRandomWithBits(blocksNumber * 16 - 10), + modulo = Generation::getRandomWithBits(blocksNumber * 16 - 10), + powm = CryptoPP::ModularExponentiation(base, power, modulo); + + Aeu b = base, p = power, m = modulo; + EXPECT_EQ(Aeu::powm(b, p, m), powm); + } +} + +TEST(NumberTheory, PowerByModuloDifferentPrecision) { + constexpr auto testsAmount = 5; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto base = Generation::getRandomWithBits(250), + power = Generation::getRandomWithBits(1000), + modulo = Generation::getRandomWithBits(250), + powm = CryptoPP::ModularExponentiation(base, power, modulo); + + Aeu<512> b = base, m = modulo, result = powm; + Aeu<1024> p = power; + + EXPECT_EQ(Aeu<512>::powm<1024>(b, p, m), result); + } +} + +TEST(NumberTheory, PowerByModuloHuge) { + constexpr auto testsAmount = 5, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto base = Generation::getRandomWithBits(blocksNumber * 16 - 10), + power = Generation::getRandomWithBits(blocksNumber * 16 - 10), + modulo = Generation::getRandomWithBits(blocksNumber * 16 - 10), + powm = CryptoPP::ModularExponentiation(base, power, modulo); + + Aeu b = base, p = power, m = modulo; + EXPECT_EQ(Aeu::powm(b, p, m), powm); + } +} + +TEST(NumberTheory, LeastCommonMultiplier) { + constexpr auto testsAmount = 256, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto left = Generation::getRandomWithBits(blocksNumber * 16 - 10), + right = Generation::getRandomWithBits(blocksNumber * 16 - 10); + + Aeu l = left, r = right; + EXPECT_EQ(Aeu::lcm(l, r), CryptoPP::LCM(left, right)); + } +} + +TEST(NumberTheory, GreatestCommonDivisor) { + constexpr auto testsAmount = 256, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto common = Generation::getRandomWithBits(blocksNumber * 8 - 10), + left = common * Generation::getRandomWithBits(blocksNumber * 24 - 10), + right = common * Generation::getRandomWithBits(blocksNumber * 24 - 10); + + Aeu l = left, r = right; + EXPECT_EQ(Aeu::gcd(l, r), CryptoPP::GCD(left, right)); + } +} \ No newline at end of file diff --git a/test/number-theory/CMakeLists.txt b/test/number-theory/CMakeLists.txt deleted file mode 100644 index e8b1a2a..0000000 --- a/test/number-theory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB NumberTheorySources *.cpp) -target_sources(AesiMultiprecision PRIVATE ${NumberTheorySources}) \ No newline at end of file diff --git a/test/number-theory/gcd.cpp b/test/number-theory/gcd.cpp deleted file mode 100644 index bfe56b4..0000000 --- a/test/number-theory/gcd.cpp +++ /dev/null @@ -1,302 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(NumberTheory, GreatestCommonDivisor) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi768 l, r, bezoutX, bezoutY, gcd; - { - l = "205784153332541666951721440128698050625116439954815756686985686924136781796364."; - r = "307035295126195867431935258077083409964253881938534929969841800430539080521438971516735465701137195440790976100606780266398647644989237724734489396."; - gcd = "41585805574181814324827681910758050372."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "111566069989396480109323065508769660240810214512517075885163356992826365139469700770207263750149793861769."; - r = "154743673156417500512039774789787757346116280393797550477108808916111388674086759718465821673102306865673853289542558625997220109."; - gcd = "292472754777438853754423506532451213023."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "24659398318439729302240246201665534525102362379491614579552427205830977838831047063802883336387223287438833199575932987973737540045128478109."; - r = "49587757353649279384437371047975578240113987716362061502389860387747076250612846816317594625760513361."; - gcd = "75553261499772784346110059021989061499."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "11521028418660550065729466761845880570216036247572648263062994955917270028290665942236307118."; - r = "1479536898599051026320917752642193132609921144276688743027371589964853071409380431874405759069261539403591966690907635217073421665078."; - gcd = "217923287151415741523707686983491712782."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "3841562528769437201523240842718660017429263164952695622678617097859210730989013533."; - r = "1093542588796992810141834649085391221867950296783004341984384620517533876037935147."; - gcd = "6430643592857622910904458338363125443."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "127807242604260525083124096860508698828421232195983693722033815746656930110545844903."; - r = "429313479805279082344367160457136540841887545709335163043017577512806648281310753550761344278160393483045373963410807813529622305489270144108662233."; - gcd = "102067283142759679269916544524675746137."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "1141756693702142227010498417643932965844243142607890629823025899002893108570348147491578857555716738386."; - r = "10949371590756494759469739525674546633713903693015867889173145004417254562250371582425672431918746477435168219768746337851811918383240409478822702."; - gcd = "315189900165538911016170531893291459746."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "9864028579863589218062555245111805587936353304810624145340812217169774001200118165201852."; - r = "5248225329099693667986421613392863574437570924845493489705843390656865910743562207288953032326427160050617124."; - gcd = "104654743505489002976659993777682153324."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "3087093172123476810182524521962505086081302958018432793715418895003149905483441760529146590668369547108420361871499666922860."; - r = "452966340797470996539353693028185639891479086006433905509839128796258210031979124580."; - gcd = "80906953728913322426626308416236734380."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "88595623370093561284436619134004162259954765958407392349924080709552264061392901355972965326939921068345728202057275511."; - r = "144952925330599786740866640616072352152987377116577408170203674761309829077614480183945514006500478545060449."; - gcd = "226243993689792552449485400968334435973."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "2987723468411881341920690566759078710141787544741085339044601414241434699639218."; - r = "4793807936700750688642623027367654266118970294469755468165070342220572692458950596660364101517146."; - gcd = "78325843943212695784878594184549940314."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "1861071441699643013379174541584998465021361208945140601710238865235020812947033532."; - r = "72560008920963711574247830598354664391125348394701596081923789845816772969232226321279216675559609298228."; - gcd = "270300996350877582251981561905719583388."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "197727927574469774397612067829048837082971158513728938740734482843614319943196792393022727108508721140065849398393."; - r = "396400748011882071979654999888356754066413169781008119836029496548576910937773996644598288532074526464419384879259."; - gcd = "37073036653275544253741256509051065033."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "89505763624339162436797374854984215907430554127920662572284757460644457275725535532467775384."; - r = "5955651717848683519703961678348887764335699824262089276965159042814408332056814010639822984349724538682284562215493791511375635451110253848."; - gcd = "304885522039370326149401650640420885176."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "533666998986469087354112711104296871842011127284294346795055083227240951642323570952985767."; - r = "19111601496661007806035128422622351909037240880696999670757757582929167545900953289905890923626713942572503481725607816304598065956226834141363957082079."; - gcd = "300738076060550953107019464694740968929."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "24257219585899404037224837715055642869667246574951396570322927369580685023502281976068884147631786942676011085."; - r = "462684206566385865375609802575900289727930959756149190680768298103437013769753341313944277946261648221990855."; - gcd = "70242931658748585272531479007205090345."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "25091713568182000507950646853612708487699728018143906534073098909630097844733940811786096032755547072885533."; - r = "959765237747503080861458522911583753739409468022351804866608308861675336994241279."; - gcd = "248506051604780998736970466457536820387."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "39944418602953231126306929918346946632069968939650061987268105286479666858015419035445468453."; - r = "4189891338749956846247145492169019842479784203285276935893563569302277218474010010669."; - gcd = "284954526028927876109290302832929834003."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "13489188432870892597004250200170050534936860949408137513855816866611238712760551362128718513777422898573951885007583312825344494029798155961."; - r = "7709283904944836102379195255790410194709325140352713599680491524225215604610501830887783414946563586086993748842890883315559473428147627893177817."; - gcd = "213104602391186535161323546559541492507."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "14483039540277560603783683280847022391396703768267128852163700260748094710567287727372339206674105022."; - r = "904722395594658373244008446448078135727805900142197218194684035973740130883505750119088392141314420436754082684664562."; - gcd = "118780753047002365116691732167954559938."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "92952712576430175617054446101860618717843494326656009053465236655467740366400."; - r = "67568213081073159437851723010887097244065929553017037938290738836401585115780430629982905169600."; - gcd = "330306669624830478114340282733606577600."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "66645653765292261536434180198454602333043640773334478181897153697447239568802452296128."; - r = "269236734599516545324149225328212459222526395893183553315261827823648500281794475895416018928897306786904809977408."; - gcd = "149432871301353304760124697316242497088."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "98637224535334792247430440601042006663047749294233649665195941465714384456640511025378684054371001731386195668345239878794054221578361745905295428588."; - r = "2305639559313033786431931543007533034600548469849215065847278216530202191257599536568748537134313270634561529269522532849494615688076114655063732."; - gcd = "165784007512342872640525935583808826508."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "24159019000192540969615087363661158011723187222072456363752742513544923599809343716448445570020779402771851850344."; - r = "1295073803172429459527512249086324839790199753832307826794227736717929325092395778514389344930264."; - gcd = "234290309267548172037648433619306181544."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "57452658418535152899239888256482352337770478145569879298506325583928039676581991559661658870767973418856423077635."; - r = "878917883844080873698600456379425654013937998282977852437557379552042219442787964437065."; - gcd = "238491196851544857785506963107149842495."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "465356826436460492384623443833064017655397539817876589682269978889852714808199982578354757565865417124440160142985084637813682532437."; - r = "82863133056292997521422544574175985716314480803516677567104430207522644282398454491447974311891338827329886633010427."; - gcd = "209257234204571742471051318935771022257."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "391600573002744197256595451259113682234894021599774242082666314397338728454758464927100198685351735615972491037522159367855083004639319371675."; - r = "23107691211378303655474254848680911926299645710301186105502054153412331659757225."; - gcd = "181004552554023155039408203994242816675."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "879386860239865997446971885254779881082868897292514920966502038411523137523712641750872979150303578107653826."; - r = "4856157384393364041769930156453193945117474553755894168817473624742193316799274718565888075134."; - gcd = "117355005946105172430452554636307539658."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "2420216764206574149658881417605800228818193139105209863943214786287570117665274617470473822309743090249930929205251324794070550594668443314495000210."; - r = "2281830816396880022302773362034660696699995037063339803347994586828102708062912232090."; - gcd = "307472746670316061020087138154485837810."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - }{ - l = "25340869474246654457149446674560008151588544592377190304431729751524893746690433141210952402."; - r = "505705671739983428727792609000869764077604982740869339046895059054325694919362."; - gcd = "269780201665873814734446618758904176334."; - EXPECT_EQ(Aesi768::gcd(l, r, bezoutX, bezoutY), gcd); - EXPECT_EQ(l * bezoutX + r * bezoutY, gcd); - } - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(NumberTheory, GreatestCommonDivisorDifferentPrecision) { - { - Aesi < 672 > l = "4230676745963713957230888310187630372432069099345644636601407373385234444092181446632419775164492383515032489284154688242326706321937072760697455769189714765485293120009031112653110814316764869420714396."; - Aesi < 1056 > r = "209956445382185916560571879684192822710509265996286513955249087273201046635170590440468705699334543201017112397357524814680715615940980228897724843179093148890706469409864131728137510849203862753097509824739361739324467479868924067825818041059172501531522186466176930159962182768295794284302187614761676199305309362598."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "64647248204074430032946973534391241670722146839208916950037622315812135371561662893244373531561692445330126366808337145392822653697465725700567202977462087954432214."); - } - { - Aesi < 928 > l = "644951599131558468448822699675101480817054053912186902041119715443011322660635640568989777809715116919537330884789519966705429083097889126874505167742076054529441346225944104364013619559102217967512847269152662680659527314311155583027074735196464695453049020550687619282706673780."; - Aesi < 1088 > r = "1252941560311043512523997658469534813375458357445260439433069166087750220713059429094251618826186749670237790725745107987671620766916110050637341523661806802438885757938176445765367074693538388179332139672144442296395986579205303043587462303056267734919176254191491656233887570942452329673578160793149291963102726854961476695580."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "203293001641370607163401184222192347776467064691515055952109974505650171074441289837083156052522009397546049907256904793801021573728979083048469298910736690867259940."); - } - { - Aesi < 672 > l = "9585677621361790747542731699183518553137961470185822862239050776423435924661647685535553667410269642819739499533557302829503576772190609861145081711348261368655191548650535644687555882814079281948869199."; - Aesi < 640 > r = "2367441375543594502871331188239360671612910847513218362733938745389664603226319931515532518153642659183826157027536274151677433136113925683393084630993056641826869908962410949704181567477845684."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "24559920916699563850536643601549609228979323413871223776713945872990612433752548701691501009334170712436258461631937289240372019140601722675567806966645451."); - } - { - Aesi < 544 > l = "1025048602017503238379658040884423038448922686219368124848551707652216483592983433990964146351702815507561016381100414953012305321229063309483299606483418891030640."; - Aesi < 736 > r = "106448671726508721528388537639752408638277215306306124531666804890581168642263269874377417619676284350098150505258412414111914310935155228646579173088427225279631343476145327012828295266633490885866191085927392050419150819."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "428446229629353219094697372973316732133257685757548840764304754131555598240995410109723."); - } - { - Aesi < 864 > l = "44320326277180188605550230327284864052128535718637012693380665653124594973263618475677931894682101734289305418698016483853144404956679033883483704856378658313356101953359021132507379024088641114187409396079713991346469667148396546158054039226749486286912318560."; - Aesi < 736 > r = "41668490976788256893116532112044213633891359795569874372094917663858301505071893549196637596596594227914932990980233830923465691001974909138469425320780768565573086115765816099764002048746527040413983847705904743086234370."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "1708361341436101192039773551707751167254746113155336883576640520904553250449029089768025050425490."); - } - { - Aesi < 896 > l = "139443230929326819742511001780557243544488388811740733158927984804189580958726055988746111731798646180768971018453015883511382613957198801163384882078422832299227575494883780383981543181262373381387871754112543335216794666711979174645718111404389620556052627299659924852."; - Aesi < 928 > r = "98231837540696176192716842030040470368853612601491655676156264650167048316924367083154603468182752002665526862941805263818060742932782925036699650401442302401205876587930129172414953177353293741770889950783311103087246650679492133199578391147206960033485669612752011312."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "2251253896172415982777972236185412618641618874085326835371445315762588964357064607495729947232052045296360160019139280879776642998272477383363897626540993764114721080183425042679143079111335292."); - } - { - Aesi < 608 > l = "325769536172480976255095852600606628504126622952311254811505077256553463206419828948119183101950613306990404875120858939254435390950969141484515606308769222930743006127948420503982928."; - Aesi < 512 > r = "3771809266741055493549451513157005786066682818233987554309132717627080555992261098905445672420210923903478986471794947463443003537961677262127935771727004."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "1247616674975269414985803952995604494402642776008716846763186302548884361983518575690138571082732."); - } - { - Aesi < 416 > l = "20680688544267474657760903768407052783166744854758811851415026018309749322986577950145407189920193348861574921971735221802876."; - Aesi < 672 > r = "2956502787098119466632013235822525257867074821428011258584613412939308483532092473190441822930477576423338687218939016376452752243982602123843718199078277649634938129003787106260707247901593760272874452."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "319678443171958180783744886861788320812."); - } - { - Aesi < 896 > l = "42033894881215996563108824273565563206952280356966715576239049742633461575153250322694502197947526775303289143065490876208104443444417442712617522887284180773682812075536085210513867904387261262790036527018646882430745768502342419510371271677976466130237925712."; - Aesi < 864 > r = "75867476167179756925189188822046073211615450659798937685652546340627693592162333337673856937731122878141305419876052715970593556847957206562707054474122862154356783001116876909318649001507577926656457764502751649210615252720606090500519819763918607652245168558."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "27672200309473699466062460175842684257346481496243760492409880520870460338024009451890590373869371927971798965935026."); - } - { - Aesi < 960 > l = "66572371473626869504545823252619142464193730149383021256020143828360084583026747178282066297818530269672193691663477462362949663873447485909091803171757713288071500174398122128974167158184713891975707292163209464233354039844504886846255579841788803831270096992799997314710756515912384932."; - Aesi < 864 > r = "2717110386452237801726359356476649734114774942280259956646836330036878242770234356972517318636317673915153651731460015476270816118147748987819601991883041120536291849123792103949964526383119561363238428929684952362487430621947737505145305359619917570502724028."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "82731924146567176744607433419954882495328135619958445588203865094017394134698720720140154465802098619756362841393016720545053050602348."); - } - { - Aesi < 1120 > l = "931314542705274319646632352153246657479452521943146000934558120737682842153774932655132204160672179121064725685166170681064901674325499415057018208653032425424263459263174778437715568286760005443597997407912855518443087722119276194896495318010500498920668255593697386976200185493984053612383767195662605430705598666929947695158169041441."; - Aesi < 672 > r = "398242925688781908804629541692075682129940372267467448875144337157239533341579189744226800954256693369907097296571756778485088050475413320601179547067403487744721014306232014448542855962999665164043541."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "38966954206645663651514809733667103933922380986309455307611494248772771450869010561793972862057018068536104713401481520693144745407501972923272147875716979701942577796107271."); - } - { - Aesi < 864 > l = "10992804516588380186805217471635725871174634307871676918698875265213143540071730800538791442848027248824990939372635016732120921604137649481799252610185755909065764431272038623253455612549541904818623765159251902312254920235405967708229095553864068302950582350."; - Aesi < 928 > r = "264835421786154535323939206198359569425765314055458651728141986282472939366203059436429914585114165822513612644403787444253291276420079233329456991861524685051179815905462425465702580586714386497847999288508080114973657727876148808072530687740756214384670550308919267040958960075."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "56951597237701561176394216804689598281166885623645391283265117535573544550707037024741985083463421121373175."); - } - { - Aesi < 672 > l = "12383346959826637872118427447702047086488691075270619429852828771735645050146119574897341135633242685360277384483601737856590574416067657407070172230606545680332151435867203211724609547921893727132274982."; - Aesi < 704 > r = "14348294542121772197373903409937840369255203167509944698866799165105485668890432197379691678421214540978338319810411264201636003862768473235193140639532178514767537924713971936767982999021052664568251511."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "5395601467742227452695088775148294435531930873981263517441."); - } - { - Aesi < 832 > l = "1075563162210870127379865975809649527926199247433493483352964442448416210650926451646315396118448209043587167997600329951108747528612281152439446078275152212718602491291788837072118769256000621202922534427628959737088260189079743991721963110408865892."; - Aesi < 1152 > r = "9574219070651515826229026814078475385260586488852288382382550113141195513014924143605339943414483810988016027646671965848107590194916779264649780566306465742916400135822764900665037457280692579555471605072859576266614248699324885765658960173216148273812405919438792725752551523804396008628809996901363194043948276316327903250387072357919162867177."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "59674012642333753734610734990062908255218798084295958207399353741208437901643855825698694924687087177682867048554982860053126011284434405257929800112718420288354143."); - } - { - Aesi < 608 > l = "151522770749964678436148842371800661308755610344045960075519436400073891748881928936553469657464872818171536225043815173126601503063626409691786995851470215979632324780679154730655790."; - Aesi < 672 > r = "4514938238985691056059937449130052459716751635657861474242995973951297034721954133037737289305067035195170735945468656730231522190063989575281386186648309581728125181761236624690442222030130768178150251."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "4229133045955358202624475552855554877230999193277482980445577535964404995334906375576954301791895915830118167844572669658078638157230085205387745107022847."); - } - { - Aesi < 1024 > l = "10161055883348445617306414199629648859830426505308297391754313664187847160675266540965795990197975433659180149745200523104355845902208422575476341128527085331464552322111254979977417879009045541643340064230263018335314580877376779848213893595846951498461946789311256474748049982898555317283085505307159210152."; - Aesi < 800 > r = "515948972769130273350064740382292518386639731561737879067985843825058515267023925632271320701891333029923206120916362550988508113742196058545378274549901860897247568719463063376425826010741684820636164653439302208357418930310455309849769048."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "490401245335199464371290691377917776995274646975724529767288634194266756471725789065628095645498930126084359922466265539160809022929889821467096."); - } - { - Aesi < 576 > l = "23645447925774886002998325692466057758331797656108649612849474157052278882570831703052388929013756451995500099188687523236841329466817612566959955406702858238462676245919775."; - Aesi < 608 > r = "60816000044152499904165146100270719114033719350347442322922861655195500069491242575612516603138520663953323040606673746723265376030821313791031108379435240630461525006170393."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "54520923532656950320107140503388701513804601249740428671147261843615703871570377448914205428830873806278088396569978623965161."); - } - { - Aesi < 896 > l = "62740249742851067499143020245042328617106625052044053623630449680318838292966703181144755319509513852788182521150171625967343453454896254576974917366461752849745977986535555222653167262834252905884504542047821006142275248747466212944147243718426751861161658531058713046."; - Aesi < 960 > r = "6307646547349816689884051803903026367842299810293153129468125895296675160161238101702895573682320860203534872020273771631666436912319742029537889993380537496644585713231177661458650632306520115037431356069432182492230018348182496456483937267150780657278540729068328194793314032584899821508."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "232049247473897235401214546845887461904067903584451783555238505019868948999669972398822609257046574074937853184852486345389034."); - } - { - Aesi < 672 > l = "18616024909498069904742602316774939101747083989830144251003152932678679984570171984782926648554015163415750309950069214583731001348828780685130884681562232908559551829478297203129290587119289162337871808."; - Aesi < 928 > r = "1462071909563042148732205222521737429230349331185649480947631195688804705564655880411994861112165458656747887795123436208097853104815460645892547697704327872720101826330401970311658217181220712291318225641639537817645927799121466748636065994794000886184985190115390134079927333401."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "472900631175425196165697542378929353717689763966490017025295390429655469782190314228943."); - } - { - Aesi < 608 > l = "85212760240756899430548729250831581127013686936228448859685109651502483027511794418800582922480125191423391639832564937254028190082219477018479477785330638252967391181184897401046076."; - Aesi < 416 > r = "6756442613711296058022703182509007796007227156406805847900921410721341473167524903912074030144758186183657221774913606001268."; - EXPECT_EQ(AesiMultiprecision::gcd(l, r), "68017067994476894939528303364."); - } -} \ No newline at end of file diff --git a/test/number-theory/lcm.cpp b/test/number-theory/lcm.cpp deleted file mode 100644 index 8f5c567..0000000 --- a/test/number-theory/lcm.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(NumberTheory, LeastCommonMultiplier) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 l, r; - l = "58712898820445740578867938422005479885576561870284639903702251100561617484082.", r = "73271804942217305270802872124823125802579882393902100324004182532671979224332."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "2151000034981920403783672172121095062306443558541639433694713477795867196388687757277738437332293774445519756953714546194412172547652310751074355858541612."); - l = "58863911179190489819692830244173244788660412955385050676183232551129080766029.", r = "105375481318482303482984022544313244487626288238837961103587526270381302447504."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "6202812972795589079742096736721522400130110975236961129038381052586061958039544291539939807045347550560275179337231203317848935613892681396546548879041616."); - l = "51179317342583050349271006941235258436562423597891372936653459797260933392939.", r = "55266959775209160722275083290265433628244466673192193348345153793565859031460."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "2828525272895202041230880808359147207292350525571131576620878294182683480307067497603285199319937587539052724646353930204162950835601374998251034142860940."); - l = "71075386647667831614305770432842758110719315879940702411044679625395163499679.", r = "19420096351189427599978278289427428141531872150147996722364820346761839383196."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "1380290856895751819303257815743401126063149493711871378782649470858376433336517874981015753988319170212051169855950933148737622770725943367291022103994084."); - l = "110586714992074394146797181411236431914736024870101772209158990293971672974877.", r = "90095745879493175545179332883522377921412063459448855381268994376520063760999."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "9963392571573872777568531672672907756489864250095926879343054945375174542156084386792768301088289123312138116438854386157796187363726347176234619459422123."); - l = "11691177235736879303818495080235291888358288326351767545149940552417902396520.", r = "57310145382359497749659187466726695618964571980150051293443066384256833778972."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "167505766767753097676984757189955493590927815543907377031261814850393904194745608903133226573760775027732650873093525151933237508622422426990921695494360."); - l = "105615611113159431072290378480579251303824661747610597766139746203576583490323.", r = "95656957444972818291875433691253730515002678350506517662396771667838884948422."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "10102868017776289964867815851564512328703697262377968657168197342353382876541080140561804576291684420975307946425058949659454937390477647631647586591120306."); - l = "47002868626214988913237600103633202496143573592837114969748580732987325580191.", r = "78105707027577690029866421958102439343155310020165378058779103604976696174479."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "3671192286374870984553874760312039563932953730242512832577007818461769481904638603227850388014447305660981092016354322226961640509274605764129808842145489."); - l = "34708440348962043432973562418387415970937447482781464822946551003959587922624.", r = "25121403956361813722140882710372438545003760017928341823926147443467147296187."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "871924750701563088383308626701062260248013885339132585626872889769549893994184911179818492052448862304566413787415451463250536309340711279500501766234688."); - l = "86520702971885834671204927155726392078832481987566394172174953831231382120843.", r = "4837952285113070922346809892097950884570150462670547805193886078424030695558."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "418583032652424340293813608103236342105412226875924722005508870628883135682811849679110428767473414209356368424214062964415388272268151228092742499315394."); - l = "96844348140155893293362701060183275908428275320641344045899104317411151822930.", r = "33872762713107516869512287179209686203721240394414580086116183334314487307914."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "1640192812328537920748305261803131688072711813799942254067530350216405642132543615251688134614297513182213505154414623233330740103997336371647594657834010."); - l = "112562009055647422476858980542361171789938401410081319633291657953063544835694.", r = "93930563766922787981501364474417807514895857693567522501183298330195861637964."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "480591498606110478568470151153130963130385653661993605493289274531547199816202233734902597095423699040209855401609221922843799775208231268832508186031228."); - l = "57732686192114257568587162558625193203532844970972275322250348432317602108605.", r = "63557454376452829266092812774041468018873431581692229362343720415521236010692."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "1223114189561790048770844346700130031028896190397466878906306625517113510192857857519164993323417314207428891013013248190023116609850936254031879175068220."); - l = "56926535338106282990865267288925080081520385997290691237155694981263201896618.", r = "58612183323799845379130043631108275902248167582900961483328012532886276304499."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "3336588525225855672558779227154762810282816544445857742652530195543518942898196225038095333959447066870191134607652527076724793124916864040566728886284382."); - l = "94857092396393060862336380007179474899216418662468210099879820123368583017782.", r = "82839225584132591954099525884722405464481402042292739851530518892703030325440."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "3928944037639856601974180993619706073033527230306079114549826642611710668375611333691209593035601747039017177112877132243366120923453099402803468383487040."); - l = "100216969915146904450853143373708165101190869516291594230707101649368060613141.", r = "50572698133082630703059823421389444930568905645073009402019834158807388460433."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "5068242567330948021825003915237367225118821193727994909065737408287699452533576544023292300624004618792841716566900646647475556279679528916084937998350053."); - l = "33278054850265842511823508642403196065765942220801842524458566320673304355960.", r = "17028816936137193738681789179955375002198329416999478562807743771826719385828."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "141671476008977365957153640791871756918944637607698908644326329425840711393747979564296937888723298669341869290007835934867161516473574150438642072833720."); - l = "66723199105003358170426434325268668390905226712220871236617608648912156434243.", r = "2992881685545027601393900167232275080613534168184605413481102433259365469642."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "199694640602338927697291990618256408748563242434084575350060370495823113783426629993907545550337164214433992488158026414841252995941974359189407785751006."); - l = "93579083085542199025056589105247868767616095558217192257416612696150076351629.", r = "58012737282568456836142715237492929601916625360368417403675113098352964424684."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "5428778762185205194065108035814957758050288181371725368479085568779482061315392326004575800760401488678970084239091499906979755650572453337817403671210236."); - l = "9705229121684709192196245989541349934775298411310292551338495276136656231243.", r = "68928988145144834362648812763567267868272445686115794669115064955783333239170."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "668971623074519733010867468075100566328907437279793952066886573066672938669980291498699830468671777991216341938141127051678254590435315918257343745388310."); - l = "41460550331568012785266416757870279990256147094359536766987081581827478513858.", r = "20047284242792633322684046815462369009052142801038743320039754034390180104180."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "415585718679777155815472939653204076385910762443168697210260444266230637560808572776542697317426770313010270341907192242998914083922892582247913006863220."); - l = "102805589161881168617678502421149630686111842598862240236480632062998679924629.", r = "40734529556131787324939805904071270047875302368461145508437087307433721719659."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "4187737310250190205201149642664115112883047954426194387780669708454616221150904615605868665785866977770809398480651464656925951833754092865260010387581511."); - l = "21038908898221815233929890132936155269053371391691638129626208967166503982728.", r = "6798285876510020288639788851603872281952760092917977456050867110948396156053."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "143028517219962358408844520321455161750572708646998975980264902346946621551550891448357373775252886386336201873874629799110545448556494940517750304652584."); - l = "49103160083412815477140503017078322770823305089601406224250739694178093915301.", r = "115202092683830997572183448006778988558754277174658971324858041602440206129422."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "5656786798998313786363368340365737525802412187467154860198905277658517921060498206629665815913184760397845605525225471150159523077709917062198262712086022."); - l = "19452603255167304115449260480936666780014721303187332227323296234395920133766.", r = "49825621582733576490578645089685592371834791570728762920738583295508508583323."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "969238048591017453384030451315876037969990718832897964371659026310364557014954805583971498612860033595495752274735092183847243344141062930882401316784418."); - l = "94617532627429483695065110009946356127684397083548387554415344960096990953973.", r = "84279937098366922918120462947567563337582230368206365080742047087508603493875."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "7974359698242436896427718624521226012412803817478631504873087736287604748181001247936996779946915564609492549240959914106578228967319717784715937112415375."); - l = "45817717205721929485761764914978225171622776456569427346940265647809580000433.", r = "54122354456243599988778051829439083813473888984913775428509711108695507685900."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "130513827946527017599883466323542060676929443639039424936386502334427482981915486158478981010874047525915278789928307244072940219031507910511372464631300."); - l = "75590315832253936171897904171805487553837625848728936394570977088163335928766.", r = "100394120235167471591538898304342427819858690414500030374152205751939641346081."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "7588823256277584989590889368402178627767217045338443698866115919319425000569862444694273063113095883796487986281758700653870297945804318317363074569266046."); - l = "70176423169192876784874404824532538701163439226713214104127598596270312163813.", r = "16607648561938125670799346464151342769206367277202815726222927933472212113424."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "1165465373327807443727667582469999714757320187826716805685932499081975188863529182296509370165409220702696001010228454433529504858092329319391351224325712."); - l = "8720764263540820948538075000211372388622786639122083293654620961763476699218.", r = "110961702458500132874127368768157413968053611045363558724462620361461962525319."; - EXPECT_EQ(Aesi < 512 > ::lcm(l, r), "967670849421737612524447125456492735431589633387181601120103714572698658380496264988047235569079380444672810675962950119507564413129327813249961872500542."); - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(NumberTheory, LeastCommonMultiplierDifferentPrecision) { - { - Aesi < 320 > l = "1428889428460167499315584507836389062688806223786162622539505586101940356860019810643119393548628."; - Aesi < 384 > r = "37686189677831851764349235137567848340730893948168055139726293042862756252397017656166338203011546510825102809516478."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "26924699014799309305261222989301759825749407053895948012484824872796619478759411783758695207498023836908322939173365537843992922082255100083466369611484002201518595950799733525754088165961194294483229518630146092."); - }{ - Aesi < 320 > l = "445585476497040275428792754199092245882117256190144061470899631735583560602363446124722321311115."; - Aesi < 512 > r = "11584600468772085186548809762410644233133379730489671847396734272870161665705497396072163081488595394932743565493805527498541312095431267177664485822616351."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "5161929719905645721091899069963718053756393957402451931250513530788134121568470308624606114017656500971498638316159565803927540341412593710598623433087145569278412856969683509403203401804862651267619303691939307357060345658422643352938095973957041365."); - }{ - Aesi < 128 > l = "305620482598245835119228405874136670768."; - Aesi < 352 > r = "6271999313249005520885471454193195421506548847953467911460218230725712111416876104921847811252390153684439."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "1916851456971027520335557203151863010157534059895608810532283646768238240168682987090001784100848653729109392231802571077997512814134376307779152."); - }{ - Aesi < 320 > l = "1837770559905153169087220399359752990754417457846184412690419054182283654937923779719863640650083."; - Aesi < 448 > r = "136504835877519612817189808871499938081871306911540530573462312893806907768275342682609910873426579197810764102551241119801118913656932."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "250864568660390259170778259559786772271347897156553294936917596581238714907038688852414726850617701869525850430523883910623991474476412116677749345328970456255964161981520915173849574561421555770565926411540389127623567499319325356."); - }{ - Aesi < 192 > l = "736745538918083971598635012752780845779336778127334084251."; - Aesi < 448 > r = "236137152806546033963495875795062351404943552190049467644279299951246065349676293037908806771776531069013019803244832996703701732902727."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "57990997967680234268276528836891198950453264333239805016267543533494372539178761438801952587550697481270206883874927557591177090207982234568971054316433876480553223680145603111538846201884159."); - }{ - Aesi < 224 > l = "20987765443050621571752605242244785856580884608015774485032635454524."; - Aesi < 416 > r = "64925246197587632193302863526859179415854504442889274249761422073469402834877306916723026313899386062776685896614658762467967."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "1362635838527283474919742878156093156449185309273351864233320993372506331879982967457091433644652739958587196176751106704330735424524796842696943284523169209953849550527005370016296455035232708."); - }{ - Aesi < 160 > l = "1314788776006130017721621445936096241905701642733."; - Aesi < 640 > r = "3944444654705246436004675629488289041625535259075058089861445332694212491822049164757621999207407513920003292340582793212537190066020470748745023655314270383772905995252026829745010895354716350."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "5186111559583833118008247946957140928966707676416407075856865531766477721024256755847913093746017006460925177722339533923714980117730404902248679704751492706868803810563925520688919689788339109918998445374688835745566562289990106934253784550."); - }{ - Aesi < 256 > l = "110399586982739171513359810869059310734225326557977183334542988597723463551241."; - Aesi < 640 > r = "701518975508802776870268459014545016104492890889996046236526008102726918559585392170531744975512156852714786407059748480023113189013212237115990723675733917646187035405253304327671756753938302."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "77447405156726142714549806316304581899954243804137127951984817110733474726946564821930445066723855627184320142717513716378689678786495666636390613692128889599151039130686313780688438830823928195648701096132741220307535555646862724046211532191052223874123624577529532782."); - }{ - Aesi < 96 > l = "46986841881701486685010196721."; - Aesi < 544 > r = "1850030646886377033980072771117645731129758366901627442901625282252078133633872862798157869304067930592208210526959537444141119550083489269528394057052837520995365."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "86927097481552114534223037844952887127154979249884951534535030491981190278552783077727334193700708270395167843413393742858392715097567366663074561440196160988636803687106047360674946379198165."); - }{ - Aesi < 96 > l = "37432449885296018646891067943."; - Aesi < 608 > r = "474785937839241632872893099626320987784561403392170270532920426519368853391253382226229336540701190676293935967837120175609367625871135730724760006971570298762958393672988822199758241."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "17772400824410683099802218529550174414107428588690970970689363415741562774751533506516827360875738182130577641557623673793005913241120221771838079841022706382788306164418704389405643713713733825487692996905168263."); - }{ - Aesi < 224 > l = "3364715296031669908140499951214133735077241047038308382972670181872."; - Aesi < 640 > r = "1340112860391689483714360232296503479518714923091520466970255347910445541122497710271554956230354056150688985584447589453493401429561616255045531160189603568326365865488867385402600561760079136."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "281818639985541963020159888117651583573708273570980098595544706624234811759045513488752330586363278402666521951315590058380575324336285339521043290022826940467397923979957403758746056973750509219054746435471380882128140799100188083228231390066468352639538912."); - }{ - Aesi < 256 > l = "58459790092021701394508470089135364827491339037462067537220849857589060558016."; - Aesi < 448 > r = "700810673265953137558889418159425740745263315907468855822986582028086842518244552890381470838890913902029495154731308458789677139055053."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "40969244853376025080897767655566297681110746202326253231627776138585555694240516429989625367186258551449025606465851761331709773774010898743518152650919109934842002332591576664955719259631406725689668947124454848."); - }{ - Aesi < 256 > l = "102604921090451980581136985858974342028181180519082939001561541583346238258440."; - Aesi < 384 > r = "6297843124891467970932450305672396890332225656708639491750711684374438851930714243084886927944869720408528188031971."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "646189696869534588767284494039456514464962192367149355850873646325436200409030406695870506255979871881132954546043455788486158332166073552748360199761965876711586616535504175097931490080585240."); - }{ - Aesi < 320 > l = "164478560530762243207335500907553685451566263201717994093412784352639388362101842969818304731744."; - Aesi < 448 > r = "5319490946670577608061369874191711536817998258556740008972445270431702956059055458359886428179258995153358658245821341884101651831898."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "437471106832399173459083490947901295311581977344438861074328125329398011377033185036378999649234140661761231729350287049808878263725094838714768869553352455368164452187042064365982882007635154071947567235430347482945289536185056."); - }{ - Aesi < 96 > l = "70235915751471253643981998332."; - Aesi < 416 > r = "4334467509962420771132050113552011379747797773430954899496107692253698092306633544255417130308962006634014829681913759322516."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "76108823714302493016508623529433798263640842009603506607150818581273131443051354593315289942003876829085835133381501479898381625213245069787087040510828."); - }{ - Aesi < 288 > l = "361256790755252514861386171795771684420236715678259357620152244344774664332258164739563."; - Aesi < 384 > r = "3141997076702265320784863668039137145169069378014210867247433364574596340960664084566870763246633646121734094642612."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "1135067780491845349381569676015298955735143592957503511871076986659206982661981970997944129256027525651105128740901677059016486211243698453754376220204749343752947753257802119081962391252531520542058556."); - }{ - Aesi < 160 > l = "946634033776095183313917225198261895455421216618."; - Aesi < 608 > r = "431329519518825820299821291418785609121430182478018629601938221520443028858516275878797355054829005079497379652449591746136297065139538237025402817478759681709013419579565245309412856."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "204155601474405534107310030569598789014243432482075048800181701758440183889049210812956071919368206636463280792769053991269112587998498911401603294225214443561303353569872048234218434135641133688843919973721380119122270363385020504."); - }{ - Aesi < 192 > l = "1844114173391421390979423241481847640598628768827078369521."; - Aesi < 576 > r = "71861083688914837449188768964192244014641761931625820086276725769455894898934907878160916911598317313444448922231861553100328099855510337630854003043773057025158939609074144."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "132520042945994940064843964988270268498265138636092631709529566563101778615922966414129207924516464561156614716649336466170005637541564367684770204959035558233477757845179209188064357817790140820120035090104826891124940155918765024."); - }{ - Aesi < 192 > l = "5299229054500554625121192511853312859523532077992743228522."; - Aesi < 608 > r = "770471062032868455419038686290226753515984268772178504426631523011878517911913066952323577807975081815468900902522009220457806472517268069227185299429158699022691044513423254242445060."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "2041451318788237837769631540916910086862411044828582684239761651236631689305463275660846247897174473521257659584675800550964128342448899665524213311651509628378672876514120410471068614823949612127144441856574928819732539901553081095805000660."); - }{ - Aesi < 192 > l = "2879878003743117154578359632132509661689455731246921824735."; - Aesi < 640 > r = "3961473525855131383612150297550357803535448068571393953913076252505955031196463560085793829025041484426974822895258708072648124970251885054025178797125506130889763696203443724383446519861816018."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "3802853489840294523603517782215791127052460161409713367238824009250547260898357013121715419835890999016759260930484127233604562998025422118523451743127789193814027922887165005727986473730659730393920057956766242030789514751976435730088063071803868410."); - }{ - Aesi < 256 > l = "82338319530068144072624636475015227439533620323150727405791267951532216684209."; - Aesi < 640 > r = "213691639252703915319983911070132194263429101197243967214390495271734717116033410728371393137326779737771256496203368143158732788579122164205896911554107624434484953606588781410804927459336552."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "17595010473693187214683411338234930321676797016490578027937992339897434239289232746386763130129570904309355152204868157331267139489641490263772399948359765521035724703340132550719870897454187693514929171143729675138950655282118949850819718813896924898571826384434907368."); - }{ - Aesi < 192 > l = "3496689099380818433396281878889312361917659529211011466686."; - Aesi < 416 > r = "39182023725984497021329813988369751998957880998246510906448523032167378677799834119862249774501538076786998243297400938900092."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "68503677627165295335053647287802481939144481656804652643193072241199190307220302893767294049029749454026842872130079727759677059083143163976478360841727050942959121892884942270167556."); - }{ - Aesi < 192 > l = "4209759469076710452598294370916527042018268331320076890549."; - Aesi < 448 > r = "47493678053254403877188463096562432456409900736907427690763947901229064620108246572845697171850854871803099337283593489773355798161737."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "199936960905968474526967271244104351154512369617441654200280591408366656070481646124927606978429151005273911570217203821125556217564857418975370724808160016222735817293137157675595829148723613."); - }{ - Aesi < 160 > l = "36761795452760763959413179769039814100415903483."; - Aesi < 416 > r = "165824316049752752761220383576514437930634226943088106567313678849229651001067095531502783247344752603588699762436264652980278."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "6095999587714964515426904336701200139875491840661852385637018922870083768118973053398398019595620952461507973405318672653578894238921738107559330640754519121004083950508274."); - }{ - Aesi < 256 > l = "20502000005070124748943875670332768408145605290301146881830919926724552535338."; - Aesi < 448 > r = "331206984434640621379769611312757764558751643463637667001064822711340452232638891267108849430797188216399819718318686694492529427279526."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "3395202798279131374166588494264984355264874049790251126112653765572286444648100058977948649070937210542909015436304577435140968177654148849923565081607561844862643968801286984658666088241690481535514831659444894."); - }{ - Aesi < 96 > l = "33562356283677538908849792488."; - Aesi < 544 > r = "50146589460452462515620400195367870547299823939120321826940238258163119614231417889357007831196540142197869437410169197775954481460907704677094654517983005797974995."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "1683037701883014550839527789801036132177267227082408976609345424567798626450952277060876730476305331173417129288307768466048537161053806908058118340538461109061560477300398450962385056362837560."); - }{ - Aesi < 192 > l = "651747476140043414778140015459153856923590767607148580957."; - Aesi < 448 > r = "369967480937830400094643361935006223992960983239415307725842173740425908938713894492953063443013975142860630301501791780711143348398453."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "241125371955120585565154164579882119455530541574278524918931394486973986071819783884952593272309201233370471994172423651158533247281883899447686630626076493783404755630700236180581197564059521."); - }{ - Aesi < 192 > l = "5327691866944609449828768397433300072605439958605987230196."; - Aesi < 448 > r = "551887659176002254442454407714321187585772295693616892225578571352447834574651440078400223292296330359321501930031019320573678860673468."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "735071848314771442873064261876397998791123167696296441525980057126747675214736069259622038235941225572459679014937936499077710761941643743515442333976339051754242477159583442038963966126409932."); - }{ - Aesi < 192 > l = "1174681724141055414854997540388633347685533492168015644637."; - Aesi < 384 > r = "11876159235381469984990137786310697750701997191444612254295117051723724238876261492865419592421498285751448276689294."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "4650235735597207842484404269999087008281938140907131020306521701191980335518244190189644578860015126373755028657158712451693462176313124337764807253710642999654157188805426."); - }{ - Aesi < 320 > l = "2009968702278837526057151241692860897837685532905733600285477750051215084261388738778647252461209."; - Aesi < 480 > r = "2038876764682567264168983741190897343271666198928438046832554117351517921573834067135703440711493675291968505649114697701286496696966769571875253."; - EXPECT_EQ(AesiMultiprecision::lcm(l, r), "4098078484815494518988918928970371415570484750740385558683521371491536161647777095989028821989315177308012450600299021387444091565797254015441361414486134159012436672112591485508373278429950420503002623854285576158420392669943062729769560877."); - } -} \ No newline at end of file diff --git a/test/number-theory/powm.cpp b/test/number-theory/powm.cpp deleted file mode 100644 index 99cb068..0000000 --- a/test/number-theory/powm.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../../Aesi-Multiprecision.h" -#include "../benchmarks/benchmarks.h" - -TEST(NumberTheory, PowerByModulo) { - const auto timeStart = std::chrono::system_clock::now(); - - { - Aesi<256> b = "567572101034080205309651342998777317", p = "297984066927063188700878055519124646", m = "404818736618427895605379763906126248"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "182666762144093873740458481734649201"); - } - { - Aesi<256> b = "998768703011680273071786097456599575", p = "838719183048403110675655836166326299", m = "299696190112372209326961437583217431"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "288068419767832246270635192692632100"); - } - { - Aesi<256> b = "336456408630160900533549512247987136", p = "1248587571926291978959593107595237657", m = "648309516697674152971948494703831645"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "342048795736812234798237393335119506"); - } - { - Aesi<256> b = "914622560964721141493427459992503802", p = "763219652393220675205198670391678759", m = "430237715242853439053627172666944224"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "317650254686275561023962294519200192"); - } - { - Aesi<256> b = "1268916760840853298809823787329054222", p = "180973113846446321166664497121211451", m = "725715288027406622232457399087116006"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "147257091509176954426131091388189154"); - } - { - Aesi<256> b = "739748799134972105280587885776960570", p = "374259178181313322219152261747779832", m = "1317547854141801674067189843865389281"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "118273094801801927102290609402637169"); - } - { - Aesi<256> b = "481801615922442100257464371151014390", p = "116178865189292043368782719437895613", m = "888815380137097058825615103001743830"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "704914547540667683549083274460815110"); - } - { - Aesi<256> b = "213891809419059586269650697995286990", p = "239205021221667068048306224932980950", m = "307413653426687016222961491463595999"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "216335195445956514645489641017549279"); - } - { - Aesi<256> b = "16261504851869305191222225440261647", p = "613486208131019520782057825758758712", m = "1300414911115762793164221394710419151"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "341297668412692151171933963210103967"); - } - { - Aesi<256> b = "683928816373481423428744426290111792", p = "769875870630110531832229895167355557", m = "112918646288557667535576576144272708"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "4040468718105829451983915859094792"); - } - { - Aesi<256> b = "431122693523566469035943041277850522", p = "331638265143889161152421797881215050", m = "459954073315887393821781260618109227"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "314295149673166424777277606342885393"); - } - { - Aesi<256> b = "216681731926550509833580969318138121", p = "213639025647391699485675325836934950", m = "120888597348194426809276828942041873"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "99251907618050393999666762894848636"); - } - { - Aesi<256> b = "353365877311171025337974453038167482", p = "532525439689781546585505012663603902", m = "861377484159908158248610262999312907"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "414420046914662369954883502533346708"); - } - { - Aesi<256> b = "38094963576592760842299969233537698", p = "257991736481218916180183475563476471", m = "39592757717470104035137061802549155"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "16824517390095560686216650980057602"); - } - { - Aesi<256> b = "943156363090414771103156489542459730", p = "266402687154323589798964370904444134", m = "124506249547714908745479396139111029"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "69675975838328185976578300731318046"); - } - { - Aesi<256> b = "32348159896111353551278557698452121", p = "351831962750096628745196084807553289", m = "1131434265651623294422527905026158541"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "786284866700529729106717972983420984"); - } - { - Aesi<256> b = "808341467553486722539006187327192843", p = "1009106397684136359838378432494278682", m = "557381914688765421974873076415483704"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "123266924323935231025494069883455769"); - } - { - Aesi<256> b = "592548817422390740079205185329819816", p = "1176148706585967900425263973807735024", m = "178396324310660279122390901795113102"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "86180423494525298280198194832412116"); - } - { - Aesi<256> b = "556769364075128644512218688350625840", p = "265846140935516241301559164620444142", m = "742204900710401335678268288065380412"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "368186945165022391752850275803222032"); - } - { - Aesi<256> b = "548061049101635700037533890738112897", p = "878509262951597220615403188969003554", m = "1218953220570637031139681530171623326"; - EXPECT_EQ(Aesi<256>::powm(b, p, m), "1082145722968065276870199316893301073"); - } - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} - -TEST(NumberTheory, PowerByModuloDifferentPrecision) { - { - Aesi < 1088 > b = "28793048285076456849987446542225640606265293220424618926480394046852138561538086130369569608684063330929781666943229330417701929475565397707259833702883043470999551"; - Aesi < 512 > p = "115792089237316195423570984637466491971220643441904616453966139132392564064256"; - Aesi < 960 > m = "3121745573184599697933326506281725673488773347286281875230608438576618760350198733928207019107265771354178414155544146158372110284329493119107072"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "1286836696482081140314397122337047802239648832365860657790787629905517321601268779927276198715392010886217965690239863155957940369407301606440961"); - } - { - Aesi < 1024 > b = "13407807929942597099574024998205840962979609646775214065885217437705972534855967544372580674851683074864211086053989552841267536093376052211498616578637824"; - Aesi < 320 > p = "1461144825407731620530278796051549176363871109120"; - Aesi < 1088 > m = "57586096570152913699974892898380567793532123114264532903689671329430453039077084285042523271276718195461686303871834374018121798118265098455642255034105415086374911"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "42564106683845511631498521655651469549617377615639896347806059028514635640668676047385020376805556204505439186893523848592594858588418496205410276056718237776373363"); - } - { - Aesi < 832 > b = "169230328010303040104789128755083054127923732022899807468809113220112422547386864369054315593043409610121512739103191611736064"; - Aesi < 576 > p = "497323235483449955863837968976039649428411832473088307844669270716132876116016121249792"; - Aesi < 1152 > m = "247330401473104534060502521019647190023501929512482129665273875166691446055489595470830922917634503889644788508017545565362328433794782571145209373548919260370265165831077888"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "55563801833497614384214020422460598554623823483619729019925294819559150020877392844322847134219839231707844120715314831750084637976551028897860408786676578680286523449933824"); - } - { - Aesi < 960 > b = "3121748550315992231381597229793166305748598142664971150859156959625255946730528303924882532078483283251973661136740982331408518095280372176650240"; - Aesi < 384 > p = "6277101735386680763835789422575079056027526123990582034431"; - Aesi < 1152 > m = "247330401473104534060502521019647190035131349101211839914063056092897225106531867170316401061243044989597671426016139339351365034306751209967546155101893167916606772131921920"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "81719070410459849960569981916324100519056896839959044892894431146871324540741163585133503747046455790127428872500488867769790021865305550496403957465924800510614288444948480"); - } - { - Aesi < 1280 > b = "4562440617622195218641171605700291324893228507248169712010403018870352467554953240717694236549538278384784914953641235843336234018860399735369724823327235821862467883605650806576529468624470015"; - Aesi < 640 > p = "2135987035920910082395021706169551291856702963489018373226286118570173662888770803297219548020736"; - Aesi < 832 > m = "169230328010303641331690318839301489908704318298266917863074585613767653132821522082282056581704256758716025351527221690367999"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "86903993352159273726024218988856437095769082421817875105919859082069441199773555795349230693287571703209411791651700879814984"); - } - { - Aesi < 1024 > b = "13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946551499689575296532480"; - Aesi < 192 > p = "79228162514264337593536610303"; - Aesi < 960 > m = "3121748550315992231360443438791916829103813019291528218834738035592802360069254495148035631253882535571969826625245784523250285503002430152900607"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "167648241824788377642688807762960368919909878668492835130280239250424359095899275731967252385659208273069031431040545192513035811684446348615715"); - } - { - Aesi < 1088 > b = "57586096570152913699974892898380567793532123114264532903689671329431520511113834798455284506659101071783731920229799439845945850001882401931509362202255401183871999"; - Aesi < 512 > p = "115792089237316195323137357245424007756186726618908221633794085042696929411079"; - Aesi < 1088 > m = "57586096570152913699974892898380567793532123114264532903689671329431521032595044740083720782129802971518987656109067457577065805510327036016891142675844838996312064"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "39425654526107845777534757940252133690690500017817066812291843029593672275529926593423190550750419392824945760638655783123482275062105795307978947593311022434229247"); - } - { - Aesi < 1216 > b = "1062275985633534197379176413104937254659186235454063846398888276400807119721704485478325004530458571337778658972493002030693158675305414478819039957533174703887662541670777916848340992"; - Aesi < 640 > p = "2135987035920910082395021706166182121269310692382319393235388725851535576021070777467889459920895"; - Aesi < 1088 > m = "57586096570152913699974892898198858112458221391627201951717670195843110692423215225013348232334643149490638175301464937724654427531985572965205873684212146126192640"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "52805426313587856528879255792073388076887345584000467946817726849023223060397538582575761013521794712684325354210839369723119298304221565695114180849032759143825408"); - } - { - Aesi < 1088 > b = "57586096570152913699974892898369211025110932197875125602495188346570005377472866204388234174818635354569564200889698953789765988726003027997523531343887529083404287"; - Aesi < 320 > p = "1461501637330902918202446892677015653779542900224"; - Aesi < 896 > m = "726838724295606890549323807886857785319052665529389133028993772601213061236285265346505431407524514935530011739795894737435778042822656"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "601472881595829681311768882757452224394957009400235631029169398952722344346849528336215179275540154188455637790277240554377393333075969"); - } - { - Aesi < 1088 > b = "57586096570152913699974892898380567790824437866099674642382626227729290853457899158662024907939881506075021535205136185077090799549253229283575389860596013917536255"; - Aesi < 640 > p = "2135987035920910082395021706169552114602704522356652769947041607822219725780640550022962086936575"; - Aesi < 1216 > m = "1062275985633534197379176413104937254659186235454063846398882987953056797732912870155929093947289413222951585417336150507998249973690913492664547841982744437630392702545436270131150847"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "283134526851189100852240159489524993577982883156885921970936798893693737332300616573823900258478833841330461507282794088468469403324860657710499652143142023883259032958999851114066538"); - } - { - Aesi < 1216 > b = "1062275985633534197379176413098233350694217985486845501860948811928112156625225383756074256777023821120951484760158914493906870028350298551175190050077976241237449780259849816638488576"; - Aesi < 512 > p = "115792089237316195411016781724986755903953896272547229400021678868641165213680"; - Aesi < 1216 > m = "1062275981676247773809503868136896918344831194891962260779498837775798222235348883782564132704528202055379948047400744675847606966191432593882325306975554164754257180661652547409281024"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "367212410660349293556324601728065904864465591684104661804455312007376321346007876135761176000158090074118654491979754235578022146043364297442338651781033978643260258822572193433518080"); - } - { - Aesi < 960 > b = "3121748550315992231381597229793166305748598142664971150859156959625364501814188287858092129876928928165586101747365020360195509581413690642530303"; - Aesi < 320 > p = "1461490486963620564874634758333721921125397561407"; - Aesi < 1024 > m = "13407807929942597099574024998205846127479365820592393360225555645457668635093529159860903375341547980544332366780321199574129889216939184158328232821653504"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "7558784404007254179446202013527355286311652987153519874299029622893115829321653711359187394756810497438550966453777044499316481698080147321408978876891135"); - } - { - Aesi < 768 > b = "39402006196394474837777590534119765060075285035223558459942780075314432264177467154966809113375959303628109239026687"; - Aesi < 576 > p = "497323236409786642155375666128591555276287530920617488043514648350609880299066793918463"; - Aesi < 1088 > m = "57586096570152913699974892898380567793532123113003668714652434414310560084205278948179183670766658714471158035184897947977991938123264469667722602304733233878663167"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "53750455023425484251590451536225101504065350384994488259671724003959955961949211487858823711077412591697854622831147179340278924737999949165432908832771319540000734"); - } - { - Aesi < 1280 > b = "4562440617622195218641171603857536234648335268849363357831014348506247558079881512662571649039502557186432406335067778684252157262718916566987175660155911237399442436210624017667798014472740864"; - Aesi < 640 > p = "2135986017402921915152204728370999543107810658702551030548942207690795127816630233948373376827392"; - Aesi < 1152 > m = "247330401444311485775426064169659743585941065205122699668893200193986361758817106118602877866534999448796070226567555134413719075795233475073408356551927274789783246120943615"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "71264946182442896501111445551292324403933274599945950715454908540527922469326567258770589455295819618860258960659949847068266956542322357308123242207639532834185396056696466"); - } - { - Aesi < 1280 > b = "4562440617622195218641171605700291269974847226203682213701117539962914098952224014513569647584321690996277108355474989175092994780793822144284304711061489162472004594364639851026124360325783552"; - Aesi < 320 > p = "1461501637325586006220545169224667791414811230207"; - Aesi < 896 > m = "726838724295606890549323807888004534353641360687318060281490199180639288113397923326191050713763565560762521606115062206082772981776384"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "573085401894547166516877089750418966107279455078782547574800402627962088464692182111276871789969819688769511207932354915166690109030400"); - } - { - Aesi<864> b = "11090678776483259438313656736572334813745740344331483744095643836342514882089060884861484872297597135700949968707655805690179485695"; - Aesi<256> p = "340282366920938463463374607430694469632"; - Aesi<672> m = "139984046386112763159838289862099970323476066441406953502400293335070582272926757986317508127144017920"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "69079484759223978771725604820876564626247001712169147692709103033711794245882473503725969639949205505"); - } - { - Aesi<768> b = "39402006196394479212279039590884619721458231838130542792678389807758629298361274489173579184684013616334120517894144"; - Aesi<128> p = "18167520626212866175"; - Aesi<736> m = "601226901190101306339707032778070279008174732520529886116452717031736444463277932798047865154700400216954896384"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "166447213589684059641991998731395753952867333867023648121519053118548941940730378205117569499309680382883135488"); - } - { - Aesi<736> b = "601226901190101306339707032778070279008174732520529886901066488712245510429339599267430114963433206756870717439"; - Aesi<128> p = "9223510592466305031"; - Aesi<832> m = "169230328005378390557158926912791928617237135317019459417751424189778811413571839323317524417207459349096616339035945982496767"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "163571374596502077158450643805430090015294226721581258074063672607038855306387274368353843169596610829477792365728343013827463"); - } - { - Aesi<736> b = "601226901190101306339707032778069815839817783676997359291355200569599889047518065525993786130227286043797749760"; - Aesi<256> p = "340282366920937896779396662524586754048"; - Aesi<800> m = "2582249878086908589655919172003011874329705792829223512830659356540647622016841194629645353280137831435903171972479057920"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "2579701408596237953229338966783854517127482461408021202063410591513655437652750417878791830806844428048643028427032494080"); - } - { - Aesi<704> b = "9173924471937092994040168135609609028485434160723415743258425125724447672427269041667050124299132165160960"; - Aesi<256> p = "170141183460469533963142207355997913103"; - Aesi<768> m = "39402006196394479212279040100143613805079739270465446667948293404245721771497209282186270469969042736999567709962240"; - EXPECT_EQ(AesiMultiprecision::powm(b, p, m), "5482278480730755497604397215387492614088698182310191625462706667534436415097143802580027802613073006276679523368960"); - } -} - -TEST(NumberTheory, PowerByModuloHuge) { - const auto timeStart = std::chrono::system_clock::now(); - - { - Aesi<2048> b = "6830171368312288096475908992405588501389780043799306084349131369952807274139586731773092160775146076312263272393170577747518778448948163309509561003089707902453708458796000467268431451552569515654251657999779243061161220652165286993066871166534158075697454405543156721108200637842315713915207460883998684249", - p = "102618672105036018644968797310246279513453448452020833987356615341017262261890796129357088577082418514014678547486176373518826555460073808288739474503394162621645188677442688997297349313621476640613824248811265299373932191159668022903457609442812601652761472717901164634182128574535238693392969025882643988432", - m = "130867420213148255042714304040581763908284083990870492540583938432666213785455334578503359216899680520648339815937677146332390945201160603659087503407954102331629293108006611414812322100821131413783243481182824097205519281079779111825441360293552432745125461715677860177902708485952079170032728993896531326027"; - EXPECT_EQ(Aesi<2048>::powm(b, p, m), "52243375550600445155490601836045351615978014701779721243138435858058893432023032638723274043428422989232936398439091961339335905031983551857362264380894936663357945140415783629514549942874263662259394183281446759483780345247637517637452710564976718010235099070969606092324131094175192186382905483645573245602"); - } - { - Aesi<2048> b = "89342520850149391279781763065175497997799439042694887521488341840168289823378481153406686518566784851530290977706002891345301027701629460091769942102784041539443462174931393769167927716456271590787466058738098799785252366526923514122181316794118689102831716623007794643968544213836774314065077176589415454713", - p = "172348137581825939131557498016944655699287488650842375126394034719939792791876600290688961376466654855754348508717790551064020615907030648456853246168332586932013431591495309132023845328615222128885553255599780035206386314890185046511157482779540682679353948800415683372589469079188515314299327533043124762522", - m = "80376298267965148987701210413571813727191584104544066222598799068314380725267073476121338604608526213965351335218677209931198366148446803528102324729792026025390352726490334052957136030865095958124323772518251406129973996022020458270379379625731238261333146331815633399103172933604944123608781047950959087937"; - EXPECT_EQ(Aesi<2048>::powm(b, p, m), "69782059039933138373313852634942506739708198882244799961220725681282118607233402914675259134464708458652818062327228324806386796587686370016083700999732734781593855336812067801051438860870487794796422319477005536489828135113902061396077788150231583472902114492789799655511373998160571226880028296654558107650"); - } - { - Aesi<2048> b = "99724623666340957739704577056778080532316964209499948225230569089343873610412513871684491912958410308829588608437510975444301976165083135895418285519699666793572500288683191785597691138288856363254718418098118143906874086168900543721517398708223602449102301791041440791957466665726860410409912744816331851748", - p = "156604441907158450291968029730220494179790131902927254260859143898381978964924076547870523846077645335826068815540777991648535336382091338254327745634369206274042304645955833269398717951314546465269899286119009105105487103980932695223350757826022471838454332046422011775948936155832110851363852386625884358706", - m = "98571318015400747842564192332799053567569453599401455773627074084850868231795947546951416858272568683594554778692778467220589231030331007944769485915791089577472159613785679495176586625545823782814414822157201505741667291856235224086456801948648090232369172682767586162503323504842222411825167971699351769567"; - EXPECT_EQ(Aesi<2048>::powm(b, p, m), "42463783697895964944158666384865788858038502027323828496598667402929250067168996381491020564989331222054291100770992698155432201077087584226113306880326436599000071205989494600994409708534444876911455704745731075583199081680527032768537509337980846684399073762563987564876085822718988694619038521045268926684"); - } - { - Aesi<2048> b = "106559103524847723378070937142290397017307511637358713827456814630485158326504801331424853897275428926375297164042147314868119680513634277062010961546769382645129815866563407154539245010248815340751474894630422779705207550573316490832948477980717315178369216976920854708881156538536207095381387422029051837118", - p = "122711914532141126803954995228153583168149388551858774426009988033725311162173090963083670370843867749885520764642916367133366434001474600256655387495210177039242749318326041097310895547505334241086756403285148575575132006973137768256062596355408175353602333306622835452726314049505305567805249079551144415109", - m = "88690060370356778353509554993117118447221503121943201116582692867719571746928765343001623476589995283482223397461140486693744917574312134585589580269211776230389259841452415627936017533569138057983507895524992393416826303214870738569022975283682930055428981055369993363456993040153065352684531730854159903129"; - EXPECT_EQ(Aesi<2048>::powm(b, p, m), "60821044764354250284980047790991056308928712482556004973284249455737637292159231377967006527214750678953768957902512891249267919108356433914337879736217652551053634026612712449002594266664446215252862488738804919626585404642095140893585511259348928442950991804870670553903243180551340789989627193842262336513"); - } - { - Aesi<2048> b = "100390334490704871264490303982857535551939147625656138296880409745490328743072380338532486073571894609977468394128716739168566875609252841551557646784730733624127565556376333319921922456032008935318182356095201116958971713268270951570877960802787998446250788116142601752248389500322357777128411129744695325757", - p = "175303281932978985001521673033089056622393657993890048682003837386051264756294248143414070803811013236893489961293698949141846922154401295990243988705997568663871776719181741028388646126074617770998842064763945416386610681863106124454447788432851464858343086686544127386163910348287904948894585367950434543409", - m = "37091626457153802785754172645346827847419346326447719185887484113000823773299446368316933239049144716096930779015470924622016211624151240435807303312173996281773734110083926659121147442434350597676236347024495902689227626924961429462336991554823366237418085476944029292968917582674112246916639629128589127231"; - EXPECT_EQ(Aesi<2048>::powm(b, p, m), "6718546365501856191364734478512326699043874046505170587904327645452500015908127918042494970607515560751554256929445522143846790003020958133962511415991221245181925669366545168800595189568652808832173565039535084745369880301927229861467434718170000570941689789006007219462125660600295170823842399173353279811"); - } - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/operations/CMakeLists.txt b/test/operations/CMakeLists.txt old mode 100644 new mode 100755 index 5b46d82..91d53a8 --- a/test/operations/CMakeLists.txt +++ b/test/operations/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB OperationsTesting *.cpp) +file(GLOB OperationsTesting *.cpp casts/*.cpp display/*.cpp initialization/*.cpp) target_sources(AesiMultiprecision PRIVATE ${OperationsTesting}) \ No newline at end of file diff --git a/test/operations/basic_initialization.cpp b/test/operations/basic_initialization.cpp deleted file mode 100644 index eeb5ae2..0000000 --- a/test/operations/basic_initialization.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Initialization, ZeroInitialization) { - Aesi512 m0 {}; - EXPECT_EQ(m0, 0); - - Aesi512 m1(0); - EXPECT_EQ(m1, 0); - - Aesi512 m2 = 0; - EXPECT_EQ(m2, 0); - - Aesi512 m3 = Aesi512(0); - EXPECT_EQ(m3, 0); - - Aesi512 m4 = {}; - EXPECT_EQ(m4, 0); - - Aesi512 m5 = "0"; - EXPECT_EQ(m5, 0); - - Aesi512 m6 = "0"; - EXPECT_EQ(m6, 0); - - Aesi512 m7 = "Somebody once told me The world is gonna roll me I ain't the sharpest tool in the shed"; - EXPECT_EQ(m7, 0); -} - -TEST(Initialization, BasicInitialization) { - Aesi512 i01 = 1; - EXPECT_EQ(i01, 1); - - Aesi512 i02 = -1, i03 = 127, i04 = -127, i05 = -128, i06 = +127; - EXPECT_EQ(i02, -1); EXPECT_EQ(i03, 127); EXPECT_EQ(i04, -127); EXPECT_EQ(i05, -128); EXPECT_EQ(i06, 127); -} - -TEST(Initialization, SmallCharArrayInitialization) { - Aesi512 ten = "10", negativeTen = "-10"; - EXPECT_EQ(ten, 10); - EXPECT_EQ(negativeTen, -10); - - Aesi512 hexTenLC = "0xa", hexTenHC = "0xA", negativeHexTenLC = "-0xa", negativeHexTenHC = "-0xA"; - EXPECT_EQ(hexTenLC, 10); - EXPECT_EQ(hexTenHC, 10); EXPECT_EQ(negativeHexTenLC, -10); EXPECT_EQ(negativeHexTenHC, -10); -} - -TEST(Initialization, StringStringViewInitialization) { - using namespace std::string_literals; - using namespace std::string_view_literals; - - Aesi512 d0 = "489133282872437279"s; - EXPECT_EQ(d0, 489133282872437279); - Aesi512 d1 = "63018038201"sv; - EXPECT_EQ(d1, 63018038201); - Aesi512 d2 = "-489133282872437279"s; - EXPECT_EQ(d2, -489133282872437279); - Aesi512 d3 = "-63018038201"sv; - EXPECT_EQ(d3, -63018038201); - - Aesi512 b0 = "0b11011001001110000000010000100010101011011101010101000011111"s; - EXPECT_EQ(b0, 489133282872437279); - Aesi512 b1 = "0b111010101100001010101111001110111001"sv; - EXPECT_EQ(b1, 63018038201); - Aesi512 b2 = "-0b11011001001110000000010000100010101011011101010101000011111"s; - EXPECT_EQ(b2, -489133282872437279); - Aesi512 b3 = "-0b111010101100001010101111001110111001"sv; - EXPECT_EQ(b3, -63018038201); - - Aesi512 o0 = "0o106274176273174613"s; - EXPECT_EQ(o0, 2475842268363147); - Aesi512 o1 = "0o642054234601645202742"sv; - EXPECT_EQ(o1, 7531577461358003682); - Aesi512 o2 = "-0o106274176273174613"s; - EXPECT_EQ(o2, -2475842268363147); - Aesi512 o3 = "-0o642054234601645202742"sv; - EXPECT_EQ(o3, -7531577461358003682); - - Aesi512 h0 = "0x688589CC0E9505E2"s; - EXPECT_EQ(h0, 7531577461358003682); - Aesi512 h1 = "0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h1, 1066340417491710); - Aesi512 h2 = "-0x688589CC0E9505E2"s; - EXPECT_EQ(h2, -7531577461358003682); - Aesi512 h3 = "-0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h3, -1066340417491710); - Aesi512 h4 = "0x688589cc0e9505e2"s; - EXPECT_EQ(h4, 7531577461358003682); - Aesi512 h5 = "0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h5, 1066340417491710); - Aesi512 h6 = "-0x688589cc0e9505e2"s; - EXPECT_EQ(h6, -7531577461358003682); - Aesi512 h7 = "-0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h7, -1066340417491710); - - d0 = L"489133282872437279"s; - EXPECT_EQ(d0, 489133282872437279); - d1 = L"63018038201"sv; - EXPECT_EQ(d1, 63018038201); - d2 = L"-489133282872437279"s; - EXPECT_EQ(d2, -489133282872437279); - d3 = L"-63018038201"sv; - EXPECT_EQ(d3, -63018038201); - - b0 = L"0b11011001001110000000010000100010101011011101010101000011111"s; - EXPECT_EQ(b0, 489133282872437279); - b1 = L"0b111010101100001010101111001110111001"sv; - EXPECT_EQ(b1, 63018038201); - b2 = L"-0b11011001001110000000010000100010101011011101010101000011111"s; - EXPECT_EQ(b2, -489133282872437279); - b3 = L"-0b111010101100001010101111001110111001"sv; - EXPECT_EQ(b3, -63018038201); - - o0 = L"0o106274176273174613"s; - EXPECT_EQ(o0, 2475842268363147); - o1 = L"0o642054234601645202742"sv; - EXPECT_EQ(o1, 7531577461358003682); - o2 = L"-0o106274176273174613"s; - EXPECT_EQ(o2, -2475842268363147); - o3 = L"-0o642054234601645202742"sv; - EXPECT_EQ(o3, -7531577461358003682); - - h0 = L"0x688589CC0E9505E2"s; - EXPECT_EQ(h0, 7531577461358003682); - h1 = L"0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h1, 1066340417491710); - h2 = L"-0x688589CC0E9505E2"s; - EXPECT_EQ(h2, -7531577461358003682); - h3 = L"-0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h3, -1066340417491710); - h4 = L"0x688589cc0e9505e2"s; - EXPECT_EQ(h4, 7531577461358003682); - h5 = L"0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h5, 1066340417491710); - h6 = L"-0x688589cc0e9505e2"s; - EXPECT_EQ(h6, -7531577461358003682); - h7 = L"-0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h7, -1066340417491710); -} - -TEST(Initialization, DifferentPrecisions) { - long long iValue0 = 3218136187561313218; - Aesi < 96 > o00 = iValue0; - Aesi < 96 > o01 = iValue0; - - Aesi < 128 > o02 = iValue0; Aesi < 160 > o03 = iValue0; Aesi < 192 > o04 = iValue0; Aesi < 224 > o05 = iValue0; Aesi < 256 > o06 = iValue0; Aesi < 288 > o07 = iValue0; Aesi < 320 > o08 = iValue0; Aesi < 352 > o09 = iValue0; - Aesi < 384 > o010 = iValue0; Aesi < 416 > o011 = iValue0; Aesi < 448 > o012 = iValue0; Aesi < 480 > o013 = iValue0; Aesi < 512 > o014 = iValue0; Aesi < 544 > o015 = iValue0; Aesi < 576 > o016 = iValue0; Aesi < 608 > o017 = iValue0; Aesi < 640 > o018 = iValue0; - Aesi < 672 > o019 = iValue0; Aesi < 704 > o020 = iValue0; Aesi < 736 > o021 = iValue0; Aesi < 768 > o022 = iValue0; Aesi < 800 > o023 = iValue0; Aesi < 832 > o024 = iValue0; Aesi < 864 > o025 = iValue0; Aesi < 896 > o026 = iValue0; Aesi < 928 > o027 = iValue0; - Aesi < 960 > o028 = iValue0; Aesi < 992 > o029 = iValue0; Aesi < 1024 > o030 = iValue0; Aesi < 1056 > o031 = iValue0; Aesi < 1088 > o032 = iValue0; Aesi < 1120 > o033 = iValue0; Aesi < 1152 > o034 = iValue0; Aesi < 1184 > o035 = iValue0; Aesi < 1216 > o036 = iValue0; - Aesi < 1248 > o037 = iValue0; Aesi < 1280 > o038 = iValue0; Aesi < 1312 > o039 = iValue0; - EXPECT_EQ(o00, iValue0); - EXPECT_EQ(o01, iValue0); EXPECT_EQ(o02, iValue0); EXPECT_EQ(o03, iValue0); EXPECT_EQ(o04, iValue0); EXPECT_EQ(o05, iValue0); EXPECT_EQ(o06, iValue0); EXPECT_EQ(o07, iValue0); EXPECT_EQ(o08, iValue0); EXPECT_EQ(o09, iValue0); - EXPECT_EQ(o010, iValue0); EXPECT_EQ(o011, iValue0); EXPECT_EQ(o012, iValue0); EXPECT_EQ(o013, iValue0); EXPECT_EQ(o014, iValue0); EXPECT_EQ(o015, iValue0); EXPECT_EQ(o016, iValue0); EXPECT_EQ(o017, iValue0); EXPECT_EQ(o018, iValue0); - EXPECT_EQ(o019, iValue0); EXPECT_EQ(o020, iValue0); EXPECT_EQ(o021, iValue0); EXPECT_EQ(o022, iValue0); EXPECT_EQ(o023, iValue0); EXPECT_EQ(o024, iValue0); EXPECT_EQ(o025, iValue0); EXPECT_EQ(o026, iValue0); EXPECT_EQ(o027, iValue0); - EXPECT_EQ(o028, iValue0); EXPECT_EQ(o029, iValue0); EXPECT_EQ(o030, iValue0); EXPECT_EQ(o031, iValue0); EXPECT_EQ(o032, iValue0); EXPECT_EQ(o033, iValue0); EXPECT_EQ(o034, iValue0); EXPECT_EQ(o035, iValue0); EXPECT_EQ(o036, iValue0); - EXPECT_EQ(o037, iValue0); EXPECT_EQ(o038, iValue0); EXPECT_EQ(o039, iValue0); - - long long iValue2 = -380464553884730375; - Aesi < 96 > o20 = iValue2; - Aesi < 96 > o21 = iValue2; Aesi < 128 > o22 = iValue2; Aesi < 160 > o23 = iValue2; Aesi < 192 > o24 = iValue2; Aesi < 224 > o25 = iValue2; Aesi < 256 > o26 = iValue2; Aesi < 288 > o27 = iValue2; Aesi < 320 > o28 = iValue2; Aesi < 352 > o29 = iValue2; - Aesi < 384 > o210 = iValue2; Aesi < 416 > o211 = iValue2; Aesi < 448 > o212 = iValue2; Aesi < 480 > o213 = iValue2; Aesi < 512 > o214 = iValue2; Aesi < 544 > o215 = iValue2; Aesi < 576 > o216 = iValue2; Aesi < 608 > o217 = iValue2; Aesi < 640 > o218 = iValue2; - Aesi < 672 > o219 = iValue2; Aesi < 704 > o220 = iValue2; Aesi < 736 > o221 = iValue2; Aesi < 768 > o222 = iValue2; Aesi < 800 > o223 = iValue2; Aesi < 832 > o224 = iValue2; Aesi < 864 > o225 = iValue2; Aesi < 896 > o226 = iValue2; Aesi < 928 > o227 = iValue2; - Aesi < 960 > o228 = iValue2; Aesi < 992 > o229 = iValue2; Aesi < 1024 > o230 = iValue2; Aesi < 1056 > o231 = iValue2; Aesi < 1088 > o232 = iValue2; Aesi < 1120 > o233 = iValue2; Aesi < 1152 > o234 = iValue2; Aesi < 1184 > o235 = iValue2; Aesi < 1216 > o236 = iValue2; - Aesi < 1248 > o237 = iValue2; Aesi < 1280 > o238 = iValue2; Aesi < 1312 > o239 = iValue2; - EXPECT_EQ(o20, iValue2); - EXPECT_EQ(o21, iValue2); EXPECT_EQ(o22, iValue2); EXPECT_EQ(o23, iValue2); EXPECT_EQ(o24, iValue2); EXPECT_EQ(o25, iValue2); EXPECT_EQ(o26, iValue2); EXPECT_EQ(o27, iValue2); EXPECT_EQ(o28, iValue2); EXPECT_EQ(o29, iValue2); - EXPECT_EQ(o210, iValue2); EXPECT_EQ(o211, iValue2); EXPECT_EQ(o212, iValue2); EXPECT_EQ(o213, iValue2); EXPECT_EQ(o214, iValue2); EXPECT_EQ(o215, iValue2); EXPECT_EQ(o216, iValue2); EXPECT_EQ(o217, iValue2); EXPECT_EQ(o218, iValue2); - EXPECT_EQ(o219, iValue2); EXPECT_EQ(o220, iValue2); EXPECT_EQ(o221, iValue2); EXPECT_EQ(o222, iValue2); EXPECT_EQ(o223, iValue2); EXPECT_EQ(o224, iValue2); EXPECT_EQ(o225, iValue2); EXPECT_EQ(o226, iValue2); EXPECT_EQ(o227, iValue2); - EXPECT_EQ(o228, iValue2); EXPECT_EQ(o229, iValue2); EXPECT_EQ(o230, iValue2); EXPECT_EQ(o231, iValue2); EXPECT_EQ(o232, iValue2); EXPECT_EQ(o233, iValue2); EXPECT_EQ(o234, iValue2); EXPECT_EQ(o235, iValue2); EXPECT_EQ(o236, iValue2); - EXPECT_EQ(o237, iValue2); EXPECT_EQ(o238, iValue2); EXPECT_EQ(o239, iValue2); - - long long iValue4 = -2577490965723039550; - Aesi < 96 > o40 = iValue4; - Aesi < 96 > o41 = iValue4; Aesi < 128 > o42 = iValue4; Aesi < 160 > o43 = iValue4; Aesi < 192 > o44 = iValue4; Aesi < 224 > o45 = iValue4; Aesi < 256 > o46 = iValue4; Aesi < 288 > o47 = iValue4; Aesi < 320 > o48 = iValue4; Aesi < 352 > o49 = iValue4; - Aesi < 384 > o410 = iValue4; Aesi < 416 > o411 = iValue4; Aesi < 448 > o412 = iValue4; Aesi < 480 > o413 = iValue4; Aesi < 512 > o414 = iValue4; Aesi < 544 > o415 = iValue4; Aesi < 576 > o416 = iValue4; Aesi < 608 > o417 = iValue4; Aesi < 640 > o418 = iValue4; - Aesi < 672 > o419 = iValue4; Aesi < 704 > o420 = iValue4; Aesi < 736 > o421 = iValue4; Aesi < 768 > o422 = iValue4; Aesi < 800 > o423 = iValue4; Aesi < 832 > o424 = iValue4; Aesi < 864 > o425 = iValue4; Aesi < 896 > o426 = iValue4; Aesi < 928 > o427 = iValue4; - Aesi < 960 > o428 = iValue4; Aesi < 992 > o429 = iValue4; Aesi < 1024 > o430 = iValue4; Aesi < 1056 > o431 = iValue4; Aesi < 1088 > o432 = iValue4; Aesi < 1120 > o433 = iValue4; Aesi < 1152 > o434 = iValue4; Aesi < 1184 > o435 = iValue4; Aesi < 1216 > o436 = iValue4; - Aesi < 1248 > o437 = iValue4; Aesi < 1280 > o438 = iValue4; Aesi < 1312 > o439 = iValue4; - EXPECT_EQ(o40, iValue4); - EXPECT_EQ(o41, iValue4); EXPECT_EQ(o42, iValue4); EXPECT_EQ(o43, iValue4); EXPECT_EQ(o44, iValue4); EXPECT_EQ(o45, iValue4); EXPECT_EQ(o46, iValue4); EXPECT_EQ(o47, iValue4); EXPECT_EQ(o48, iValue4); EXPECT_EQ(o49, iValue4); - EXPECT_EQ(o410, iValue4); EXPECT_EQ(o411, iValue4); EXPECT_EQ(o412, iValue4); EXPECT_EQ(o413, iValue4); EXPECT_EQ(o414, iValue4); EXPECT_EQ(o415, iValue4); EXPECT_EQ(o416, iValue4); EXPECT_EQ(o417, iValue4); EXPECT_EQ(o418, iValue4); - EXPECT_EQ(o419, iValue4); EXPECT_EQ(o420, iValue4); EXPECT_EQ(o421, iValue4); EXPECT_EQ(o422, iValue4); EXPECT_EQ(o423, iValue4); EXPECT_EQ(o424, iValue4); EXPECT_EQ(o425, iValue4); EXPECT_EQ(o426, iValue4); EXPECT_EQ(o427, iValue4); - EXPECT_EQ(o428, iValue4); EXPECT_EQ(o429, iValue4); EXPECT_EQ(o430, iValue4); EXPECT_EQ(o431, iValue4); EXPECT_EQ(o432, iValue4); EXPECT_EQ(o433, iValue4); EXPECT_EQ(o434, iValue4); EXPECT_EQ(o435, iValue4); EXPECT_EQ(o436, iValue4); - EXPECT_EQ(o437, iValue4); EXPECT_EQ(o438, iValue4); EXPECT_EQ(o439, iValue4); - - long long iValue6 = -7225109388162562138; - Aesi < 96 > o60 = iValue6; - Aesi < 96 > o61 = iValue6; Aesi < 128 > o62 = iValue6; Aesi < 160 > o63 = iValue6; Aesi < 192 > o64 = iValue6; Aesi < 224 > o65 = iValue6; Aesi < 256 > o66 = iValue6; Aesi < 288 > o67 = iValue6; Aesi < 320 > o68 = iValue6; Aesi < 352 > o69 = iValue6; - Aesi < 384 > o610 = iValue6; Aesi < 416 > o611 = iValue6; Aesi < 448 > o612 = iValue6; Aesi < 480 > o613 = iValue6; Aesi < 512 > o614 = iValue6; Aesi < 544 > o615 = iValue6; Aesi < 576 > o616 = iValue6; Aesi < 608 > o617 = iValue6; Aesi < 640 > o618 = iValue6; - Aesi < 672 > o619 = iValue6; Aesi < 704 > o620 = iValue6; Aesi < 736 > o621 = iValue6; Aesi < 768 > o622 = iValue6; Aesi < 800 > o623 = iValue6; Aesi < 832 > o624 = iValue6; Aesi < 864 > o625 = iValue6; Aesi < 896 > o626 = iValue6; Aesi < 928 > o627 = iValue6; - Aesi < 960 > o628 = iValue6; Aesi < 992 > o629 = iValue6; Aesi < 1024 > o630 = iValue6; Aesi < 1056 > o631 = iValue6; Aesi < 1088 > o632 = iValue6; Aesi < 1120 > o633 = iValue6; Aesi < 1152 > o634 = iValue6; Aesi < 1184 > o635 = iValue6; Aesi < 1216 > o636 = iValue6; - Aesi < 1248 > o637 = iValue6; Aesi < 1280 > o638 = iValue6; Aesi < 1312 > o639 = iValue6; - EXPECT_EQ(o60, iValue6); - EXPECT_EQ(o61, iValue6); EXPECT_EQ(o62, iValue6); EXPECT_EQ(o63, iValue6); EXPECT_EQ(o64, iValue6); EXPECT_EQ(o65, iValue6); EXPECT_EQ(o66, iValue6); EXPECT_EQ(o67, iValue6); EXPECT_EQ(o68, iValue6); EXPECT_EQ(o69, iValue6); - EXPECT_EQ(o610, iValue6); EXPECT_EQ(o611, iValue6); EXPECT_EQ(o612, iValue6); EXPECT_EQ(o613, iValue6); EXPECT_EQ(o614, iValue6); EXPECT_EQ(o615, iValue6); EXPECT_EQ(o616, iValue6); EXPECT_EQ(o617, iValue6); EXPECT_EQ(o618, iValue6); - EXPECT_EQ(o619, iValue6); EXPECT_EQ(o620, iValue6); EXPECT_EQ(o621, iValue6); EXPECT_EQ(o622, iValue6); EXPECT_EQ(o623, iValue6); EXPECT_EQ(o624, iValue6); EXPECT_EQ(o625, iValue6); EXPECT_EQ(o626, iValue6); EXPECT_EQ(o627, iValue6); - EXPECT_EQ(o628, iValue6); EXPECT_EQ(o629, iValue6); EXPECT_EQ(o630, iValue6); EXPECT_EQ(o631, iValue6); EXPECT_EQ(o632, iValue6); EXPECT_EQ(o633, iValue6); EXPECT_EQ(o634, iValue6); EXPECT_EQ(o635, iValue6); EXPECT_EQ(o636, iValue6); - EXPECT_EQ(o637, iValue6); EXPECT_EQ(o638, iValue6); EXPECT_EQ(o639, iValue6); - - long long iValue8 = -2599822390419074042; - Aesi < 96 > o80 = iValue8; - Aesi < 96 > o81 = iValue8; Aesi < 128 > o82 = iValue8; Aesi < 160 > o83 = iValue8; Aesi < 192 > o84 = iValue8; Aesi < 224 > o85 = iValue8; Aesi < 256 > o86 = iValue8; Aesi < 288 > o87 = iValue8; Aesi < 320 > o88 = iValue8; Aesi < 352 > o89 = iValue8; - Aesi < 384 > o810 = iValue8; Aesi < 416 > o811 = iValue8; Aesi < 448 > o812 = iValue8; Aesi < 480 > o813 = iValue8; Aesi < 512 > o814 = iValue8; Aesi < 544 > o815 = iValue8; Aesi < 576 > o816 = iValue8; Aesi < 608 > o817 = iValue8; Aesi < 640 > o818 = iValue8; - Aesi < 672 > o819 = iValue8; Aesi < 704 > o820 = iValue8; Aesi < 736 > o821 = iValue8; Aesi < 768 > o822 = iValue8; Aesi < 800 > o823 = iValue8; Aesi < 832 > o824 = iValue8; Aesi < 864 > o825 = iValue8; Aesi < 896 > o826 = iValue8; Aesi < 928 > o827 = iValue8; - Aesi < 960 > o828 = iValue8; Aesi < 992 > o829 = iValue8; Aesi < 1024 > o830 = iValue8; Aesi < 1056 > o831 = iValue8; Aesi < 1088 > o832 = iValue8; Aesi < 1120 > o833 = iValue8; Aesi < 1152 > o834 = iValue8; Aesi < 1184 > o835 = iValue8; Aesi < 1216 > o836 = iValue8; - Aesi < 1248 > o837 = iValue8; Aesi < 1280 > o838 = iValue8; Aesi < 1312 > o839 = iValue8; - EXPECT_EQ(o80, iValue8); - EXPECT_EQ(o81, iValue8); EXPECT_EQ(o82, iValue8); EXPECT_EQ(o83, iValue8); EXPECT_EQ(o84, iValue8); EXPECT_EQ(o85, iValue8); EXPECT_EQ(o86, iValue8); EXPECT_EQ(o87, iValue8); EXPECT_EQ(o88, iValue8); EXPECT_EQ(o89, iValue8); - EXPECT_EQ(o810, iValue8); EXPECT_EQ(o811, iValue8); EXPECT_EQ(o812, iValue8); EXPECT_EQ(o813, iValue8); EXPECT_EQ(o814, iValue8); EXPECT_EQ(o815, iValue8); EXPECT_EQ(o816, iValue8); EXPECT_EQ(o817, iValue8); EXPECT_EQ(o818, iValue8); - EXPECT_EQ(o819, iValue8); EXPECT_EQ(o820, iValue8); EXPECT_EQ(o821, iValue8); EXPECT_EQ(o822, iValue8); EXPECT_EQ(o823, iValue8); EXPECT_EQ(o824, iValue8); EXPECT_EQ(o825, iValue8); EXPECT_EQ(o826, iValue8); EXPECT_EQ(o827, iValue8); - EXPECT_EQ(o828, iValue8); EXPECT_EQ(o829, iValue8); EXPECT_EQ(o830, iValue8); EXPECT_EQ(o831, iValue8); EXPECT_EQ(o832, iValue8); EXPECT_EQ(o833, iValue8); EXPECT_EQ(o834, iValue8); EXPECT_EQ(o835, iValue8); EXPECT_EQ(o836, iValue8); - EXPECT_EQ(o837, iValue8); EXPECT_EQ(o838, iValue8); EXPECT_EQ(o839, iValue8); -} diff --git a/test/operations/binary_io.cpp b/test/operations/binary_io.cpp new file mode 100755 index 0000000..14e7d01 --- /dev/null +++ b/test/operations/binary_io.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include "../../Aeu.h" +#include "../generation.h" + +TEST(Unsigned_BinaryIO, BinaryRead) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (unsigned i = 0; i < testsAmount; i += 2) { + std::array blocks {}; + std::stringstream ss, ss2; ss2 << "0x" << std::hex; + + Aeu a {}; + if(i % 2 == 0) { + for(auto& block: blocks) { + block = Generation::getRandom(); + ss.write(reinterpret_cast(&block), sizeof(block)); + ss2 << std::setw(8) << std::setfill('0') << block; + } + + a.readBinary(ss, true); + } else { + for(auto& block: blocks) { + block = Generation::getRandom(); + ss2 << std::hex << block; + } + + for(long long j = blocks.size() - 1; j >= 0; --j) + ss.write(reinterpret_cast(&blocks[j]), sizeof(uint32_t)); + + a.readBinary(ss, false); + } + + EXPECT_EQ(a, ss2.str()); + } +} + +TEST(Unsigned_BinaryIO, BinaryWrite) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + for (unsigned i = 0; i < testsAmount; ++i) { + std::stringstream ss, ss2; ss << std::hex << "0x"; + for (std::size_t j = 0; j < blocksNumber; ++j) + ss << Generation::getRandom(); + + Aeu l = ss.str(), r {}; + uint32_t temp; + + if(i % 2 == 0) { + l.writeBinary(ss2, false); + for(std::size_t j = 0; j < blocksNumber; ++j) { + ss2.read(reinterpret_cast(&temp), sizeof(uint32_t)); + r.setBlock(j, temp); + } + } else { + l.writeBinary(ss2, true); + for (long long j = blocksNumber - 1; j >= 0; --j) { + ss2.read(reinterpret_cast(&temp), sizeof(uint32_t)); + r.setBlock(j, temp); + } + } + + EXPECT_EQ(l, r); + } +} diff --git a/test/operations/binary_read_write.cpp b/test/operations/binary_read_write.cpp deleted file mode 100644 index cae201d..0000000 --- a/test/operations/binary_read_write.cpp +++ /dev/null @@ -1,428 +0,0 @@ -#include -#include "../../Aesi.h" - -TEST(Binary, BinaryRead) { - { - std::array blocks = { 0b01101011010000101111100000110001, 0b01111010111010010110110010001001, 0b01010100000011010000000110100111, 0b01011000011100010000101000101000, 0b01000001111100100110000011110111, 0b01001001101010011110100000000010, 0b01001001111011001110111011000110, 0b01101000010010110101111111110111, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0110101101000010111110000011000101111010111010010110110010001001010101000000110100000001101001110101100001110001000010100010100001000001111100100110000011110111010010011010100111101000000000100100100111101100111011101100011001101000010010110101111111110111"); - } - { - std::array blocks = { 0b01000001000110101110000011101011, 0b01011011101011001011101000100001, 0b01010100110001111010110101110010, 0b01110111010100011000111000101110, 0b01010111011100101110010100111000, 0b01101101010101001010001011110111, 0b01110100000010111111000001000000, 0b01101000011110010110111110010111, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100000100011010111000001110101101011011101011001011101000100001010101001100011110101101011100100111011101010001100011100010111001010111011100101110010100111000011011010101010010100010111101110111010000001011111100000100000001101000011110010110111110010111"); - } - { - std::array blocks = { 0b01001110100110110100011010001001, 0b01001011001110100001000010111010, 0b01010000011101001110011110111100, 0b01010000111000011100011001010100, 0b01010110100110000110010101001100, 0b01010100111001111111100011110000, 0b01001100001110001000011100100110, 0b01011100011100010110011111001100, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0100111010011011010001101000100101001011001110100001000010111010010100000111010011100111101111000101000011100001110001100101010001010110100110000110010101001100010101001110011111111000111100000100110000111000100001110010011001011100011100010110011111001100"); - } - { - std::array blocks = { 0b01001111111001001011111110101110, 0b01011100110110101110010100001111, 0b01000011110001001001011010001010, 0b01010111110101111101111110011011, 0b01010110001001000100001010100101, 0b01001101100100001100010010000111, 0b01001100001000011001100100001110, 0b01000001001101111000001001011001, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100111111100100101111111010111001011100110110101110010100001111010000111100010010010110100010100101011111010111110111111001101101010110001001000100001010100101010011011001000011000100100001110100110000100001100110010000111001000001001101111000001001011001"); - } - { - std::array blocks = { 0b01110010001110100111110011010100, 0b01100110111111101100110100001101, 0b01011000111010001111001001110111, 0b01110000011011000100000101110101, 0b01101001011101000101010011001100, 0b01111111001011000111110100110101, 0b01101100110100001100001101001000, 0b01011101000011001110011101111101, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0111001000111010011111001101010001100110111111101100110100001101010110001110100011110010011101110111000001101100010000010111010101101001011101000101010011001100011111110010110001111101001101010110110011010000110000110100100001011101000011001110011101111101"); - } - { - std::array blocks = { 0b01001010010101101000011101101010, 0b01101000110100100001010001010111, 0b01011111010100001101011010001001, 0b01000110001011010010100101100111, 0b01011111101100101001110101000101, 0b01000001011000010011110000111000, 0b01100010010111110011100010000010, 0b01100101110001011110111010100100, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100101001010110100001110110101001101000110100100001010001010111010111110101000011010110100010010100011000101101001010010110011101011111101100101001110101000101010000010110000100111100001110000110001001011111001110001000001001100101110001011110111010100100"); - } - { - std::array blocks = { 0b01010000110100000110011001001100, 0b01101001101101011101001101010011, 0b01001011001011011100001001010110, 0b01010010110010110010100100010000, 0b01110000100000011001111100010110, 0b01100000101011110000110001010101, 0b01010000101110001110000010110010, 0b01110110000101001111111100101010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0101000011010000011001100100110001101001101101011101001101010011010010110010110111000010010101100101001011001011001010010001000001110000100000011001111100010110011000001010111100001100010101010101000010111000111000001011001001110110000101001111111100101010"); - } - { - std::array blocks = { 0b01011000000100101011101111111101, 0b01011011010001100001010110011111, 0b01001011110110100100110011001001, 0b01110111110111001010011100111110, 0b01010111000111000101011000111000, 0b01011110111001101100100111001110, 0b01101101001101100010010011011111, 0b01111110111100110000101000110000, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101100000010010101110111111110101011011010001100001010110011111010010111101101001001100110010010111011111011100101001110011111001010111000111000101011000111000010111101110011011001001110011100110110100110110001001001101111101111110111100110000101000110000"); - } - { - std::array blocks = { 0b01111100010100001011010011101000, 0b01010001101001000100001100000011, 0b01011100001111011000010001101100, 0b01100001101111011110110000000001, 0b01110100100010001011100001111010, 0b01101111001101101011100111011010, 0b01011100010100100001100100000110, 0b01100000110100011010110110110011, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0111110001010000101101001110100001010001101001000100001100000011010111000011110110000100011011000110000110111101111011000000000101110100100010001011100001111010011011110011011010111001110110100101110001010010000110010000011001100000110100011010110110110011"); - } - { - std::array blocks = { 0b01010100110011000101100110011110, 0b01110111001101000101110000111101, 0b01001000111111100000101000000011, 0b01010001000010001101100111010010, 0b01001010111100000101110010110110, 0b01111101100110110010001000010111, 0b01110010000001101011111111100111, 0b01000101001001000000010010100111, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101010011001100010110011001111001110111001101000101110000111101010010001111111000001010000000110101000100001000110110011101001001001010111100000101110010110110011111011001101100100010000101110111001000000110101111111110011101000101001001000000010010100111"); - } - { - std::array blocks = { 0b01100011000000110000010011011001, 0b01011000011000100001000000000101, 0b01111010111111010010000011011101, 0b01110001000000000011011011011011, 0b01000111011110011001010111100110, 0b01010110000110001110111001101110, 0b01110101100011111111010000100100, 0b01010101011011100101011100101101, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0110001100000011000001001101100101011000011000100001000000000101011110101111110100100000110111010111000100000000001101101101101101000111011110011001010111100110010101100001100011101110011011100111010110001111111101000010010001010101011011100101011100101101"); - } - { - std::array blocks = { 0b01011111101010111001100111010010, 0b01000111000011011000010010101001, 0b01000001111111001001001000001100, 0b01111111111100110010000000110010, 0b01101110101100101111101110110001, 0b01101000000100110001000101111100, 0b01000100001011001000010001010111, 0b01110000000100111010010001001000, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101111110101011100110011101001001000111000011011000010010101001010000011111110010010010000011000111111111110011001000000011001001101110101100101111101110110001011010000001001100010001011111000100010000101100100001000101011101110000000100111010010001001000"); - } - { - std::array blocks = { 0b01000111000101111000000111010110, 0b01101000100101001100000101110000, 0b01101000011011001001110000011100, 0b01111011011001111101011101011000, 0b01000110110000011000110011011101, 0b01011101110100010010101010111000, 0b01010001000110011001011110010000, 0b01011101100101010000000010110110, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0100011100010111100000011101011001101000100101001100000101110000011010000110110010011100000111000111101101100111110101110101100001000110110000011000110011011101010111011101000100101010101110000101000100011001100101111001000001011101100101010000000010110110"); - } - { - std::array blocks = { 0b01010000111010011000011011011101, 0b01110000100000101001000000111110, 0b01111010011000010011110001111100, 0b01011111110101101110010010001011, 0b01101111101111110011111111111000, 0b01010000000110001110011011000001, 0b01100101110000010000100011001111, 0b01111001011010000111000011110011, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101000011101001100001101101110101110000100000101001000000111110011110100110000100111100011111000101111111010110111001001000101101101111101111110011111111111000010100000001100011100110110000010110010111000001000010001100111101111001011010000111000011110011"); - } - { - std::array blocks = { 0b01100001010100000110100010001100, 0b01100111001101000111010110010001, 0b01010011010101110010001110000011, 0b01001100010001100000011011001111, 0b01000110101101010111001000101001, 0b01011010011011101101000001110010, 0b01000000101001111011111010001000, 0b01011111101010111100111001000111, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0110000101010000011010001000110001100111001101000111010110010001010100110101011100100011100000110100110001000110000001101100111101000110101101010111001000101001010110100110111011010000011100100100000010100111101111101000100001011111101010111100111001000111"); - } - { - std::array blocks = { 0b01010110011001111010010100111111, 0b01001100001010111100010101101110, 0b01010110011101011010011011010011, 0b01110100000101100100111000101111, 0b01101010111110011110101010100101, 0b01000010111111011101101111010111, 0b01101010110110010100111110100001, 0b01001010011100100111001010111011, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101011001100111101001010011111101001100001010111100010101101110010101100111010110100110110100110111010000010110010011100010111101101010111110011110101010100101010000101111110111011011110101110110101011011001010011111010000101001010011100100111001010111011"); - } - { - std::array blocks = { 0b01100110101010000001100101001111, 0b01111110010010010101111111001101, 0b01010010010010001000100010000110, 0b01111001011101000001100110111001, 0b01000101010111010011001110110000, 0b01110001100110110000111000111011, 0b01000111001000011110011111111010, 0b01010101011110000000010111100101, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0110011010101000000110010100111101111110010010010101111111001101010100100100100010001000100001100111100101110100000110011011100101000101010111010011001110110000011100011001101100001110001110110100011100100001111001111111101001010101011110000000010111100101"); - } - { - std::array blocks = { 0b01000101100001100011101001001101, 0b01010111110000110000011001010100, 0b01010011010110001010110001111010, 0b01101010011110010110110111111111, 0b01111000000001111010010101000000, 0b01001101011011010001011101010111, 0b01100010110011110110101100100000, 0b01100100110111000000110010100111, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100010110000110001110100100110101010111110000110000011001010100010100110101100010101100011110100110101001111001011011011111111101111000000001111010010101000000010011010110110100010111010101110110001011001111011010110010000001100100110111000000110010100111"); - } - { - std::array blocks = { 0b01111000101100001000010111110010, 0b01001110100011101001111101000101, 0b01011100111011000001000000101101, 0b01110101111001110101110101111100, 0b01100000110011101101111110001101, 0b01101010111010000000111000111001, 0b01101100000101010010001111000101, 0b01100101101001111001011101010011, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0111100010110000100001011111001001001110100011101001111101000101010111001110110000010000001011010111010111100111010111010111110001100000110011101101111110001101011010101110100000001110001110010110110000010101001000111100010101100101101001111001011101010011"); - } - { - std::array blocks = { 0b01001011111110100111011110110100, 0b01110000111000100000011011011110, 0b01010111101111111110100001000100, 0b01110010100010001110111100011011, 0b01111000011111001011000001100100, 0b01011010010010101110000100011111, 0b01001110011001110100000100101000, 0b01101111000100010111110101111001, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100101111111010011101111011010001110000111000100000011011011110010101111011111111101000010001000111001010001000111011110001101101111000011111001011000001100100010110100100101011100001000111110100111001100111010000010010100001101111000100010111110101111001"); - } - { - std::array blocks = { 0b01011011010011000100110101101011, 0b01011100001111110011001010101100, 0b01001011000101000100001100010100, 0b01010010011101111111110010101100, 0b01100101101011010100011001011010, 0b01100011011000010010111010100011, 0b01111100011111110010010001110001, 0b01111110100110000000101000011001, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0101101101001100010011010110101101011100001111110011001010101100010010110001010001000011000101000101001001110111111111001010110001100101101011010100011001011010011000110110000100101110101000110111110001111111001001000111000101111110100110000000101000011001"); - } - { - std::array blocks = { 0b01110100101011010100010011110111, 0b01000110011101011100011001110110, 0b01001011010000000010001000000100, 0b01111111011100001101100111011111, 0b01001110110101001000001011000101, 0b01000010010000011111010111010000, 0b01001111010101101001010011011100, 0b01000110111001100001111100011001, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0111010010101101010001001111011101000110011101011100011001110110010010110100000000100010000001000111111101110000110110011101111101001110110101001000001011000101010000100100000111110101110100000100111101010110100101001101110001000110111001100001111100011001"); - } - { - std::array blocks = { 0b01010100000001001111001110110011, 0b01110011000011100110110011000111, 0b01111010010110010000110000000100, 0b01001001011101000001110000010010, 0b01111100001111110111000011110111, 0b01001100000100001111010111100100, 0b01011111001111111111100010011111, 0b01011100101000110000111011110100, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0101010000000100111100111011001101110011000011100110110011000111011110100101100100001100000001000100100101110100000111000001001001111100001111110111000011110111010011000001000011110101111001000101111100111111111110001001111101011100101000110000111011110100"); - } - { - std::array blocks = { 0b01010101001111100010110001101000, 0b01101001011010001000001010011111, 0b01001100011100111000010011001001, 0b01000011100111011011101111110100, 0b01011000010111101100100001101000, 0b01000011101110111011101101001011, 0b01110101010010001111000100001000, 0b01101000111011000110110111100100, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101010100111110001011000110100001101001011010001000001010011111010011000111001110000100110010010100001110011101101110111111010001011000010111101100100001101000010000111011101110111011010010110111010101001000111100010000100001101000111011000110110111100100"); - } - { - std::array blocks = { 0b01000010110110100000101100101000, 0b01010101100100011110000000001000, 0b01000010011000101101110111001101, 0b01010010110101000000011111100000, 0b01111110111100111010110110000101, 0b01010000101101110010000010001100, 0b01001100111011000001100011010000, 0b01110001100000010101001011010110, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0100001011011010000010110010100001010101100100011110000000001000010000100110001011011101110011010101001011010100000001111110000001111110111100111010110110000101010100001011011100100000100011000100110011101100000110001101000001110001100000010101001011010110"); - } - { - std::array blocks = { 0b01000010000110110100101100101011, 0b01110001000111001010101110110110, 0b01100100100000111011011101101001, 0b01011010111011010100100011111010, 0b01000100111101110010011110001111, 0b01100001111110011011110011010100, 0b01100011011010000000010110010010, 0b01000101001110001011110011110000, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0100001000011011010010110010101101110001000111001010101110110110011001001000001110110111011010010101101011101101010010001111101001000100111101110010011110001111011000011111100110111100110101000110001101101000000001011001001001000101001110001011110011110000"); - } - { - std::array blocks = { 0b01110010010011111111100100100011, 0b01111011011001100001001000001101, 0b01100111101110010111100000110111, 0b01010100011011101000110011000000, 0b01101100100010111111111111110110, 0b01001011110101101110000100100011, 0b01111011000101101100001001001011, 0b01100110110000010001010100100110, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0111001001001111111110010010001101111011011001100001001000001101011001111011100101111000001101110101010001101110100011001100000001101100100010111111111111110110010010111101011011100001001000110111101100010110110000100100101101100110110000010001010100100110"); - } - { - std::array blocks = { 0b01110100011111001000010100000110, 0b01101001101000011011011011011110, 0b01111010110010001011001111100000, 0b01110001110111011010001000010100, 0b01010010001011101001111010110000, 0b01001101000110001000001001111100, 0b01100000011110000001011100000000, 0b01010100110000010001001001100000, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0111010001111100100001010000011001101001101000011011011011011110011110101100100010110011111000000111000111011101101000100001010001010010001011101001111010110000010011010001100010000010011111000110000001111000000101110000000001010100110000010001001001100000"); - } - { - std::array blocks = { 0b01001011010110001111011010111101, 0b01100010110111000000000011100011, 0b01100111001011001110110100110011, 0b01100101101110001011011011101110, 0b01101110101010001001111010101110, 0b01110011110110101111011110001001, 0b01011101110010011001001110010110, 0b01010110010000010100011010100000, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); - EXPECT_EQ(a, "0b0100101101011000111101101011110101100010110111000000000011100011011001110010110011101101001100110110010110111000101101101110111001101110101010001001111010101110011100111101101011110111100010010101110111001001100100111001011001010110010000010100011010100000"); - } - { - std::array blocks = { 0b01011011011010000011111011000100, 0b01001111011000000001100001101000, 0b01110110100010011101011000111110, 0b01100000100011000010011001100110, 0b01001100011101011001100010110100, 0b01000111111000011100110101000111, 0b01110001110101100000000100010001, 0b01010010100001101010010100110111, }; - std::stringstream ss; for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); - EXPECT_EQ(a, "0b0101101101101000001111101100010001001111011000000001100001101000011101101000100111010110001111100110000010001100001001100110011001001100011101011001100010110100010001111110000111001101010001110111000111010110000000010001000101010010100001101010010100110111"); - } -} - -TEST(Binary, BinaryWrite) { - { - Aesi<256> l = "0b1000101101001010100110101101100111101011111110000110010001000000101101100011101101110111011110101111001101110000011001101110010101001000010000010010001000011111010111111111000000100001110110111001000111000111100000000001100100110011111100110110000000100110", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1010000101000101100011011111111100101010011111110100110101101000100011111000110000010101000101001011101010001111100011000111111110110001010110111111010110110110100111101000001000111100011011001110010011100010110011001011010110111000100111100110011101010100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1001000011101000000001110101111010101110101100110111111101011001010000101110100101000111010011011111001010110000100101001111110011000101011010010011000111011111011011111010111111111011100101110011100010000011101001101001100100001010101101001100111000011101", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0000000101101100100000010010011100010101001110101001010111011101001111100100110000101100011000101001110101101110100111000101001111001001011101001111010100010010001101011101111111100100000101110100000001111000011010011110111101101001011000010011010101011101", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0111000000100011101100110010000101101010101011101010110101101011001001100011110101011111101011000000111110111110100101101101101010101000111110101101110100111011111000100111110101010110110011110010001010100011111010000010000100100111100000001101010110111010", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0110000011101000001111101101010011010100010000011111001000101100100110111101100111101101111001000111001011100100101110110111100001110110111110011100000001111000111111101100010010101100101110001110111011110010011011111001000101100001101101111010101011001011", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1011010101111011100000011110000100010100001010010000101100110010101111010111011011110000111100101000101101111101100001010011101000101011111011001101011100001011011101110010010101110011100100011101111110110110010000101001111110111010100001100011110111011100", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0011101101101000000010000000000100000011010101100110010001101000000001110001101001011011100011101111100100001110100110111101001110000001110110011010001011001101110111010000101001100011101111001001000010000010101011110111111011010101110011010111010111011100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1010101010000111110100000110100100010101011101111111111011100111101101100100101110010010101111011010011001110110100001111010001001111001111001000001011110100011101010110010100001011101100101100000100100111001011011010000010011111001000000001011001111100010", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101010000010001110101011100011001001001110110100101011001011111010101000011011101111100011011010111001011111010111111111111110011110011111000100011001111101011100010010011100011011100111010111100011001000101100110011111001101101010010000111111111110111100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0110101111101100111111011100100011111001110111101000110111101110000110000110011011011111111111001001111001010010001011100101111001111001100110010000000011011111011000111001000001010110000101010001000101011011101110001111001101101101000111111011011111000010", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101000010011101001011001010001110110101001011000001110100101000101010110101001101011101101011110111101001000000000000101110100110101110101111010111101010001011100101010011100101011110101111110000011000001011000010101000100000000000011001001010100001010110", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0010010001111010010011001101101000110000010001011110100000000110100011111010000011101100001100011110111011011000000011011100010101000010001100110011001010010100001011110000110101001111111000001101001110000101110101100110010110110000101010100000110110011000", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0110100000001001010110101010001110111111110100100111000110011000100111101101011001010001000101111101101001010110110000011101000010000110101000011000101111000001111111000111101100000010101011101010111011001000100101010010111101011011010100011001110110111111", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1001110011010010001110001010011010111000110001011110111010011011110101101100110101010110010001001001110010100100000001001011011111111011000001101101101101011010110100011011010010101011000011011010010100011000110000000010111000111000110110000101111010111011", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0111110000100101001011010111111011001101111010111100011100011011111010011001000111000101111001101010011010010010101011010111010100011110111011110001001001000101110100001100110110111101101001010000111011111101110100010110101101101100100011010011000110000001", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1111001010011101001000110000110110110110110001010100101010110011010111101000111100000001011111000100001101111011100111010000100100101001110101111111100111111100010111100001101001101110101010000100011111111001001010111101111100000101100011011111110101100110", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101110100000101111010101000010010100100001010111110011000010010110110011001101100110010101111011011011011110011010110001100111001001110001011101000111111011110111010100000001010100101100100010011100010011011100010111001000011110100101100011011111000111110", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0011011000100010010010111010100000000010111110111110000000101100101010111101010110010000111011111000110000100011110001110100010110111111010001010001110100000000110001000110101010001011000011111011011110011100101110110101101010010111100010101101101011100010", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101100110010000110101001100100101011001101010110100000111100001111001100011011100110000001111111110111001110001101101001011001000111111110000000110110111100110101101010101101010111110011010010100010001010101101000101101000011100110110000010000110110000100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101111011110001111000110001010001101000110000111101001000101010110001110000101100011001101010111100100000010110000010001110000101101101101100111001101011101101111011101000101111000011101001100011110001110010110011001011001111010011000110101111111110101011", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0101010001111111000100010110110011010100111100010101100010101100011001001010010000110000110101011100010011010010000110010001001001110111011100111111110100011111001101000011010101000001110000000111100100001011111100011100101101001001101101101110011010100011", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1010111101101111110011110010100010111100010101100101101001001010111000100100110000011101111011111001110101000100000101101000101110010111111111001011100011011101110000011011101010000001001001111111000000011110101011111100000101000010101101100010110111001111", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0000111110101001101010111111001100011110110010111111110101100110100011010001110111011010100011000101001001010111111110011010001001000110101000010011011001111011100010111110110100000000100011101001110111001101001110000100010001000111011111011000010100111010", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0010110110110100011011010000110100010000011101001011110110110010001111111011000010100101101001110101011111001001001101000001011111001000111101011111101011101110010000001001000111111010010000101111100000011011100100111010011001100000100100111010111110100101", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1000001010001011100011101110100100100111010111101111000001010100101001101010001010110011001111111000011111010101110000011010111100011111001001111100000010110011110111010001001011101111011100011011110101110101001101111101101011100011001111101101111011100100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0100010011101000000110100100100100111110011110000000101111101000011101010010110111110001001010000110010110010011010101000101000000000001001011101010001010111010100100001100000101111110111100000101111000011111011101111011100100111000000000011101111000000000", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1110110110011000001110011101101010000110010100111010101101001111010011011110101100000111101100110000010001011110101011111100111110101100010101011011111010101011010001001000001011101110010001110010101111011100110000001111011001110101011011101011011111011100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b1100001110010001100001000001011001111011111100011101110001010010110000101111111010100011111011111011000101011110110111101101110011010100011110011111011000101001111100011111111101101111110100110110011001011111110011110000010000100001000011110001011101101001", r {}; - std::stringstream ss; l.writeBinary(ss, false); unsigned temp {}; - for(unsigned i = 0; i < 8; ++i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } - { - Aesi<256> l = "0b0111111111010011100110101111111011111110111011100101001000010100010101111110011001111110111110111100100010110001111001110100101101000001111010011110001001111111011101111101010101101010000001010001001101110100100101110110000101101000101000111111101101000100", r {}; - std::stringstream ss; l.writeBinary(ss, true); unsigned temp {}; - for(long long i = 7; i >= 0; --i) { - ss.read(reinterpret_cast(&temp), sizeof(unsigned)); - r.setBlock(i, temp); - } - EXPECT_EQ(l, r); - } -} \ No newline at end of file diff --git a/test/operations/casts/integral_cast.cpp b/test/operations/casts/integral_cast.cpp new file mode 100755 index 0000000..5750a86 --- /dev/null +++ b/test/operations/casts/integral_cast.cpp @@ -0,0 +1,41 @@ +#include +#include +#include "../../../Aeu.h" +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_IntegralCast, IntegralCast) { + constexpr auto testsAmount = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto value = Generation::getRandom(); + Aesi<128> aesi = value; + EXPECT_EQ(aesi.integralCast(), value); + + value = Generation::getRandom(); + aesi = value; + EXPECT_EQ(aesi.integralCast(), value); + } +} + +TEST(Unsigned_IntegralCast, IntegralCast) { + constexpr auto testsAmount = 2048; + for (std::size_t i = 0; i < testsAmount; ++i) { + auto value = Generation::getRandom(); + Aeu<128> aeu = value; + EXPECT_EQ(aeu.integralCast(), value); + + value = Generation::getRandom(); + aeu = value; + EXPECT_EQ(aeu.integralCast(), value); + } + + constexpr auto blocksNumber = 16; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto baseValue = Generation::getRandom(); + std::stringstream ss; ss << "0x" << std::hex << Generation::getRandomWithBits(blocksNumber * 32 - 96) + << std::setw(16) << std::setfill('0') << baseValue; + const auto& ref = ss.str(); + Aeu aeu = ss.str(); + EXPECT_EQ(aeu.integralCast(), baseValue); + } +} \ No newline at end of file diff --git a/test/operations/casts/precision_cast.cpp b/test/operations/casts/precision_cast.cpp new file mode 100755 index 0000000..c3dc672 --- /dev/null +++ b/test/operations/casts/precision_cast.cpp @@ -0,0 +1,183 @@ +#include +#include "../../../Aeu.h" +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_PrecisionCast, PrecisionCast) { + constexpr auto testsAmount = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto init0 = (i % 2 == 0 ? 1 : -1) + * Generation::getRandomWithBits(250); + const Aesi<256> aesi = init0; + EXPECT_EQ(aesi.precisionCast<288>(), init0); + EXPECT_EQ(aesi.precisionCast<320>(), init0); + EXPECT_EQ(aesi.precisionCast<352>(), init0); + EXPECT_EQ(aesi.precisionCast<384>(), init0); + EXPECT_EQ(aesi.precisionCast<416>(), init0); + EXPECT_EQ(aesi.precisionCast<448>(), init0); + EXPECT_EQ(aesi.precisionCast<480>(), init0); + EXPECT_EQ(aesi.precisionCast<512>(), init0); + EXPECT_EQ(aesi.precisionCast<544>(), init0); + EXPECT_EQ(aesi.precisionCast<576>(), init0); + EXPECT_EQ(aesi.precisionCast<608>(), init0); + EXPECT_EQ(aesi.precisionCast<640>(), init0); + EXPECT_EQ(aesi.precisionCast<672>(), init0); + EXPECT_EQ(aesi.precisionCast<704>(), init0); + EXPECT_EQ(aesi.precisionCast<736>(), init0); + EXPECT_EQ(aesi.precisionCast<768>(), init0); + EXPECT_EQ(aesi.precisionCast<800>(), init0); + EXPECT_EQ(aesi.precisionCast<832>(), init0); + EXPECT_EQ(aesi.precisionCast<864>(), init0); + EXPECT_EQ(aesi.precisionCast<896>(), init0); + } + + Aesi < 448 > l0 = "554241380131154142962417280417998404754929828012346097179687246704910303315350311367744175378443304128036758983824324734859979768793199."; + EXPECT_EQ(l0.precisionCast<288>(), "408360527252105534419027813905394704348416525449517229626145092686873334890812834908271."); + Aesi < 576 > l1 = "-173149006578507408541558843749803097456182801623666290320265239338181642132588175569300761116459015677654013937947922994294373883893325690805618652779686048163576445320646483."; + EXPECT_EQ(l1.precisionCast<128>(), "-210443040993062611785785420324814540627."); + Aesi < 576 > l2 = "66531456573720529442216757952933331047332848598711407403162907502778746277356003198417676048381460115126892609965612607567352416913344652080416627158294298245466839069775512."; + EXPECT_EQ(l2.precisionCast<160>(), "1443229828299692348357792670919834022979176257176."); + Aesi < 384 > l3 = "-1098897099174270538478178379535802020226067483295913532002005072123857444388599717512365115154922424475266850503120."; + EXPECT_EQ(l3.precisionCast<320>(), "-1913199418936122088346837076981965348887692948209008066197015782466463820230886895375591805565392."); + Aesi < 512 > l4 = "3069476797928086052610870903467024437789501028462434594919744663711449127505497769599003817092647117494652657649787519339440892062605145266124294683385280."; + EXPECT_EQ(l4.precisionCast<288>(), "404126981474586070624526050760237057921124714973395197115667617772232279058850682265024."); + Aesi < 352 > l5 = "-2948016904402708200913240914482790524802448562129494737510300849124666954825609112501202095235581771983067."; + EXPECT_EQ(l5.precisionCast<192>(), "-1120442763073472009948111228858560283233140945287272409307."); + Aesi < 544 > l6 = "10812628969630480520296504856105212223514943626905130339806055726389997460671652738109321632680730144583156832174036283780045422846847056560092948355830105461452561."; + EXPECT_EQ(l6.precisionCast<128>(), "330342928733391374787712324367724277521."); + Aesi < 544 > l7 = "-4112600136041780850943347403651201772866193144792995503451651200434798923608930918174270859878921981299563448120913143826254282006786082095303150341646975970259785."; + EXPECT_EQ(l7.precisionCast<288>(), "-257304491601243764544329915240262128843475594535859368626521507218543067528530890011465."); + Aesi < 384 > l8 = "28048835949300858284373720359733481364253247860667645736041649560388756406925265368724245525050388699493492127215396."; + EXPECT_EQ(l8.precisionCast<256>(), "41878091393227431195219434526290235492405672892345774495477168807404321681188."); + Aesi < 640 > l9 = "-3848583613533234298953998803964435640019755235139553979562211441430877304606643444685829881598731682613890268054287149783980908651187506403654762887423297734191981318623098337988025363561114940."; + EXPECT_EQ(l9.precisionCast<160>(), "-541300877713023860093328693961789219540436446524."); + Aesi < 512 > l10 = "8488462826013523989070679682331534259557436274695014765129319667636222109541019846966725069632607848463488852770772093964627525568328843684570072600088832."; + EXPECT_EQ(l10.precisionCast<160>(), "523538838524052847229876918926034085392282358016."); + Aesi < 576 > l11 = "-11236969385546154746878679488297868602806916111627187642798923353498840149284473359875405738278850824908974037092662116610981773121895588572197349961886691945064651776229050."; + EXPECT_EQ(l11.precisionCast<128>(), "-29179789164106523943541955618292268730."); + Aesi < 480 > l12 = "924082864945322453283057577897421592990774691137290429034141806501722486590884960785337810624006801980116699350354269354398363040536296529326681."; + EXPECT_EQ(l12.precisionCast<256>(), "15790246827509817793328866413084671789409373095293932456575888129892184748633."); + Aesi < 512 > l13 = "-9607535504179656540242447115527397529604623905521687360978734063119313561780639573012578165648934865049773849480530263572594554247909207343890208529325178."; + EXPECT_EQ(l13.precisionCast<96>(), "-43716316362024562473758891130."); + Aesi < 352 > l14 = "504397667162110386921588331778312416154169943905827797809093816111203720055808585599403524127547394508185."; + EXPECT_EQ(l14.precisionCast<320>(), "366270022681278488140630850294606110994384776947473041868263123438838372271196545770306825766297."); + Aesi < 544 > l15 = "-27608764507031531319380382106462863564782632077695501707054751614193288192180423340509534352068491112085645377731761780973224450169988873068318780343686563718281728."; + EXPECT_EQ(l15.precisionCast<128>(), "-299026899257808842617251361117814438400."); + Aesi < 352 > l16 = "1978129624964056450214026876059300487877996643140932950061364608660420356925042564405231900323677600676732."; + EXPECT_EQ(l16.precisionCast<320>(), "365332643823514689801663993143371567677009732484894048068501453581388238598858847283260927441788."); + Aesi < 576 > l17 = "-195265355728943716865923619155375969530111891393015085388776834717930166073822658430177349287072569812662023940174467801397134386843815407817766067594355521616265929622366898."; + EXPECT_EQ(l17.precisionCast<160>(), "-221431119546753700832094394260270558954283936434."); + Aesi < 448 > l18 = "414657978233561248876686250413054606900177295904410399578041220021615424324810017863916222257119299661647319122459751028412186388057654."; + EXPECT_EQ(l18.precisionCast<160>(), "287129154900729631574915186396319442248636812854."); + Aesi < 416 > l19 = "-56687510612260333551549640577823250078355837097233108084669493198465659199087411861462621495608437125573216962137258061197924."; + EXPECT_EQ(l19.precisionCast<192>(), "-3671611332121323818239920054049877596259686932276771811940."); + Aesi < 640 > l20 = "1546223449542899971558886608789690118697134740086024592798235620930020323290348765670723997823619247765209481873838363731256837657816604584457400460176692587426042570895554473755247436115230189."; + EXPECT_EQ(l20.precisionCast<320>(), "1705058499460706178048346990812902342294295809567394699482134087317553182108908996873089872575981."); + Aesi < 544 > l21 = "-174065680196633578590894771435895688468079098486287540664921962829963159709119456409138894766839898574579608494679948491219544731370758383681896937747086278361071."; + EXPECT_EQ(l21.precisionCast<160>(), "-220794710368648048438000780675654519053309411311."); + Aesi < 448 > l22 = "136337341513559528961653942676228706381771186833849367631461720301064785651836843206251270469997623786977461200400063656318366284038665."; + EXPECT_EQ(l22.precisionCast<224>(), "816945909177209805889026909383334983853515920833335341477807047177."); + Aesi < 352 > l23 = "-5882616107094423670384170997721509360066167036113934904312412848395219509023523677500755059444938780072409."; + EXPECT_EQ(l23.precisionCast<192>(), "-2482927072274059692659564052439247617034525043020273441241."); + Aesi < 576 > l24 = "49857691326617957339080952718292050690932576020199908481126156219200801064319573633766216649464944745473827870799580369859357610319478396095070633417622983092014069297900742."; + EXPECT_EQ(l24.precisionCast<96>(), "20676605872175966156536081606."); + Aesi < 384 > l25 = "-28597517267806223597843711502305823530466336309097073757475161768363138442370308787956725565043616828782360287501138."; + EXPECT_EQ(l25.precisionCast<192>(), "-2349989946988515365971908154524797542461532293278087240530."); + Aesi < 352 > l26 = "5359709770582948688991943818180669926832250789635927200530270394005210447928718134456374737387522683948933."; + EXPECT_EQ(l26.precisionCast<96>(), "30780870628112076616018546565."); + Aesi < 608 > l27 = "-800374186897442994345991532287383427669343624463618411247954314190792985454915883373717659254388118542800958906763592267710368929085300529376043722066941548681087911311229845689540460."; + EXPECT_EQ(l27.precisionCast<128>(), "-2854867648611582803837292073272156012."); + Aesi < 384 > l28 = "33405800918446002208040817593884350731087014451427547055891417316377644807769010652297688512536252488106030729965818."; + EXPECT_EQ(l28.precisionCast<224>(), "459273051701248468242064512442751256897801283813240021045830922490."); + Aesi < 448 > l29 = "-545136889659423149046640496483142589267039543174772529930583944491083582156213563276447863450923726927200116011820859957964687342869311."; + EXPECT_EQ(l29.precisionCast<224>(), "-11564578527812652389272649650310409698199102565460528063263161490239."); +} + +TEST(Unsigned_PrecisionCast, PrecisionCast) { + constexpr auto testsAmount = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto init0 = Generation::getRandomWithBits(250); + const Aeu<256> aeu = init0; + EXPECT_EQ(aeu.precisionCast<288>(), init0); + EXPECT_EQ(aeu.precisionCast<320>(), init0); + EXPECT_EQ(aeu.precisionCast<352>(), init0); + EXPECT_EQ(aeu.precisionCast<384>(), init0); + EXPECT_EQ(aeu.precisionCast<416>(), init0); + EXPECT_EQ(aeu.precisionCast<448>(), init0); + EXPECT_EQ(aeu.precisionCast<480>(), init0); + EXPECT_EQ(aeu.precisionCast<512>(), init0); + EXPECT_EQ(aeu.precisionCast<544>(), init0); + EXPECT_EQ(aeu.precisionCast<576>(), init0); + EXPECT_EQ(aeu.precisionCast<608>(), init0); + EXPECT_EQ(aeu.precisionCast<640>(), init0); + EXPECT_EQ(aeu.precisionCast<672>(), init0); + EXPECT_EQ(aeu.precisionCast<704>(), init0); + EXPECT_EQ(aeu.precisionCast<736>(), init0); + EXPECT_EQ(aeu.precisionCast<768>(), init0); + EXPECT_EQ(aeu.precisionCast<800>(), init0); + EXPECT_EQ(aeu.precisionCast<832>(), init0); + EXPECT_EQ(aeu.precisionCast<864>(), init0); + EXPECT_EQ(aeu.precisionCast<896>(), init0); + } + + Aeu < 448 > l0 = "554241380131154142962417280417998404754929828012346097179687246704910303315350311367744175378443304128036758983824324734859979768793199."; + EXPECT_EQ(l0.precisionCast<288>(), "408360527252105534419027813905394704348416525449517229626145092686873334890812834908271."); + Aeu < 576 > l1 = "173149006578507408541558843749803097456182801623666290320265239338181642132588175569300761116459015677654013937947922994294373883893325690805618652779686048163576445320646483."; + EXPECT_EQ(l1.precisionCast<128>(), "210443040993062611785785420324814540627."); + Aeu < 576 > l2 = "66531456573720529442216757952933331047332848598711407403162907502778746277356003198417676048381460115126892609965612607567352416913344652080416627158294298245466839069775512."; + EXPECT_EQ(l2.precisionCast<160>(), "1443229828299692348357792670919834022979176257176."); + Aeu < 384 > l3 = "1098897099174270538478178379535802020226067483295913532002005072123857444388599717512365115154922424475266850503120."; + EXPECT_EQ(l3.precisionCast<320>(), "1913199418936122088346837076981965348887692948209008066197015782466463820230886895375591805565392."); + Aeu < 512 > l4 = "3069476797928086052610870903467024437789501028462434594919744663711449127505497769599003817092647117494652657649787519339440892062605145266124294683385280."; + EXPECT_EQ(l4.precisionCast<288>(), "404126981474586070624526050760237057921124714973395197115667617772232279058850682265024."); + Aeu < 352 > l5 = "2948016904402708200913240914482790524802448562129494737510300849124666954825609112501202095235581771983067."; + EXPECT_EQ(l5.precisionCast<192>(), "1120442763073472009948111228858560283233140945287272409307."); + Aeu < 544 > l6 = "10812628969630480520296504856105212223514943626905130339806055726389997460671652738109321632680730144583156832174036283780045422846847056560092948355830105461452561."; + EXPECT_EQ(l6.precisionCast<128>(), "330342928733391374787712324367724277521."); + Aeu < 544 > l7 = "4112600136041780850943347403651201772866193144792995503451651200434798923608930918174270859878921981299563448120913143826254282006786082095303150341646975970259785."; + EXPECT_EQ(l7.precisionCast<288>(), "257304491601243764544329915240262128843475594535859368626521507218543067528530890011465."); + Aeu < 384 > l8 = "28048835949300858284373720359733481364253247860667645736041649560388756406925265368724245525050388699493492127215396."; + EXPECT_EQ(l8.precisionCast<256>(), "41878091393227431195219434526290235492405672892345774495477168807404321681188."); + Aeu < 640 > l9 = "3848583613533234298953998803964435640019755235139553979562211441430877304606643444685829881598731682613890268054287149783980908651187506403654762887423297734191981318623098337988025363561114940."; + EXPECT_EQ(l9.precisionCast<160>(), "541300877713023860093328693961789219540436446524."); + Aeu < 512 > l10 = "8488462826013523989070679682331534259557436274695014765129319667636222109541019846966725069632607848463488852770772093964627525568328843684570072600088832."; + EXPECT_EQ(l10.precisionCast<160>(), "523538838524052847229876918926034085392282358016."); + Aeu < 576 > l11 = "11236969385546154746878679488297868602806916111627187642798923353498840149284473359875405738278850824908974037092662116610981773121895588572197349961886691945064651776229050."; + EXPECT_EQ(l11.precisionCast<128>(), "29179789164106523943541955618292268730."); + Aeu < 480 > l12 = "924082864945322453283057577897421592990774691137290429034141806501722486590884960785337810624006801980116699350354269354398363040536296529326681."; + EXPECT_EQ(l12.precisionCast<256>(), "15790246827509817793328866413084671789409373095293932456575888129892184748633."); + Aeu < 512 > l13 = "9607535504179656540242447115527397529604623905521687360978734063119313561780639573012578165648934865049773849480530263572594554247909207343890208529325178."; + EXPECT_EQ(l13.precisionCast<96>(), "43716316362024562473758891130."); + Aeu < 352 > l14 = "504397667162110386921588331778312416154169943905827797809093816111203720055808585599403524127547394508185."; + EXPECT_EQ(l14.precisionCast<320>(), "366270022681278488140630850294606110994384776947473041868263123438838372271196545770306825766297."); + Aeu < 544 > l15 = "27608764507031531319380382106462863564782632077695501707054751614193288192180423340509534352068491112085645377731761780973224450169988873068318780343686563718281728."; + EXPECT_EQ(l15.precisionCast<128>(), "299026899257808842617251361117814438400."); + Aeu < 352 > l16 = "1978129624964056450214026876059300487877996643140932950061364608660420356925042564405231900323677600676732."; + EXPECT_EQ(l16.precisionCast<320>(), "365332643823514689801663993143371567677009732484894048068501453581388238598858847283260927441788."); + Aeu < 576 > l17 = "195265355728943716865923619155375969530111891393015085388776834717930166073822658430177349287072569812662023940174467801397134386843815407817766067594355521616265929622366898."; + EXPECT_EQ(l17.precisionCast<160>(), "221431119546753700832094394260270558954283936434."); + Aeu < 448 > l18 = "414657978233561248876686250413054606900177295904410399578041220021615424324810017863916222257119299661647319122459751028412186388057654."; + EXPECT_EQ(l18.precisionCast<160>(), "287129154900729631574915186396319442248636812854."); + Aeu < 416 > l19 = "56687510612260333551549640577823250078355837097233108084669493198465659199087411861462621495608437125573216962137258061197924."; + EXPECT_EQ(l19.precisionCast<192>(), "3671611332121323818239920054049877596259686932276771811940."); + Aeu < 640 > l20 = "1546223449542899971558886608789690118697134740086024592798235620930020323290348765670723997823619247765209481873838363731256837657816604584457400460176692587426042570895554473755247436115230189."; + EXPECT_EQ(l20.precisionCast<320>(), "1705058499460706178048346990812902342294295809567394699482134087317553182108908996873089872575981."); + Aeu < 544 > l21 = "174065680196633578590894771435895688468079098486287540664921962829963159709119456409138894766839898574579608494679948491219544731370758383681896937747086278361071."; + EXPECT_EQ(l21.precisionCast<160>(), "220794710368648048438000780675654519053309411311."); + Aeu < 448 > l22 = "136337341513559528961653942676228706381771186833849367631461720301064785651836843206251270469997623786977461200400063656318366284038665."; + EXPECT_EQ(l22.precisionCast<224>(), "816945909177209805889026909383334983853515920833335341477807047177."); + Aeu < 352 > l23 = "5882616107094423670384170997721509360066167036113934904312412848395219509023523677500755059444938780072409."; + EXPECT_EQ(l23.precisionCast<192>(), "2482927072274059692659564052439247617034525043020273441241."); + Aeu < 576 > l24 = "49857691326617957339080952718292050690932576020199908481126156219200801064319573633766216649464944745473827870799580369859357610319478396095070633417622983092014069297900742."; + EXPECT_EQ(l24.precisionCast<96>(), "20676605872175966156536081606."); + Aeu < 384 > l25 = "28597517267806223597843711502305823530466336309097073757475161768363138442370308787956725565043616828782360287501138."; + EXPECT_EQ(l25.precisionCast<192>(), "2349989946988515365971908154524797542461532293278087240530."); + Aeu < 352 > l26 = "5359709770582948688991943818180669926832250789635927200530270394005210447928718134456374737387522683948933."; + EXPECT_EQ(l26.precisionCast<96>(), "30780870628112076616018546565."); + Aeu < 608 > l27 = "800374186897442994345991532287383427669343624463618411247954314190792985454915883373717659254388118542800958906763592267710368929085300529376043722066941548681087911311229845689540460."; + EXPECT_EQ(l27.precisionCast<128>(), "2854867648611582803837292073272156012."); + Aeu < 384 > l28 = "33405800918446002208040817593884350731087014451427547055891417316377644807769010652297688512536252488106030729965818."; + EXPECT_EQ(l28.precisionCast<224>(), "459273051701248468242064512442751256897801283813240021045830922490."); + Aeu < 448 > l29 = "545136889659423149046640496483142589267039543174772529930583944491083582156213563276447863450923726927200116011820859957964687342869311."; + EXPECT_EQ(l29.precisionCast<224>(), "11564578527812652389272649650310409698199102565460528063263161490239."); +} \ No newline at end of file diff --git a/test/operations/display.cpp b/test/operations/display.cpp deleted file mode 100644 index 8dc5850..0000000 --- a/test/operations/display.cpp +++ /dev/null @@ -1,1124 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Display, Zero) { - Aesi512 m = 0; - - std::stringstream ss1 {}; - ss1 << m << -m << +m; - EXPECT_EQ(ss1.str(), "000"); - - std::stringstream ss2 {}; - ss2 << std::dec << m << std::dec << -m << std::dec << +m; - EXPECT_EQ(ss2.str(), "000"); - - std::stringstream ss3 {}; - ss3 << std::oct << m << std::oct << -m << std::oct << +m; - EXPECT_EQ(ss3.str(), "000"); - - std::stringstream ss4 {}; - ss4 << std::hex << m << std::hex << -m << std::hex << +m; - EXPECT_EQ(ss4.str(), "000"); - - std::stringstream ss5 {}; - m = 8; ss5 << m - 8 << -(m - 8) << +(m - 8); m -= 8; ss5 << m; - EXPECT_EQ(ss5.str(), "0000"); - - m = 0; - - using namespace std::string_view_literals; - - std::array askii {}; std::array utf {}; - auto size = m.getString<10>(askii.data(), 10); - EXPECT_EQ(std::string_view(askii.data()), "0"sv); - - askii = {}; size = m.getString<2>(askii.data(), 10, true); - EXPECT_EQ(std::string_view(askii.data()), "0b0"sv); - - askii = {}; size = m.getString<8>(askii.data(), 10, true); - EXPECT_EQ(std::string_view(askii.data()), "0o0"sv); - - askii = {}; size = m.getString<10>(askii.data(), 10, true); - EXPECT_EQ(std::string_view(askii.data()), "0"sv); - - askii = {}; size = m.getString<16>(askii.data(), 10, true); - EXPECT_EQ(std::string_view(askii.data()), "0x0"sv); - - size = m.getString<10>(utf.data(), 10); - EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); - - utf = {}; size = m.getString<2>(utf.data(), 10, true); - EXPECT_EQ(std::wstring_view(utf.data()), L"0b0"sv); - - utf = {}; size = m.getString<8>(utf.data(), 10, true); - EXPECT_EQ(std::wstring_view(utf.data()), L"0o0"sv); - - utf = {}; size = m.getString<10>(utf.data(), 10, true); - EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); - - utf = {}; size = m.getString<16>(utf.data(), 10, true); - EXPECT_EQ(std::wstring_view(utf.data()), L"0x0"sv); -} - -TEST(Display, DecimalStreams) { - { - Aesi512 m = "3271537937952190727058303882939001682991485886660040621506851717722137348853708101505329832588589230564011373848988489701250656685742214910399593451197376"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"3271537937952190727058303882939001682991485886660040621506851717722137348853708101505329832588589230564011373848988489701250656685742214910399593451197376"); - } - { - Aesi512 m = "10161723669171452222000007748918269693118515439299808075503361511356344589859770626810918593274405750483635029415344351903581211163404559190173787374875455"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"10161723669171452222000007748918269693118515439299808075503361511356344589859770626810918593274405750483635029415344351903581211163404559190173787374875455"); - } - { - Aesi512 m = L"8741176259144359000371094435030657530751145080896776690249945688668668606043324129113835674961525494312424066621772014753848601964262666188537281951488268"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "8741176259144359000371094435030657530751145080896776690249945688668668606043324129113835674961525494312424066621772014753848601964262666188537281951488268"); - } - { - Aesi512 m = L"2476460314461586629575107324439043124391300860871223957320886057124946630034631559060105175232731249992286305226317575769757671411712549575988114217837840"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "2476460314461586629575107324439043124391300860871223957320886057124946630034631559060105175232731249992286305226317575769757671411712549575988114217837840"); - } - { - Aesi512 m = "4781982545621581771656267324086448912685764826130013219576836751834529668036384329680406472187202510466043863583283393776902932687113636880789116722205437"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"4781982545621581771656267324086448912685764826130013219576836751834529668036384329680406472187202510466043863583283393776902932687113636880789116722205437"); - } - { - Aesi512 m = L"4215929624968026126833080588221373377181481977576545344471711174221023975573222791649843123097809414811659045100518232654416848159566975204491379847497288"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "4215929624968026126833080588221373377181481977576545344471711174221023975573222791649843123097809414811659045100518232654416848159566975204491379847497288"); - } - { - Aesi512 m = L"3789622105882330331562968188093794280727764249594599049862601589891993015130310260657788864590982646929671969241541514085894596750773949199330318615033992"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "3789622105882330331562968188093794280727764249594599049862601589891993015130310260657788864590982646929671969241541514085894596750773949199330318615033992"); - } - { - Aesi512 m = "3287265758065731368496386069027482805446989998500337902520144254571521136235920668644342473774899057180430243320021873882877630168365337776091887733489565"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"3287265758065731368496386069027482805446989998500337902520144254571521136235920668644342473774899057180430243320021873882877630168365337776091887733489565"); - } - { - Aesi512 m = L"8462118861872489789539682218942901112173305781597361683650534817281075802312215674761651099862961633692221691811005729561525176656327172211709683243921954"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "8462118861872489789539682218942901112173305781597361683650534817281075802312215674761651099862961633692221691811005729561525176656327172211709683243921954"); - } - { - Aesi512 m = L"12516267612019926550846095184896951434050459889368717573641955952598567110316985736396291212737972719014325471791384190279696168653879048566033085997906979"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "12516267612019926550846095184896951434050459889368717573641955952598567110316985736396291212737972719014325471791384190279696168653879048566033085997906979"); - } - { - Aesi512 m = "8608341916183000555420476269879876990744564494389510404003835599903021450191235057986892462103731216746923783583417472333241933828998776788021426271709989"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"8608341916183000555420476269879876990744564494389510404003835599903021450191235057986892462103731216746923783583417472333241933828998776788021426271709989"); - } - { - Aesi512 m = L"13130773441903925185480199473032528994089863047173425990129392609029597113686852739606221213457070186958009540566045922307185922431962885223109519097977553"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "13130773441903925185480199473032528994089863047173425990129392609029597113686852739606221213457070186958009540566045922307185922431962885223109519097977553"); - } - { - Aesi512 m = L"11900150955068297355712037037387726884754397450909803123546177173290479558589648848025700730715062614557573709532289385316763672403178581142806171784726008"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "11900150955068297355712037037387726884754397450909803123546177173290479558589648848025700730715062614557573709532289385316763672403178581142806171784726008"); - } - { - Aesi512 m = L"9670154667602123298474681634627428100851189193794686295905214804348571363111668074701082337190989787080233636696801494459183810458065556134845985561718669"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "9670154667602123298474681634627428100851189193794686295905214804348571363111668074701082337190989787080233636696801494459183810458065556134845985561718669"); - } - { - Aesi512 m = "11044611828110471959879077895562685079922058649080805282439608029356151621007076572755089916687419516880470522547999047111574925520980758925334424686509426"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"11044611828110471959879077895562685079922058649080805282439608029356151621007076572755089916687419516880470522547999047111574925520980758925334424686509426"); - } - { - Aesi512 m = L"6423193164177254442343420903692381991766249060587915381899157755245872211063949625874123363827616053683649275102373886739242440562706406354581599477876707"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "6423193164177254442343420903692381991766249060587915381899157755245872211063949625874123363827616053683649275102373886739242440562706406354581599477876707"); - } - { - Aesi512 m = "9135891680902444115616290970622731503101229940657929404975104295973442446340404284667130126139587515749647051518074583086032855260232218370752530800026680"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"9135891680902444115616290970622731503101229940657929404975104295973442446340404284667130126139587515749647051518074583086032855260232218370752530800026680"); - } - { - Aesi512 m = L"5761897487379522361143009204065787468315945832221115127672360095867913861305803835736208731062537848906984299410462240201192771351437272521027504247290360"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "5761897487379522361143009204065787468315945832221115127672360095867913861305803835736208731062537848906984299410462240201192771351437272521027504247290360"); - } - { - Aesi512 m = L"5183110268450272653207904285487892771682141664881081547059686608171817063307130654739862597240614423779280558307044815236653037098567725618077400050915260"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "5183110268450272653207904285487892771682141664881081547059686608171817063307130654739862597240614423779280558307044815236653037098567725618077400050915260"); - } - { - Aesi512 m = "7554073453559159451742916613154326652631944994331615860130270705435328389666230466875492266267189761667177287208239185671029727538572686798156678092198625"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"7554073453559159451742916613154326652631944994331615860130270705435328389666230466875492266267189761667177287208239185671029727538572686798156678092198625"); - } - { - Aesi512 m = "3542547058623734052637808539002177930413640397986480358605486937121283134308994559399621602172151282110972761667795101096204679539891521406435448173845706"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"3542547058623734052637808539002177930413640397986480358605486937121283134308994559399621602172151282110972761667795101096204679539891521406435448173845706"); - } - { - Aesi512 m = L"10519084879172588334898763592727111107055285535141702798212854410429644815679933065369488241327731146080769992872983024193547431165818250249725482874196847"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "10519084879172588334898763592727111107055285535141702798212854410429644815679933065369488241327731146080769992872983024193547431165818250249725482874196847"); - } - { - Aesi512 m = L"2810088233553736369876195376879890557180950761181861943064823454046758624350785526760932585248644069960870302604483414753448984852984926338818996818088485"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "2810088233553736369876195376879890557180950761181861943064823454046758624350785526760932585248644069960870302604483414753448984852984926338818996818088485"); - } - { - Aesi512 m = L"13182632383112556380327979292494073878155803030486671063425672277467465315787069221957247684858726358982131109799585554558078419574397554686851125385180101"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "13182632383112556380327979292494073878155803030486671063425672277467465315787069221957247684858726358982131109799585554558078419574397554686851125385180101"); - } - { - Aesi512 m = "11202112803413607614250403205154984647732072869307261145172530644721216667975571980703870392207378045218739647192910000033869180583975336556614260426774097"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"11202112803413607614250403205154984647732072869307261145172530644721216667975571980703870392207378045218739647192910000033869180583975336556614260426774097"); - } - { - Aesi512 m = L"3789094957772198706239103475221495617772434278796706638650610432515402762145014038465744468460062978139035195043468160513313652335685686196561399347669414"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "3789094957772198706239103475221495617772434278796706638650610432515402762145014038465744468460062978139035195043468160513313652335685686196561399347669414"); - } - { - Aesi512 m = L"4942170910311042405691334599803960572579254592267446658009861668340285383067282015247128709283533411265864910066465875011193994415421211851720256102793865"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "4942170910311042405691334599803960572579254592267446658009861668340285383067282015247128709283533411265864910066465875011193994415421211851720256102793865"); - } - { - Aesi512 m = L"13047766926595601541473268767969297387084083652078425371049195659891047896292924980290785383495912552963893449486082160246966722672098894743290931382926929"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "13047766926595601541473268767969297387084083652078425371049195659891047896292924980290785383495912552963893449486082160246966722672098894743290931382926929"); - } - { - Aesi512 m = L"5539316586037471043194990273472192716803831003791235401538032928475699047070443469674672404211791213313638871659265594940144274013939659988946785176650138"; - std::stringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), "5539316586037471043194990273472192716803831003791235401538032928475699047070443469674672404211791213313638871659265594940144274013939659988946785176650138"); - } - { - Aesi512 m = "11282409441323120763491669602964124902400052652986162876550682947579339300295441347556474597242477192367942748876996638435003338922337582159206732781201262"; - std::wstringstream ss {}; ss << std::dec << m; - EXPECT_EQ(ss.str(), L"11282409441323120763491669602964124902400052652986162876550682947579339300295441347556474597242477192367942748876996638435003338922337582159206732781201262"); - } -} - -TEST(Display, DecimalFormat) { - using namespace std::string_view_literals; - std::array askii {}; std::array utf {}; - - { - Aesi512 m = "600444857593376109989710428688786616835349190673461433558074395635776516875363265316582019554087090668278826437117483648653826854206892309592992851822973"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "600444857593376109989710428688786616835349190673461433558074395635776516875363265316582019554087090668278826437117483648653826854206892309592992851822973"sv); - } - { - Aesi512 m = "5842283621939104296972293152509845871709578682365438003582643886693598849368500072526642184904460391679365306590747797368102051641067287743780352046658683"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "5842283621939104296972293152509845871709578682365438003582643886693598849368500072526642184904460391679365306590747797368102051641067287743780352046658683"sv); - } - { - Aesi512 m = L"8701289820127109330680516825660438804485555507058038886622419621157723683899448217448557001031978100198976997060449963411381804574863124382579200871975002"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"8701289820127109330680516825660438804485555507058038886622419621157723683899448217448557001031978100198976997060449963411381804574863124382579200871975002"sv); - } - { - Aesi512 m = "970377916863402742243569953127026763683922851179430687216254171920536712089990915067025967246268421325344513184215290164214107456104104380583285491908839"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "970377916863402742243569953127026763683922851179430687216254171920536712089990915067025967246268421325344513184215290164214107456104104380583285491908839"sv); - } - { - Aesi512 m = L"12208606109521725375656133195464072669435890988503117231020684052868437468411987074510796492306128912961705468434848647152221372393825092101388469118538144"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"12208606109521725375656133195464072669435890988503117231020684052868437468411987074510796492306128912961705468434848647152221372393825092101388469118538144"sv); - } - { - Aesi512 m = L"6234268488445210861073182369718222064706977104072412917249014953565112926568917619159416208117919109209574054485454077698995130832941542932373554411480393"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"6234268488445210861073182369718222064706977104072412917249014953565112926568917619159416208117919109209574054485454077698995130832941542932373554411480393"sv); - } - { - Aesi512 m = "7267652423387687765966759748113019807090950555363373772755972813397742319070708926423296108380186071106569909878992337336467532870674039631262518773601553"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "7267652423387687765966759748113019807090950555363373772755972813397742319070708926423296108380186071106569909878992337336467532870674039631262518773601553"sv); - } - { - Aesi512 m = "8293350918571072876668929904884302958081756758261689234414255963152681386453392549799917453015836420880289235172786503157931304354670835461841930451990576"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "8293350918571072876668929904884302958081756758261689234414255963152681386453392549799917453015836420880289235172786503157931304354670835461841930451990576"sv); - } - { - Aesi512 m = "2404065311086430063677949915827229319938670043896833504574761491502611306585142590340265670304352851427433209925800100302890596053743779533123454604491136"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "2404065311086430063677949915827229319938670043896833504574761491502611306585142590340265670304352851427433209925800100302890596053743779533123454604491136"sv); - } - { - Aesi512 m = L"4020659674458326635450435777963118641381280255352579431571334559707064662910596755134765207208317918062915433386312273362647997262828181277308854971774408"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"4020659674458326635450435777963118641381280255352579431571334559707064662910596755134765207208317918062915433386312273362647997262828181277308854971774408"sv); - } - { - Aesi512 m = L"12274029035548441949440404514099323778431895334668860753649691559050594353648269217530030493334028373453055835642880103931095427147673867605279988399764286"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"12274029035548441949440404514099323778431895334668860753649691559050594353648269217530030493334028373453055835642880103931095427147673867605279988399764286"sv); - } - { - Aesi512 m = L"9267651236261335083054758364850082767109310457205692144367916511385206394060082876430820060289291938311839542378500107222975093165773560828651904576964942"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"9267651236261335083054758364850082767109310457205692144367916511385206394060082876430820060289291938311839542378500107222975093165773560828651904576964942"sv); - } - { - Aesi512 m = "11410319174222825661359268277795728655876327085744471469587446912992236104967206492736737860164544924719729301036597508840173627322188025670568292621036188"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "11410319174222825661359268277795728655876327085744471469587446912992236104967206492736737860164544924719729301036597508840173627322188025670568292621036188"sv); - } - { - Aesi512 m = L"8330872378845632891858648180837079405378412340859731657283492211288977888844766176543524190646743709947558903578779457589757391680312665819918062061628117"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"8330872378845632891858648180837079405378412340859731657283492211288977888844766176543524190646743709947558903578779457589757391680312665819918062061628117"sv); - } - { - Aesi512 m = "7828403706330431413722600771446955873704236392455080757153936896820213434837980034084613639454748361564418950120354991307876747550067463033747474365066651"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "7828403706330431413722600771446955873704236392455080757153936896820213434837980034084613639454748361564418950120354991307876747550067463033747474365066651"sv); - } - { - Aesi512 m = "6202589149255184407085638205712729131733658112025271978332516703840190346486390504206844404693944696787935628425269763343722298930218842486142788567206904"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "6202589149255184407085638205712729131733658112025271978332516703840190346486390504206844404693944696787935628425269763343722298930218842486142788567206904"sv); - } - { - Aesi512 m = L"3894994694452438103832816676751508036369060306787367521377838103210806383185297306864492418197089000061989604958139046319018446242197936484126289125741577"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"3894994694452438103832816676751508036369060306787367521377838103210806383185297306864492418197089000061989604958139046319018446242197936484126289125741577"sv); - } - { - Aesi512 m = "4342331432003642972543021203578352589693388564435469740305389095456086016310002660607660577629599326251012940006663320925122212925380791020559008817743562"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "4342331432003642972543021203578352589693388564435469740305389095456086016310002660607660577629599326251012940006663320925122212925380791020559008817743562"sv); - } - { - Aesi512 m = L"13086962691765623347370197422422464765301007142884050855036165474756462353868888932397339345179652841536891686464470898896050668681952955645044376288390679"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"13086962691765623347370197422422464765301007142884050855036165474756462353868888932397339345179652841536891686464470898896050668681952955645044376288390679"sv); - } - { - Aesi512 m = "3753110627842532472561848839303809510341418271312343073390246790620743870593075026035441596724101588118801066507869934347830690052757418804219982752252373"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "3753110627842532472561848839303809510341418271312343073390246790620743870593075026035441596724101588118801066507869934347830690052757418804219982752252373"sv); - } - { - Aesi512 m = L"1522792046037558303629396463632204536991512802212217850249791285159844601291382519966389886662011825325031964083905800840940974878213415407191522603266785"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"1522792046037558303629396463632204536991512802212217850249791285159844601291382519966389886662011825325031964083905800840940974878213415407191522603266785"sv); - } - { - Aesi512 m = L"7160964367231869875058851459931343284598125248342183017161505321386622733388722477233327701142610947366793938096516168347686974729152601920331484938547554"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"7160964367231869875058851459931343284598125248342183017161505321386622733388722477233327701142610947366793938096516168347686974729152601920331484938547554"sv); - } - { - Aesi512 m = "11216418788383308227298931867148493614207379696252364213634447357237578346971886757833064018930672689258737275786836500660685499140222005014999216415117098"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "11216418788383308227298931867148493614207379696252364213634447357237578346971886757833064018930672689258737275786836500660685499140222005014999216415117098"sv); - } - { - Aesi512 m = "3676625634220832362571814988991231337596859813227890322470051538349130490586086080031581132650766972152226162533078611759246576872234413306202641646485347"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "3676625634220832362571814988991231337596859813227890322470051538349130490586086080031581132650766972152226162533078611759246576872234413306202641646485347"sv); - } - { - Aesi512 m = "573395732506248058882033729620841507650614227801309035475252385774879102933339275056561048660857057531092035689905059818694102283043085243843689448717800"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "573395732506248058882033729620841507650614227801309035475252385774879102933339275056561048660857057531092035689905059818694102283043085243843689448717800"sv); - } - { - Aesi512 m = "5645621886792725857441363338430641308368356005867604416765042883091012592777169788760765994636655561185809519131088723854275527534728461015533566104243657"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "5645621886792725857441363338430641308368356005867604416765042883091012592777169788760765994636655561185809519131088723854275527534728461015533566104243657"sv); - } - { - Aesi512 m = L"13352651397007886469977855918825130943901791832269789197540577098346293016583615422747703948732054199026152689481774864741803358900266239922534319028546928"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"13352651397007886469977855918825130943901791832269789197540577098346293016583615422747703948732054199026152689481774864741803358900266239922534319028546928"sv); - } - { - Aesi512 m = "7877112439787939044337542563273793235488094515372925823131393094612970798176848668907146920165149450336023019248725688182408721569599360193160144632188938"; - const auto size = m.getString<10>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "7877112439787939044337542563273793235488094515372925823131393094612970798176848668907146920165149450336023019248725688182408721569599360193160144632188938"sv); - } - { - Aesi512 m = L"10333527956243512210646822302369349127067408967748268197833565436977894600812034601757186009739975807127630465484344508099192931024739329803288382247247751"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"10333527956243512210646822302369349127067408967748268197833565436977894600812034601757186009739975807127630465484344508099192931024739329803288382247247751"sv); - } - { - Aesi512 m = L"9549944368385960750528144098225917652555431650475388451073411570412697402007107768936532606016633054546943405989980995099693899498082444356152373273816435"; - const auto size = m.getString<10>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"9549944368385960750528144098225917652555431650475388451073411570412697402007107768936532606016633054546943405989980995099693899498082444356152373273816435"sv); - } -} - -TEST(Display, OctalStreams) { - { - Aesi512 m = L"6709497005772092244318192567569774395779193341709883499586329941274804054381247726648201746861285469272795757406571473116012794967057035619136696768170975"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "200066532251412415770554364332002117703434047445452553112424724255301662512152166170327527476004133136203707773246600055740200177461266570500752703046105650363771144505737"); - } - { - Aesi512 m = L"10829026515385700008540881685669909498152846747675623277356952263648266490686706683115330586771960104208034116858617041595301687257562780163581084660015533"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "316606267236310310070520006011467217715134115742562602702774135547566773555276041707272453067217660035457453224415567732361776646634661252545414300715074520752116404420655"); - } - { - Aesi512 m = L"10963792738576873216029253155647530170091079967579731095077821859814084296881275346531495618966261289020024063920972611300205993825152873606943583385510321"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "321253634201214567565576346533721465303376274541050323575746144433625111277304745406763770613760262636772432046150002754251741253046222746164430015770030612772206232260661"); - } - { - Aesi512 m = L"11817433246204735756863701610182333454723556470400645867223255047740850614560230911830367460137264597295796518824036400939930805754919101599522592055788583"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "341504644247213211477400243042244252547122504350176474166506646421652612151042153176346300241554263144036012472575230355615151111446565316214071500727030671536316310502047"); - } - { - Aesi512 m = "11458993231679052665586718692887033104786835608210444412914223223168288863121536543760423622929455032695831228853786049976973310245466945225186053065491576"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"332624621457237430751502172111305570267137336257204205456637527743333714246134404356015414410713547166254000710753620115717661033500010654065730636261734146051143156642170"); - } - { - Aesi512 m = L"7661755216921362154892665722766582971614291235934618941668263180092575918470664930429821833158161101892953233338382315817327131931582809882462833298510851"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "222223604377006657471303404465657716143247220624707141740755332076021073474230605327350136034146520350137054475576454320157341511421433501065474122712514452620322000412003"); - } - { - Aesi512 m = "5958944060572806011170452021616922128354494548522119974046219969612609881035874918688411842914220609877260564134194173115491584533151575596709738519619545"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"161615330730052236340430173623764070446736005136224044631166632354025732105313653624447024536302642121317676343713050070014544754757746757705065506713326250675577535463731"); - } - { - Aesi512 m = "3885017166963260891372423734520728022189548735551898131770065473337344448970028721522512089670089541979474775906376882875234291520399648900479676243820122"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"112133105770732006754625701207755757110606654056425177663447531163436206114311154076664344470362041571014323507226671124232722773013011643416015011423052373577561636137132"); - } - { - Aesi512 m = "9610812017219890026718312941572986086039048872947614820468402222369513999558396043032146621756002280176484109012923672857905574415763693057621165878502795"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"267401256532342617410404675171334032576367610256120052412447375024304204550707124740471715575564202046465367561312201406124364250617455744044372475450517220101307323662613"); - } - { - Aesi512 m = "4399835853990253825929184129069969133299574665432178225308085684899183975506780673078293326589788674139163281991394869557527073604473175177042093073020056"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"124003714354472130327452255367004473143537052466076300365761666615571016121003527516302062534542345665232352635771747753041543567755246672350502051102145751311100271132230"); - } - { - Aesi512 m = L"9153066097542692284297927623039495477138055023028132839310667970076889542802181348568880076634743942944592628820406822477591749236828794967654279598679776"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "256606405203643346362435407057143322007301374325226776703774116601303257701464607314251102461015172065536272763111425345615147233062163552302534411572711151713035641323340"); - } - { - Aesi512 m = "7288531727502728821804942542238720045613782220691018411793320151650708886978329200660411439827348023205484971826439949615732157811723295380186393574815431"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"213123147315167546067604453034236102011116470461005441205172502304553331072320555403113134643655231412333007215623710215121576220350553504463301774372052212722425644533307"); - } - { - Aesi512 m = "7421546063719237669287159810714422826413171699847397428905924605672475982639831714440995550729127137288674770909669176517658495540795691810261156247889032"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"215547413622230264121246600167344104203406124633361616477254177265105436503712515022174435074326241200320021651552216575466706133767013015230162014522002112047015317762210"); - } - { - Aesi512 m = L"2867937199704401184468452510451007105218577497921802783284570842737139753982073876364886646665573994463294979471235184224649558395444238325360441796003875"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "66604275355422311722206067744546213254327463200450564647436466032040576130526105266765065722616653473673423227364740631575636126162552242377467467356053166135105453604043"); - } - { - Aesi512 m = "4463395548013235270723742523317249238486137478993165506098769349907132552413008976824622577972888421453017925615062476257374510703894348995007062951190799"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"125161175736350666460713560053327732053604532456453066714133536374522624741143500565714316744475442770474221620021251771127105625307336416275670203752652267454226571360417"); - } - { - Aesi512 m = L"7913200782734814743382001840126754758178372487016296225339274354666770457069763282946390011915317401451724285065875447865780537042335449283819122978235428"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "227055655624266163562374275472604730623260316556010427625235163737152646261757034710504763261530504672665516324403062500430232670251774322215777453647777635513402126122044"); - } - { - Aesi512 m = L"2659310794393536865369276299874237874603985535604215258186327588043024392520900100583078199190640603060547549715079404884796054258427933859826115841694291"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "62614702756351107470333010261663723377240652125736776137177700305344757402540567064470162271471067637070173177546015436231612335156761216746000014325701456161162153215123"); - } - { - Aesi512 m = L"9858599906681074196724567974777639959125271839742456846057079002860046213224426816706189578229989128956941340645563115096964054173010424793947789148550687"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "274167524423505107723375233110544307561400320273427165377450672026000404213452141375726263107135441460251726253753754255010063244756213731377502131644106742130716321773037"); - } - { - Aesi512 m = L"6784626077713046053224066748259066394955029977756891880024139751191641809982557718921454271386392436901140885150694181142103726557863607076998175017884194"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "201425076742765374173576143674364736076260371621755304253600060200351700316665025440235425062172701732157723223001624316665170025414210412131056456760607620064740661655042"); - } - { - Aesi512 m = L"7066863624569033449678670902846066224909673646813401002315140687008729840941680992848072861726613312255441085304509423143582106972650233458333370786887041"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "206734160376265166537003635002106201325622317115423251761010264227753670700225037350121145202230662415371731211606162645373630266267320556173412047744650233443546256332601"); - } - { - Aesi512 m = "5801547984636748750158868568009339820162193614227966231194714039991852080560446812915587281104143888286590648089705621771914881346422662111950820972595141"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"156612600672627661005414773071272405732031321553254257665257412335152644074241356571633144501741227643543407132362174563060575222675744532640660401077463326777501656503705"); - } - { - Aesi512 m = L"6977869300870162892805364744171498746736839902305529755238724495049619064394405082250361485146104522249834638218861625360037817647699217268310695169877809"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "205166165326473571217227762772044347521301346651522110635267775523122660122747244057222557600520504410221726607561731461136050645770450603542271572531127652562245453363461"); - } - { - Aesi512 m = "4244219649439237918084686139085894785486369560056673287801480267701287461558765336886997305596827253594231359056292377169735838124283393730390736498459123"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"121022501017665346120762406106547043072565642121410276240034032721524006053276653641027510374633126771534623302462470546613731366007000712145454614012751746443561347400763"); - } - { - Aesi512 m = L"3298242917018822211034378075958513238808541994004380101469799393285672395894916825770298418299968036106867692146484288985674831582451622943784966245086076"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "76762746760464420454010504436726416110046634432721455625031730720065500174164374670446312136332673237752320272332071540324524036557733155114522221036167437132626017071574"); - } - { - Aesi512 m = L"13002063764732142106740923233169622166373054385387173685651639998288718110796096348361572063692990768009313372556276229108250239071872108437517254099386975"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "370201416124233751052166777740421735635002544536531400731732744021215574575402006140233011406520773733357446325050631032731035133670531113720512226362102577147361770541137"); - } - { - Aesi512 m = "1122870693416682796648909539697379297505444773464616964664405831600948152839680624690867195263845249551046659624200283939655529711330901209929073303467688"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"25340751052552622224154257635263506212145447520403537202556206421010766573322232251473526756476026670600270352030732614207113224422004347570622435422556505424565636733250"); - } - { - Aesi512 m = "4324431989675830982142823608071503916281849677957032943143029776364378358252510196893462582352884731002642702920747910901082640674259381074116320086412187"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"122442610351767117171244006055330275330730574452775564745401762335447467121313151552412236401154160466034012137415635403214236735571234467355137624401251065707350040645633"); - } - { - Aesi512 m = L"4145942970088463477653728579143226287813833235494676669194414873092433060302769103166354128414352030579853897069210522009916915416733505386035756525419302"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "117121711653417026153265564412316517252717050721402311342631552442101644242211407062567245456703321164406020206215533521673053541654636474624164420134406765246544653775446"); - } - { - Aesi512 m = L"10655391458182432026859360688386681131400596191337377020773606118559410669512619589682448221780577695083079559705876500271979873746513154742921519816550889"; - std::stringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), "313344737616037334172775527075305375446042761150527356352445073555474174176452166676047701236321274602372327677621377377506653431552114705020773105350541101111420734124751"); - } - { - Aesi512 m = "4123494456400201256480368781664588846221580144318303012681682856706547918575556249381339398464862309970071954050254299469785782288312423147387908290429808"; - std::wstringstream ss {}; ss << std::oct << m; - EXPECT_EQ(ss.str(), L"116566342270501131203663207662630751262471445511630726563774102360066735705275174463116610301507513726603603307523055442656650541663664677446740165733055112223420704541560"); - } -} - -TEST(Display, OctalFormat) { - using namespace std::string_view_literals; - std::array askii {}; std::array utf {}; - - { - Aesi512 m = "8484034216422490346844225724538580309609826871719447801489682009184578521119028440827325962760198453384816501847275907797319857740928958614326572126138539"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "241772141553047627416762225473643105405564675674471474121002442232310260063774751455330052265332346563560653156042311057031213673212004646274654521310723375325415370270253"sv); - } - { - Aesi512 m = L"10960019143940531978623189799162987450418960385725402925558511127916399744423002666644672578789808327925753135422177212711794307101436885697290282958557636"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"321206724501171317557644273773662411061327363243547507476747154347221112535121134060307413051445250371453452514456605404555412452165365642276500766127716507633656721710704"sv); - } - { - Aesi512 m = "802757384734690475735399671290741457033990474428064267893937541744013162916916959931150261857592159624870558638845020699926278989099659876835861653139811"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "17247457362445575654200530403407711410422221122241501762420471450074033555445266223134144651256457576252636550647440450032457040137434571571464536023417545421556735130543"sv); - } - { - Aesi512 m = "5864033230393456378779940845123952084444387491579017969675272329732544052622462829694185631018085210306509865488233843391984034018130462570637506587903201"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "157755460400152475321767360162536731661103210625006533732755312735046302401103761663777251344262651562160623543721342574074100271225715462633725413125226060102247131742341"sv); - } - { - Aesi512 m = "4055322183898134526647006581328499344924144189822785087579542020832975640267911996019006529764974941824792399928440431103290363589195205753353859415169212"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "115334001763047106441363202367006315211360502517265570751143502336052611434113603576276676771124672232135612301734005221177316252340351041106027673466130417405420044054274"sv); - } - { - Aesi512 m = "11278960547499198271581006008298593926640247252181217768461649432065716632299576897920822906806393280659465593191198509682279417591617941288941918500838134"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "327264644467420763335502015632745605150477001515173025407234627374471464003773766766757261553527426111150712520754705763111556621211477724757257045173725704777241612455366"sv); - } - { - Aesi512 m = "5682096456815572334427722228997753161834198050376250220913996016301183909842189824600807619144013881529341532093840683098372516873204671204926748685151697"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "154373011116450556274246537746441713624621706520555427176641122274404221015412012225320144003574134106060537533476364137760772003552430663572464544707276256426123375526721"sv); - } - { - Aesi512 m = "3264032709089657621181816002925687362025707241811219955494034478279536753972724210317415397911090090168373845085792972393525816546718370224333267525636128"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "76244411613405560707072377451307273513230216051402440745112061524144610235264117030567157331525521541101017523575522610320062662560727655702732344233746202377660734610040"sv); - } - { - Aesi512 m = "8130435973873228507062341598650166499015915188316578025229210773722404351132125639079229510092640837232335295275371550192780132279879831838059628364422837"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "233171371031226003535237272435235315217535452642031343632437657313214612162121110376741271157366310451250173200414505252255164123505512222100275426714512241135561517357265"sv); - } - { - Aesi512 m = "4468594271967245378749275824424532093290268378150455680211746353358218181769864795849929662730067075794424762152735466431123026380771993824596499348612385"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "125244042501351446556643725674120256033503735241737307136335646614430013601572420113525706610553366062242336332275222101643327045200667040775737422230031327215630536062441"sv); - } - { - Aesi512 m = L"7252298404111700062412573514943084873351297118137289923424748128959996472716293849941065680366355584912270747046622099123281041368811743769299926400911502"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"212360774056147373563471022622426335540744410017230604335573546357525615425033573133457440510630670051201123400236646137622306554753030201075571174054515503216736676044216"sv); - } - { - Aesi512 m = L"11852166318003589205656466952728474380269044942318486325244783672832177483599640323490176840808280921231850989133792562896579792144533057018216751139939438"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"342230272442007162466542546715201364175276401372176154602511274517632436631465414502021446510712045171131250767514512502040522620425556652753463421533646552440467503062156"sv); - } - { - Aesi512 m = L"4457170574920259620020543432027471088379114859509112682096128027725622440011418429738980377322268062785161072371873912754827863577978701383293719993647757"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"125064310515234563535525177301405030021020611603113536331445571376471217232442235725353560034426133351154150637012267534336537533267004110010172361736102346661203574001215"sv); - } - { - Aesi512 m = "2079150566744628347214264727469922303913739677028011170260152362043936031896556333537244147086441190282892043226769151035299761892626395694345207968606729"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "47545264402453537026567704064334702031224742677673530440022212032263445536344607643304221664174062166772117656643135520310320670217165462322755324216412440224427700525011"sv); - } - { - Aesi512 m = "2384637575118362985497355335385208819479580752287691643664999256705084702921417524583231555626735615104999486145688541510010126671842741251875963659193999"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "55417566342730074750470443436254746274042251430104023743367220301775244742323566117530765514673454755145435426217264111217302605576130602077212216623146505126105304307217"sv); - } - { - Aesi512 m = L"2890972583445425064807690877250231512652986759470572448608538043783842074550066838983806667536044109881898162530166596876048846452257240385964179563828345"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"67145436260451360220105125070245361261305315040301602442745326353746627430221270760321732701164201407464066036173146735541027055264262565001370261171772513072627323252171"sv); - } - { - Aesi512 m = L"12405101084591689854257569269961157325122189340577512090112090095042062433868754814671024861268250696378954078326875764594094213234008822076269034527820324"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"354665573740506575173414117714444027242621007424153720150312143420157274110571657104451776350004076467234163417655523522777062173204420557564370264722127320632621037105044"sv); - } - { - Aesi512 m = "3987768491954275004270890230267116465803638184202132213757431311947527019402715906442687977364461737149323559264676322437190424076660312263371455272047824"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "114107471555072356343426705722574505026641622364262575061713743741136267234631311326111646672724367723121466715454316465324570353150537243052446111600451344370036565752320"sv); - } - { - Aesi512 m = L"8686275287866132080199247911484344414668543047647031790736560439745367785217105036726392965505758776954726897897937570741491407108319663437109540740719653"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"245663204221662010362005660310061341621210453142725543601423454014376575661401642517414763310641227232202240055570170662553552516077544751627250144011363770461305111162045"sv); - } - { - Aesi512 m = "7794088297566791099702512979796360334958143655626542623883781239627269177055592029267447496150582002392164661063308196186149159535793592369683417856335812"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "224641327035256603144651623007331644527152422566403763425011424155032542773552751660017114326064122200663256632142020227334021274040007114400266607172443676234424443357704"sv); - } - { - Aesi512 m = "6953536595315515866378190345370902037113724703374306940568274958474507695921827724590152233807926034405398794385878350016194234184189761850227236344724249"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "204610267130462676351107033311513747447036601616215776736567712547320776327543240546270557271370333670652554223126173542541167201661705265017567661667474676234435505075431"sv); - } - { - Aesi512 m = L"11168702461638248605209134139108397147937345209684789906462179955309383292449956218811832828903360890096820661848960460571846957048043751732692682504941106"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"325176753767615663773730127351547402630344201472744315036013025153236316376742471642101554334501345546207024310520326451632670434243512646521537061724057557034611136027062"sv); - } - { - Aesi512 m = "4512534613069233672671636178451171376601943530187571857749811341763407305823076572112633677400622102558040382415476932998584900554247788712875188890843920"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "126121475123415152175241651257567076504505237527336430263053217521523171067036177007624252347714655630074424752645611071657504725065607465671621343000344667361505115635420"sv); - } - { - Aesi512 m = "4982347366455792100746972248766558509558022080142225492933216339525501186972458323889351316724750835799215730324851574425325597183016522863310074904354857"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "137102323456773025157250454514107535035206651263314775711505372654321022567704035707322571125213655420535144527306546323267131710213060361575365030605026511636300446120051"sv); - } - { - Aesi512 m = "2631599580625143192087900837232658798420176226565942532002492918531700171822213737859442114505091811526476217999938805949400358366968593856033318767678537"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "62175766453053612004671474022245165215374751655551700327753624631226425264206757413206627660246256361763322474757106336163001337664410452036150325140453004326570253752111"sv); - } - { - Aesi512 m = "11497334683338132625210070246173652952247255579072263620159340472658368566126773687792306865282516663905158069780082640038724815124594867274890736491024911"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "333413464413574016104447306050533732755560062453132357246702263256533567566717576103741550350777450466426732671602140351735455327640203723012155177151503515063144740751017"sv); - } - { - Aesi512 m = L"9148447934917260133122931651974110261666311609174166083036224183164236783459122669904372027316955134866742317643098308100902889627723092433818514911751469"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"256531272311634345365212543704656255306161544541337721765040701206273170030072422345047775123276770642156401714637245414255523717154140423304710436253460240161015707266455"sv); - } - { - Aesi512 m = "2828154198893713655751876443910973207844357097460721711078960201459121266744048818577596124038203784798116758543900892431797035366686222363404095316328559"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "65777353217453631730651737161473461330757011430435412767623771134276451720303107517102117524643006762142502630464521132473031623563053500355227413230334532600711256100157"sv); - } - { - Aesi512 m = "1637723736479353437609416338592574087762602791149333015643066138149781575933224969399920245285246741160618045926485783139376556484828159992750879455288112"; - const auto size = m.getString<8>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "37212033411350066576232223422010457666000044122644034035555160112116433261234435763452676226764061307254167535512574501071011771216744717361640350300013414233161077715460"sv); - } - { - Aesi512 m = L"9721450558514701199624432932527857692681296962885633519057149069807749013279573980718243910940937939355937383856267057837307948011374935414455641646640322"; - const auto size = m.getString<8>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"271472727436425220137167372371663731237266723404721357545243203225266715432655525265774210432260175652052433454571516012015545774525076602603312010036773155075746637226302"sv); - } -} - -TEST(Display, HexadecimalStreams) { - { - Aesi512 m = "7880517571022950135845519542545672635674362352352514176282423056574525226599892286573829024390433755135566410917621847348118828703457916905410038592565806"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"96772ae1a35dd41c7b2051b57333fc8a40feb3861930c79169d9152850fb25314e0908e0ad128617f23351fcb4e467edf999f7c2fdb9d85bc26c9a3c6ad1f22e"); - } - { - Aesi512 m = "4264099681992859953428700257308506548833569460341107904066013581875163184522361800591056639061618611680419927469976185229030729788181703082707548776871291"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"516a7c2e51a7cbfe57d191c1c8a9ade9ffe91e813ca422243caf6eda1e02c21ea1e1ec42059a1ca334bdf8134ac8ebfa68b1643a6ecc38b21bbc832c9fd2b57b"); - } - { - Aesi512 m = L"4969473408704730569119081757597352219810490152051860459464224318228594073529478745042356509385704447159942891945479188736621416072713392384524864054918713"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "5ee247b09093663975567540cf0e92087ff3916d8a12ac4dc81dba4435c216cd53cb32af1d7e121fc77ce72d6a4a076b45aecd92da06e66ebba8eb907e0c7e39"); - } - { - Aesi512 m = "12837611856846692047094720684342812028681834885707934468880235261126596899946724988455328861694077220010533339930550513392142175252829861492880666071121079"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"f51cf08cfa7761b81f9f1eceed56fb29e8a390b7626d6e7affda8646b2fc68b32d6c646e3b51973342c6fb3218b49984d598330a569b21c056ccc5333547bcb7"); - } - { - Aesi512 m = L"1345481284631240346205266076543255131917458615010120228173017295841699378836943327976483143181335924020261824630468181015111837070391452560915655675507198"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "19b0935593450280fbfe68e6c5e4199b2af6abe47a9e5591a15509a2188362533c8f743e8c9acbd04fde359bb439b25c8cfd5de2aeb04ce0e2a342d0066e71fe"); - } - { - Aesi512 m = L"5998743941943662041421715106865555994237109618387573868439354652964837660260719790900071006046153997362003038209880315738524364096958692719800368212928257"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "72893fe628daf210e5635ef688f834687ecb4b4c0d3a58b1f125748efe45e7c3b4e03b7930b303f09f9a68a500bd36374101401d802dc6527065f96bdd96e701"); - } - { - Aesi512 m = "6201702231804575744742911333878352069425628575643140597776561196804067976333958743756096065821261798214913520300216886526355126443137050219708465959684365"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"766949fff1e1085f89b0ed9ad9722c9eb6956ffd3a8f8ce654d4cc7761249f3b33c77fa4f1d88ba49dcfe76964421aa80523dcdce68d5c0c8defa29cebd4490d"); - } - { - Aesi512 m = "5674794176244450258829887524841788638209876857526442001542219528569579883560878736532147194795182171942973782398015927313227808238447213957205218846131324"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"6c59d0ee39728910a249658ef3a0a9b4742ecf7bcffa776c112afdadef78dd2b4128c23538e070b14bbcf8abd47f8e947288f2a8ef424e257f9cec95e40d447c"); - } - { - Aesi512 m = "6987611488997590480292662047392191937292923773199964283503090050274452634932792294404198773035355861254770339190018094585766120217189695749623722504832618"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"856abbc60d7ce1e057cbdeb011eecce3d3ad8393eee33aa13b6140cbcc3f32dc49d4d7be816b493194deba6830fc0967bf30243d5cda40c8ff84d33e54b7466a"); - } - { - Aesi512 m = "10035872826719669081248547233889172993174274556724574964135778997628930256630635602678224175737907954900793979792739792560976990485896169849519008768561576"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"bf9e531515d3c55ca1bbf04a8132473cbe541c69bc8dd6f5322a78c3e73f3aff91f41b80faffe25c1a85a07bc83c31b52621ec7aa9de8bf77a5853dd819b91a8"); - } - { - Aesi512 m = L"11477798173626033995903669277719265607855207358434758849822176331706945460685678983518964230993131078258037278114696820975758109216468346084484878471985037"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "db264f0eef367142529b1d81c9d880d46f278451d291deaa25f275ae8ca3be6ab12b737e5d27dbe6a455ab0848408fc21e66060cc4900d8e0e8d6775fbdef78d"); - } - { - Aesi512 m = "7248567649440870421714126167839340027848249030352896390165651054741709950609434686833942167371828580576510520010369382812150551339642091031391907351083177"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"8a6642b8d67e7d325cc6032186ce9a3446efd7171b60d7350f08798b7ce04a61db5e85c92ed7acd92640cca2e9a772f2d4dcfa9f1929a1972cc2bff7d747b8a9"); - } - { - Aesi512 m = "7875864189336712932395691964929876092576350803083970390881512748351083271668036626970108215499095848239236240395340759242150201877378258778784154270876518"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"96606c188c73919545850fd210124df448a5ed25ce95d0580cf3b202e2c2967da980ef6726955a0c55dd9b795cdc0e8460344402c254c16b077dfa51880cc366"); - } - { - Aesi512 m = L"9491154788781075247852634358541027356904295110476014230370301294705260976090685227931819872514328509701101702371238343220243540531554402327883031307052872"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "b537cc590584b358ca23ed5fa832731ba91e7c9336ddbfad7709c3ef59ffac1024b0dc7c954f7c5e0877a7de2e5437b1ee6664fd7f24609979352cf2ed376748"); - } - { - Aesi512 m = L"1206087033702990626266777809043946711018877942352674025705301911254311673207950561072302408493832953252531661619987702242287774266291347346922115000186287"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "17073b09d6e35248528534924ab7aa3d22116d17126164c094c1bbe45029dfe56a2f919f1dd5d35b81969eae63306cf99f46272acff80e435b933ac3c3bc35af"); - } - { - Aesi512 m = L"10007769066757137787867545397602095715119255676933249745913022350342797783115576412980155998479420674371605607388642402654828861443478380386933969785739768"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "bf14f4cb0c525dbf82435c8ef6b2179a66dc2d90546322aa96da763be44e7af9a0d6397186c7c7fa7277eebddda045f96ad7a2b6e7bf5583f352f9e846cc59f8"); - } - { - Aesi512 m = "10610214740176092705762419878266035263800088964462262551996824259485132080948565324295059394666238576512404547023016537571610558215039955436809412967875764"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"ca95a63acfa17facd49b634d45a4f6bee9f70f431840a394eb426cb67e572e88280a3c1e9915869c73c17214d7453c2db65129f6714f6c2ddc36e98d89eb44b4"); - } - { - Aesi512 m = "10159186279869809039555586344840248761030741256966552319433547577367412251863910016960676691738514521669057921614642189682113226632198467584786506662286179"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"c1f91171e102e463273681ff28210098e595f5061decb46dff53444fdcfadc2bbe7f85403de33d981e9686c3f133d111591761428f95c69d107ec643d2381363"); - } - { - Aesi512 m = "11560905456886966630637747947155243958224364918965232333919941958205224972454070731860489540658363964243888060130699556727768004887464911752557320956113195"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"dcbc875cd6c5a8f02fd0d7666ad9c1843e2a26266059b59bb6e62558fa1a2198b4802454e474560c786bc45e99f9273661247429bd6213f7fdb8018c1291712b"); - } - { - Aesi512 m = "10461970722222664228407243826567975215844586202617809207127709347560581530169824663786361676179413056513521676716396156354678048987990289476131296454964295"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"c7c10c340ac0dcb297fbed1e3a0110f6059bda42ba6a713d2d6bbac3bd85a7c703a2a53b0123ebb067b92151743fe445c8581bdf18c4c78be68de077d948f447"); - } - { - Aesi512 m = "1905732771103304924911470826615729702792904617395580369223679761303507916524341125135862887045580702728207032268082763293074373979785201498223894841582938"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"2463071a64dbd97117b951da3e1e2c20fbf9c99e7e05fa995633d41b720c0c94284a47e66db08aa5c44cbf87a48da02000e7488024405c82739c56216fc8e55a"); - } - { - Aesi512 m = L"1171523522152226172885723477380703498795644072049767306239276157973858799001512285781065902802008374217118393543995494591739942125123161911973432061054073"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "165e49a64a26c296a488bd013253522cbce90e022952e2e735041cf8b32f1c6be4cd36437f1df82f4a767cf2deb7b569fa489e2e3545bb80673ba7e1785bcc79"); - } - { - Aesi512 m = L"11796541430421156043012651866556500860892588296615220046585981908028737914364379931881561403977245162488007698063362104118033134445385317952518191564582175"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "e13c4b1cb739aa77953ea1bf54b80eefcc1d352b1e394a373b85c9164d6ba3bef872f60ef94aad0a1418829564fdfc06a256dff03eae3a09f32bdf8a44c1ed1f"); - } - { - Aesi512 m = L"272330769824342204692763301355028865483024411744778691366301846388078374278593196571551782350697315465421848332905221437602530927167508297065910783068238"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "5332004e3e1b0a3e3290b00065471155aa765dddb2116857b0f1fec73b5350c6d94d18cb8fceed20af70d3a3627ef9fa53f11a6845ec1a98afd87426aea484e"); - } - { - Aesi512 m = L"1683375555079892398490023892277872863013760300832279665252006639302684555993256859626247253975112577845029887967135508607808588488499890928438469229316155"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "20242b16aacccbf84601367cb42ad7f98c7f665bcec00f7c0a62d4cde480f68018f499f8be14f89bc92319bca1b9b2e9e7950aabe83e4baaf1c835530dc0883b"); - } - { - Aesi512 m = L"10054687803218468284670601208312830466785149757009544943481222329298609289187702906155515686134681659436345053681947593573204171831989867476885038713892970"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "bffa4a4c81bca4ead82720890815be48ab012483719f354c3a7e2d8cd7e9e100177847357cf15974be953ad04ea1e6c191224b468aa482d9eaa2a3f11209706a"); - } - { - Aesi512 m = "11909754840017459360087932101911654542059885830892908607689531539432228427848411249473730098486463519343171209126085061579281885849231520160655277558906305"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"e365ab45469e34903fb557419998308e5da0b039732a37a69ae9c13356fa79f974192c0e0df142485737f5617b81ea00ebbc3b49896c219b56252546ccb0bdc1"); - } - { - Aesi512 m = "8472807049974205483382161732711874527766285304586659641496562939308353373425136692798647483005789466789540328968939771377699366042093627873019840980259263"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"a1c637da290612d886b6ea64e64447cc093baffd5f67959696f5a39bc18520b1d7e50664a9b637207e476e4c725053ea0aa98e0175fab68b5b264ce7338b11bf"); - } - { - Aesi512 m = "1336689854498858817975473615315501523979415129196908430383702068653385215053460560989641101821893198337787346984803986744098158563026135958100035560452825"; - std::wstringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), L"19859a99ca8b4983b84505c8b4e740ec61a33e1aca52a1159835e2f28fc59db0a17b02652b35e31fd315360eda6213505984ed1cc738ddda4ba3edca9bdab2d9"); - } - { - Aesi512 m = L"12535071261641456448713461979430853759558922583591512228765082780755439337161481951925084086425853547943613232207305690044005865063899864644622499107177713"; - std::stringstream ss {}; ss << std::hex << m; - EXPECT_EQ(ss.str(), "ef5626eb2cf7f308c78883aca2b8479304a621cc3a86c0b5cd72a55da6f6f22b084b39ac4a81cac10f229a6087e62b83dc0f92a8a3e888f6429e3022e5e204f1"); - } -} - -TEST(Display, HexadecimalFormat) { - using namespace std::string_view_literals; - std::array askii {}; std::array utf {}; - - { - Aesi512 m = L"2962250605905905588680669238415992278407693994782102774402412014079328318057033175072078122763635766638597571677414881882830405070560989344684638279861218"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"388f2de9e2836c31c3b7f7e98c749abadb19d2973051307f0c790aa5c6b0865b5066f39b11e62b660bf85d40f9e083692db407dc49206c105a9c9213698883e2"sv); - } - { - Aesi512 m = L"8615789059960587201354728875548730430681097361885198856710576975436624690688262520616872789888961883514914006396587225712622072894642499517624753348170242"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"a481198493e3ccf2c3f56222dd5e23775e8a5494e7432c895d84eeb842db614e354cc76a2aefaefe0c4f102adf5d26e143ab1a660d3c01baa9fe71e111705202"sv); - } - { - Aesi512 m = L"3888054323581165461549688078463844303246388139427588890708643720618740442622042088157116166126246064050854539786541029803760624125631328282953811767140526"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"4a3c69e580d61800890448f3ee1e5dae8d2172c1bfade83ea03e65152f0b26ebd55067e40c33c470f7f980002aca66dd52d8d9d05659cd0e758be77d6fb920ae"sv); - } - { - Aesi512 m = "3568091342093676953587294690406008253945153202098274425394277528003958347284979349929958267931889265818436282821121930911024586015819388216277409542308002"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "442077994abfd02ea4617a3dc3569791453f33cac608329c910b4a70a64f9aa659b34a742bbea3ee1a034eb96e7ea1cd7bb0e0dc91c22da41d0739fce52600a2"sv); - } - { - Aesi512 m = "5361130811079416704606734093446528530539445323334379691474704019417981261887224937037149937955580296693438647055561808981780516345882916352762410137006169"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "665ca95ade4e1112458f423fc3fa1961edd7410d8c55569295d98dadd4d27fbbd3cba081f14f942abd07c37065f827283015888077ac0e04054811259063b059"sv); - } - { - Aesi512 m = L"11012968212320445594391062815119970513271015276915667593639387051669921616757243216765159990514240769349578214964975085308129849580213933952649167912003949"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"d246446db545fbe813df157fcda6243af2aef31e5b3b0cdc476e22ecd049ccbdfd39eb27072c10a1dade13cb8a0487fc9de7bc0cbc3b248759598102a78b696d"sv); - } - { - Aesi512 m = L"9514667255271867328391358295186563552371855346807237362245631509637440261911710822627546808145908270131249958750442770332234414345807208338355370414066842"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"b5aab98ae43aa67946e7c405f70bafc95b3cd54a54fe8767912be8a5ed9ebad9b36f273168f79d060e22c8c2d07ea9ef920fbc5be7bf39e03e57e81722004c9a"sv); - } - { - Aesi512 m = L"2256933445769129968685550995134057623275881711493554511827891968216139469459206552694490274193064357837589535091895882826317588286228277520559674747528750"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"2b17a92fcbe3300536256ffab0de148c37b0ca28626de4c6cd4c11708eda722ee6636b2950622609835237132329259139b0f195af98bb1222908c36856c262e"sv); - } - { - Aesi512 m = "3483457760997999109353593777951251826395047687244505970369674201864733450383249951355116049730791923200813013134129787623591605893206129218355444364129165"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "4282c96f5f5fc3862bed0744a1674f6c976f91027a15eb3edf1b0a006e7e300a169b8134c1466f50f1e98a7703ed718ff649a79af2fae0a3a9f26989cb3cb38d"sv); - } - { - Aesi512 m = L"9154256433672356235353740139345030705570183668595158614844141910697839037630602852234121738605913740683663111227215583046668548354337965132866999988438117"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"aec912c8c5b23675a434961c138c234df030132751e23c5f4faa999df93373079d2dc707bfb194e9dcb314f18dc9c8f481af3ec53785526cc665fb796f42c465"sv); - } - { - Aesi512 m = "6330941527566648902208619994273753065808414550479838590602450171228325205467773207847531954861089886383530758201608751294373625923844946017461179008991712"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "78e0ff616dee5e974af5a5d8745f68df3d9a7a3d13b2a267d27a0c3182e7167932e3ced4e8b7b2d89029b799e4c1e4b6b79d2692749ee745fae60e453638c1e0"sv); - } - { - Aesi512 m = "2039875344269452901450363543457154281710378460125112109492776811495091360393600011420266132020522816757713858930935268157098520454783555503910194788094803"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "26f2b3f6e30735e74d68c9596e44c9f1f8e713ac1e9943828d090afc2be8a28941791dcb309ac32c00b6b4bb331caad2e67e4766480129358995a3881636d353"sv); - } - { - Aesi512 m = "12778827157614903909117920058047765497731672285094817708891945621884947554646951770215319618788264970821446988045546958850054928172780306756860337345132743"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "f3fd9b24907cac2d1f8f1c5259518ee386640617aecc601849de06fb06d09aa6bf2c1757f2128875c82891f5f0442d96fb52fcf0e1b3ff8db1da14069111f8c7"sv); - } - { - Aesi512 m = "3849743788643135634687510197808083840656425659052249808513662221989692105403882045627860913117641546460411192084676324918400414849378035509221951610057120"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "498127d99ac5242f07f7ca9ac590e9a84ce42fe4e5e6f6336bce230559ea49c3e396d18dbb8472ab5b18de6ad81a3250a1339019b4fde24c422970177d7871a0"sv); - } - { - Aesi512 m = L"12366959628737335931923511931395122249309387803533309739113237232803340677332439593853588673692791360520877348495427148148720178935113718777184539799202312"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"ec207081d75292ab0d226f442b08f595591784734a81c99bc47a8e135792c7064e871c3b682fdc3b591cc6ffed6b9c1446b584130f134add990a3d0bb9c02a08"sv); - } - { - Aesi512 m = L"3519766542081340820640288158974503131824466160095513097233356073994139953986332964176135622129598192347130616565618918363619426788131246851373378347801549"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"433442aedcdc97a6cc83a6b2bc4715e084cae19dd007240643cfdcb43b07bfad187126a44ce60a28649e432c8c673b647f4db2b9b96c3319dbde223bd59d1bcd"sv); - } - { - Aesi512 m = L"8527942708856402479767602336273542574277773084261682169358922032862165027228290958175758342351779016146177609269960259961704582609669159548223370673891010"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"a2d3b7357462131e7f845daed3f5764831a956f857efeef2566ef07c0bcc5b2d73cd31ef2cfbf997331d9515d56b6020a85114d3c9585fda07b0d79972d1a6c2"sv); - } - { - Aesi512 m = L"5311688023372823686585240097055906705831895230714971776590612453572543903847287232235823001692377631106474424538927264028067629438642055798153071957431333"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"656afd7fc1caf6a9a3699323bbbcaa39a9d632cec34514e27ec893e495ed2403e5641781ae19b805b0d5f6dd322260cd60d527f6b831e075d45afe6cfc24d425"sv); - } - { - Aesi512 m = L"2335705188903921895745877142997040722979204718187076183470281815428201761961139975775682637745436349451901128253446528066990342912203760117027201875861163"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"2c98b06bd883a87320fc33a85152bee473d1309f4cf1f94d4a7eb4816b0cb612d83281bdd950d1d54d150d69fa9fb1705baf4cc41557bfddf5e1f542369e5eab"sv); - } - { - Aesi512 m = "12625751389070051202659574500975043525162203988864953744797652892591233456338850873926294234645691199443774481621302513104305802813554297752311292949698946"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "f111632334e87f9d8b98b8751c461457c283dee2772f771df773e4416ac6a5d6371e9e9715de564ca61119368c484df2bc4e67da0a5fdca521d63f70e70c1982"sv); - } - { - Aesi512 m = "10920998596476355558113744119311454772840984958851644623254366827927057560225367932003709042925434407732178014438921020601498260808955455701265304440818569"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "d084baab9a91ef15d8e02376b42a74f02699a506228399f91e5b0dda94e210f389d83e8889225aa682cd7bc25f2990252b13015bacc39278cbd96f527e1c4b89"sv); - } - { - Aesi512 m = "1872331687302683627560797270256949687159823933316089458285959650212233479170975260114024476377835191391888669588312216490017368463266858117464484512290076"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "23bfc44327e8d97c87f4e97cd3783238260b471516222755e6cc8e5e5822e0872aa225edc5acb527fe4573b14e45d8617eebcbf9a738cd4ba6c0af91cf7c551c"sv); - } - { - Aesi512 m = L"11381860966986734660739034932592619408500481972740876274154007353266221130396532498212752482697690000566173635035289714959672185796157513467355975151289290"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"d95160a5658534b6b694c4f37eae64f1cef4097512b8e26ccc9f1b0a7eb76d8b26ae5af81698fd86563a9223ae1fccc01d858cfff8a415c9904ad786be1083ca"sv); - } - { - Aesi512 m = L"6320439900703245775830295626561274235362795059541698199057156169577680529381130586349886447907439653586590602655288242132271464419613001027423142617928633"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"78adaaacb0e51e22950e4a7499cc5215595d95d18e59a629d685a202b5e83c6ffb17b50ca02cc968bdff59e47bb03bff1f481fa9c96e845aaa922b4a71e1d3b9"sv); - } - { - Aesi512 m = "4494149576363729299584611434907352457089898026953305851969186889773166562811222998711631287996087422849612012259916815151549901888493311382366656617922394"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "55cef20f0cc8c88a9779fcd37a996e89114857529b12dd945eeed682ab2e1d86ce94905d3953f6c23b30c2e157697b52cef6a292a9038e23405f35951a463f5a"sv); - } - { - Aesi512 m = "7622889572374838690970386521603251089131350851587890100667264937317897478133947339918889436354105515859767123227056195308742424687856401172363685956004394"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "918be877e34b98d17247afa70ac46dc68261e58c269a95737296e390cd0036d274768a71b629f64af324f955aacd7ed69287e26d8a1c7ac9f52b2da65b39aa2a"sv); - } - { - Aesi512 m = L"6673912666225689159533291093119328749809518290290347181883303486722441485538468686671598686934247276305576443925810845993325512546862241276653931816770318"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"7f6d67d471d2231a31171fcc0c909c9dd1f32ff3f2d63691404abc72d5892955532543a896ade3f8502cbe8a09be72bba5bd20e03fecaffe8f1f244bd98b5b0e"sv); - } - { - Aesi512 m = "9761025257714671420389887801229614182686945345448248819075973847035956789496472544188529284946016169818546068173366121913296385097969935850821416445290259"; - const auto size = m.getString<16>(askii.data(), askii.size()); - EXPECT_EQ(std::string_view(askii.data()), "ba5ee5c99ec0dcf34cea5372c2d5a9a6757d3ae558752c880258f3b6b41ef3eb5388990ce3e26126362033a48a48fb5a43bf5e8e240dfc129be57a68f9602713"sv); - } - { - Aesi512 m = L"570358841830362569125541554702233666969906267033685583646740272770310957733386909789247724020449102169588146691839818205789844071065145046141672414951916"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"ae3db1f44457725ace9f27ca7849892fb26e1be28c0e57c0bfa30536ee23811f5d60e358c126f1200bdca880314679f57994f33d9dd3ebdf2afbbe866e6b9ec"sv); - } - { - Aesi512 m = L"11678702983344295281972402696968788500732949323740106366860823669358087271088169777802256212242868639714964758577839343565950262800765286813587550194394092"; - const auto size = m.getString<16>(utf.data(), utf.size()); - EXPECT_EQ(std::wstring_view(utf.data()), L"defc4fa2a8ad010fbe96a6c4a8d1b278bbe5589d2795f7844726d83e320a3c293c9deedb7bc0094cbaa6b29500f106953e4bb427cbcab55cfbf48bc850dc63ec"sv); - } -} - -TEST(Display, ShowBase) { - const auto timeStart = std::chrono::system_clock::now(); - - { - Aesi512 n = "79056762597989804146004589067046304937093448881513449860953244456760618148161"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o12731042536321522576364706361344430446113776630112453326245163550003416046657126460501"); - } - { - Aesi512 n = "18594933181899298433265517019742854658913197818373836569180361992282230178164"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "291c5bf54c9a02a72cde977e1982d7ed12b52122727be35bacd50c2fe1b34174"); - }{ - Aesi512 n = "2317913085896717381524947930838367367064668928052008517510589675940174576938"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o243771067277724546666407141336504515003413055206627255544535575306355443135502636452"); - }{ - Aesi512 n = "83305098496556525845453565524678427749823039072230081807177676254743539951447"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "83305098496556525845453565524678427749823039072230081807177676254743539951447"); - }{ - Aesi512 n = "12220196584962933671403029709390439109117208674440066823854501377572675683467"; - std::stringstream ss {}; ss << std::showbase << std::dec << n; - EXPECT_EQ(ss.str(), "12220196584962933671403029709390439109117208674440066823854501377572675683467"); - }{ - Aesi512 n = "45424609706664613699303415410076013052589128763087051424745112600960001697924"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "646d6b012a54fc924f41bd06996da7777bdacfe2a933d29d02a52e8b8448e884"); - }{ - Aesi512 n = "10515129054495969309508165599265577114638591740969639095415255013369284448456"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o1347726422644277237374366533451703303406367222511572574631241410166317253735052150310"); - }{ - Aesi512 n = "100523596473684404973689356826868622061808775018183292902731605001220182178409"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "100523596473684404973689356826868622061808775018183292902731605001220182178409"); - }{ - Aesi512 n = "45659744421712409468975896620576640611161157797702420283453346422783513979823"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "64f27fe07a72c07d0e47d38471ca41c06419828ff165f731e645042f8c47ebaf"); - }{ - Aesi512 n = "93724686866382014600300632127828180779151363392547753282570211031302238124123"; - std::stringstream ss {}; ss << std::noshowbase << std::oct << n; - EXPECT_EQ(ss.str(), "14746622574765665224443724434265477717463353211536173060656323167746327713705023034133"); - }{ - Aesi512 n = "25944726818172693300152928429954095538891396997034742388090493688142137271086"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "395c31eaeb309bcc26d438f51449170d8dcdf61439317efbc8133118df92232e"); - }{ - Aesi512 n = "81622547550226424321556197100900886316471734978408685002527386564832009208754"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "81622547550226424321556197100900886316471734978408685002527386564832009208754"); - }{ - Aesi512 n = "3101546872990087099834517606115715382842337899664039155983268486752247975263"; - std::stringstream ss {}; ss << std::showbase << std::hex << n; - EXPECT_EQ(ss.str(), "0x6db69cf61207834c1d25af831275c9eca27019f0712e892711db382e97f8d5f"); - }{ - Aesi512 n = "101725527478887864811384267868893051252863700749071041951211672883253722439786"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o16034646731020734004652712741155747712350240347526015255400744223523000027515616660152"); - }{ - Aesi512 n = "55086469877776702305972733411101700737460503569702002402468918780928217075959"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "55086469877776702305972733411101700737460503569702002402468918780928217075959"); - }{ - Aesi512 n = "77280131167710019245201901851829033938628755804158423026804889700491318243482"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "aadb011288319c4b8b3e744655f6b8023f469f5a3a69dc7ed95368df96d3b09a"); - }{ - Aesi512 n = "61827521707418188249838634495183329119277963300552857471958085131131161855550"; - std::stringstream ss {}; ss << std::showbase << std::hex << n; - EXPECT_EQ(ss.str(), "0x88b1231dfd3954bad44e9dcdfd8f306d4419f361d177d9b74fdd636e49d2c63e"); - }{ - Aesi512 n = "67379035864353740936361615896374451168323688900640323729025667269920906371956"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "67379035864353740936361615896374451168323688900640323729025667269920906371956"); - }{ - Aesi512 n = "115762727028071320175075859117694943129952658378440340414920874107338036583991"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "115762727028071320175075859117694943129952658378440340414920874107338036583991"); - }{ - Aesi512 n = "59652679692794315769338348044921784448653627404302233673393742130108525779211"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "83e238603709ca6d8280730d422a0520e9dbad03f647b23aa5e4197d4bf1190b"); - }{ - Aesi512 n = "47161586910663106969474341668330829545151408711833635888706882247367868356409"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "47161586910663106969474341668330829545151408711833635888706882247367868356409"); - }{ - Aesi512 n = "11140120595629123970819831204421380924858251426601671846753538621311449186281"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o1424105333123565740112435267752412552114032037072514617611361156503323632073221437751"); - }{ - Aesi512 n = "33286094299167964527690325649088244240205114924386014937865242618968381974524"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "49974301117f999245a9d20db257bdacd734060ceb7d9e498c9eef86a0b1e7fc"); - }{ - Aesi512 n = "20298285053065762062591056791830179709420524376080562171255208105772940319977"; - std::stringstream ss {}; ss << std::showbase << std::dec << n; - EXPECT_EQ(ss.str(), "20298285053065762062591056791830179709420524376080562171255208105772940319977"); - }{ - Aesi512 n = "84349252021396369246885706739889238177033117235595657734601613861472550655702"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o13517377016011253756166243537026234052762567614163172153151315315546577326706614413326"); - }{ - Aesi512 n = "94297964831265586835296782183187536813336204385154223737511664185935388840167"; - std::stringstream ss {}; ss << std::showbase << std::hex << n; - EXPECT_EQ(ss.str(), "0xd07ac1b77e8eae741b6310689961fef0ee6833b46c46b39d179d5b3cf1e590e7"); - }{ - Aesi512 n = "110195754734711441388137785763342914055120496632000503178863843283423718938365"; - std::stringstream ss {}; ss << std::noshowbase << std::dec << n; - EXPECT_EQ(ss.str(), "110195754734711441388137785763342914055120496632000503178863843283423718938365"); - }{ - Aesi512 n = "15025855122314054627350553219310071736920574861504400551524735534340673514442"; - std::stringstream ss {}; ss << std::showbase << std::dec << n; - EXPECT_EQ(ss.str(), "15025855122314054627350553219310071736920574861504400551524735534340673514442"); - }{ - Aesi512 n = "104171137225462488494794669001950775716589623006488234763007122769955013504759"; - std::stringstream ss {}; ss << std::noshowbase << std::hex << n; - EXPECT_EQ(ss.str(), "e64ec635353831061e6c77628962b1fcd753d7dcf2ba8aa6dd4ade3aaa47aef7"); - }{ - Aesi512 n = "88253257261520124245440073923723654282896981850995807297624218555957154341516"; - std::stringstream ss {}; ss << std::showbase << std::oct << n; - EXPECT_EQ(ss.str(), "0o14143544547206566717156716503762441076677376475744517604677342734205717775707006561214"); - } - -#ifdef NDEBUG - Logging::addRecord("Display", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} diff --git a/test/operations/display/signed.cpp b/test/operations/display/signed.cpp new file mode 100755 index 0000000..e409d62 --- /dev/null +++ b/test/operations/display/signed.cpp @@ -0,0 +1,437 @@ +#include +#include + +#ifndef AESI_CRYPTOPP_INTEGRATION +#define AESI_CRYPTOPP_INTEGRATION +#endif +#include "../../../Aesi.h" +#include "../../generation.h" + +/* Output tester for zero values */ +TEST(Signed_Display, Zero) { + Aesi128 m = 0u; + + { std::stringstream ss1{}; ss1 << m << +m; EXPECT_EQ(ss1.str(), "00"); } + { std::stringstream ss2{}; ss2 << std::dec << m << +m; EXPECT_EQ(ss2.str(), "00"); } + { std::stringstream ss3{}; ss3 << std::oct << m << +m; EXPECT_EQ(ss3.str(), "00"); } + { std::stringstream ss4{}; ss4 << std::hex << m << +m; EXPECT_EQ(ss4.str(), "00"); } + { std::stringstream ss5{}; m = 8u; ss5 << m - 8u << +(m - 8u); m -= 8u; ss5 << m; EXPECT_EQ(ss5.str(), "000"); } + + { + m = 0u; + using namespace std::string_view_literals; + + std::array askii{}; + std::array utf{}; + auto size = m.getString<10>(askii.data(), 10, false); + EXPECT_EQ(std::string_view(askii.data()), "0"sv); + + askii = {}; + size = m.getString<2>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0b0"sv); + + askii = {}; + size = m.getString<8>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0o0"sv); + + askii = {}; + size = m.getString<10>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0"sv); + + askii = {}; + size = m.getString<16>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0x0"sv); + + size = m.getString<10>(utf.data(), 10); + EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); + + utf = {}; + size = m.getString<2>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0b0"sv); + + utf = {}; + size = m.getString<8>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0o0"sv); + + utf = {}; + size = m.getString<10>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); + + utf = {}; + size = m.getString<16>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0x0"sv); + } +} + +/* Output tester for std::streams and std::wstreams with decimal notation */ +TEST(Signed_Display, DecimalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi Aesi = value; + + std::stringstream ss, ss2; ss << std::dec << std::noshowbase << value; + ss2 << std::dec << std::noshowbase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi Aesi = value; + + std::stringstream ss; ss << std::dec << std::noshowbase << value; + std::wstringstream ss2; ss2 << std::dec << std::noshowbase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for std::streams and std::wstreams with octal notation */ +TEST(Signed_Display, OctalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi aesi = value; + + std::stringstream ss, ss2; ss << std::oct << std::noshowbase << value; + ss2 << std::oct << std::noshowbase << aesi; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi Aesi = value; + + std::stringstream ss; ss << std::oct << std::noshowbase << value; + std::wstringstream ss2; ss2 << std::oct << std::noshowbase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for std::streams and std::wstreams with hexadecimal notation */ +TEST(Signed_Display, HexadecimalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi Aesi = value; + + std::stringstream ss, ss2; ss << std::hex << std::noshowbase << value; + ss2 << std::hex << std::noshowbase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aesi Aesi = value; + + std::stringstream ss; ss << std::hex << std::noshowbase << value; + std::wstringstream ss2; ss2 << std::hex << std::noshowbase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for ASKII c-style arrays with different notations + * Generates: + * - ASKII Octal + * - ASKII Hexadecimal, lowercase + * - ASKII Hexadecimal, uppercase + * - ASKII Decimal + * - ASKII Binary + * */ +TEST(Signed_Display, FormatAskii) { + constexpr auto testsAmount = 20, blocksNumber = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array askii {}; + + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + const Aesi Aesi = value; + + switch(i % 5) { + case 0: { /* Octal */ + ss << std::oct << std::noshowbase << value; + const auto size = Aesi.getString<8>(askii.data(), askii.size(), false); + break; + } + case 1: { /* Hexadecimal, lowercase */ + ss << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = Aesi.getString<16>(askii.data(), askii.size(), false, false); + break; + } + case 2: { /* Hexadecimal, uppercase */ + ss << std::hex << std::noshowbase << std::uppercase << value; + const auto size = Aesi.getString<16>(askii.data(), askii.size(), false, true); + break; + } + case 3: { /* Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = Aesi.getString<10>(askii.data(), askii.size(), false); + break; + } + default: { /* Binary */ + ss << (i % 2 == 0 ? "" : "-"); + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for(long long j = value.ByteCount() - 2; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + Aesi.getString<2>(askii.data(), askii.size(), false); + } + } + + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + } +} + +/* Output tester for UTF c-style arrays with different notations + * Generates: + * - UTF Octal + * - UTF Hexadecimal, lowercase + * - UTF Hexadecimal, uppercase + * - UTF Decimal + * - UTF Binary + * */ +TEST(Signed_Display, FormatUtf) { + constexpr auto testsAmount = 20, blocksNumber = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array utf{}; + + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + const Aesi Aesi = value; + + switch (i % 5) { + case 0: { /* Octal */ + ss << std::oct << std::noshowbase << value; + const auto size = Aesi.getString<8>(utf.data(), utf.size(), false); + break; + } + case 1: { /* Hexadecimal, lowercase */ + ss << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = Aesi.getString<16>(utf.data(), utf.size(), false, false); + break; + } + case 2: { /* Hexadecimal, uppercase */ + ss << std::hex << std::noshowbase << std::uppercase << value; + const auto size = Aesi.getString<16>(utf.data(), utf.size(), false, true); + break; + } + case 3: { /* Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = Aesi.getString<10>(utf.data(), utf.size(), false); + break; + } + default: { /* Binary */ + ss << (i % 2 == 0 ? "" : "-"); + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for (long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + Aesi.getString<2>(utf.data(), utf.size(), false); + } + } + + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + } +} + +/* Output tester for SHOWBASE option for ASKII + * Generates: + * - Std::streams octal + * - Std::streams hexadecimal, lowercase + * - Std::streams hexadecimal, uppercase + * - Std::streams decimal + * + * - C-style ASKII Octal + * - C-style ASKII Hexadecimal, lowercase + * - C-style ASKII Hexadecimal, uppercase + * - C-style ASKII Decimal + * - C-style ASKII Binary + * */ +TEST(Signed_Display, ShowBaseAskii) { + constexpr auto testsAmount = 36, blocksNumber = 2; + for (std::size_t i = 8; i < testsAmount; ++i) { + static std::array askii {}; + + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss, ss2; + const Aesi Aesi = value; + + switch (i % 9) { + case 0: { /* Std::streams octal */ + ss << (i % 2 == 0 ? "0o" : "-0o") << std::oct << std::noshowbase << (i % 2 == 0 ? value : value * -1); + ss2 << std::oct << std::showbase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 1: { /* Std::streams hexadecimal, lowercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + ss2 << std::hex << std::showbase << std::nouppercase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 2: { /* Std::streams hexadecimal, uppercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::uppercase << (i % 2 == 0 ? value : value * -1); + ss2 << std::hex << std::showbase << std::uppercase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 3: { /* Std::streams decimal */ + ss << std::dec << value; + ss2 << std::dec << std::showbase << Aesi; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 4: { /* C-style ASKII Octal */ + ss << (i % 2 == 0 ? "0o" : "-0o") << std::oct << std::noshowbase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<8>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 5: { /* C-style ASKII Hexadecimal, lowercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<16>(askii.data(), askii.size(), true, false); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 6: { /* C-style ASKII Hexadecimal, uppercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<16>(askii.data(), askii.size(), true, false); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 7: { /* C-style ASKII Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = Aesi.getString<10>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + default: { /* C-style ASKII Binary */ + ss << (i % 2 == 0 ? "0b" : "-0b"); + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for(long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + Aesi.getString<2>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + } + } + } +} + +/* Output tester for SHOWBASE option for UTF + * Generates: + * - Std::Wstreams octal + * - Std::Wstreams hexadecimal, lowercase + * - Std::Wstreams hexadecimal, uppercase + * - Std::Wstreams decimal + * + * - C-style UTF Octal + * - C-style UTF Hexadecimal, lowercase + * - C-style UTF Hexadecimal, uppercase + * - C-style UTF Decimal + * - C-style UTF Binary + * */ +TEST(Signed_Display, ShowBaseUtf) { + constexpr auto testsAmount = 36, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array utf {}; + + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + std::wstringstream ss2; + const Aesi Aesi = value; + + switch (i % 9) { + case 0: { /* Std::streams octal */ + ss << (i % 2 == 0 ? "0o" : "-0o") << std::oct << std::noshowbase << (i % 2 == 0 ? value : value * -1); + ss2 << std::oct << std::showbase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 1: { /* Std::streams hexadecimal, lowercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + ss2 << std::hex << std::showbase << std::nouppercase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 2: { /* Std::streams hexadecimal, uppercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::uppercase << (i % 2 == 0 ? value : value * -1); + ss2 << std::hex << std::showbase << std::uppercase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 3: { /* Std::streams decimal */ + ss << std::dec << value; + ss2 << std::dec << std::showbase << Aesi; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 4: { /* C-style ASKII Octal */ + ss << (i % 2 == 0 ? "0o" : "-0o") << std::oct << std::noshowbase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<8>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 5: { /* C-style ASKII Hexadecimal, lowercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<16>(utf.data(), utf.size(), true, false); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 6: { /* C-style ASKII Hexadecimal, uppercase */ + ss << (i % 2 == 0 ? "0x" : "-0x") << std::hex << std::noshowbase << std::nouppercase << (i % 2 == 0 ? value : value * -1); + const auto size = Aesi.getString<16>(utf.data(), utf.size(), true, false); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 7: { /* C-style ASKII Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = Aesi.getString<10>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + default: { /* C-style ASKII Binary */ + ss << (i % 2 == 0 ? "0b" : "-0b"); + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for(long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + Aesi.getString<2>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + } + } + } +} diff --git a/test/operations/display/unsigned.cpp b/test/operations/display/unsigned.cpp new file mode 100755 index 0000000..27c1597 --- /dev/null +++ b/test/operations/display/unsigned.cpp @@ -0,0 +1,433 @@ +#include +#include + +#ifndef AESI_CRYPTOPP_INTEGRATION +#define AESI_CRYPTOPP_INTEGRATION +#endif +#include "../../../Aeu.h" +#include "../../generation.h" + +/* Output tester for zero values */ +TEST(Unsigned_Display, Zero) { + Aeu128 m = 0u; + + { std::stringstream ss1{}; ss1 << m << +m; EXPECT_EQ(ss1.str(), "00"); } + { std::stringstream ss2{}; ss2 << std::dec << m << +m; EXPECT_EQ(ss2.str(), "00"); } + { std::stringstream ss3{}; ss3 << std::oct << m << +m; EXPECT_EQ(ss3.str(), "00"); } + { std::stringstream ss4{}; ss4 << std::hex << m << +m; EXPECT_EQ(ss4.str(), "00"); } + { std::stringstream ss5{}; m = 8u; ss5 << m - 8u << +(m - 8u); m -= 8u; ss5 << m; EXPECT_EQ(ss5.str(), "000"); } + + { + m = 0u; + using namespace std::string_view_literals; + + std::array askii{}; + std::array utf{}; + auto size = m.getString<10>(askii.data(), 10, false); + EXPECT_EQ(std::string_view(askii.data()), "0"sv); + + askii = {}; + size = m.getString<2>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0b0"sv); + + askii = {}; + size = m.getString<8>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0o0"sv); + + askii = {}; + size = m.getString<10>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0"sv); + + askii = {}; + size = m.getString<16>(askii.data(), 10, true); + EXPECT_EQ(std::string_view(askii.data()), "0x0"sv); + + size = m.getString<10>(utf.data(), 10); + EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); + + utf = {}; + size = m.getString<2>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0b0"sv); + + utf = {}; + size = m.getString<8>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0o0"sv); + + utf = {}; + size = m.getString<10>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0"sv); + + utf = {}; + size = m.getString<16>(utf.data(), 10, true); + EXPECT_EQ(std::wstring_view(utf.data()), L"0x0"sv); + } +} + +/* Output tester for std::streams and std::wstreams with decimal notation */ +TEST(Unsigned_Display, DecimalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss, ss2; ss << std::dec << std::noshowbase << value; + ss2 << std::dec << std::noshowbase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss; ss << std::dec << std::noshowbase << value; + std::wstringstream ss2; ss2 << std::dec << std::noshowbase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for std::streams and std::wstreams with octal notation */ +TEST(Unsigned_Display, OctalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss, ss2; ss << "0o" << std::oct << std::noshowbase << value; + ss2 << "0o" << std::oct << std::noshowbase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss; ss << "0o" << std::oct << std::noshowbase << value; + std::wstringstream ss2; ss2 << "0o" << std::oct << std::noshowbase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for std::streams and std::wstreams with hexadecimal notation */ +TEST(Unsigned_Display, HexadecimalStreams) { + constexpr auto testsAmount = 30, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss, ss2; ss << "0x" << std::hex << std::noshowbase << value; + ss2 << "0x" << std::hex << std::noshowbase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + } + + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + const Aeu aeu = value; + + std::stringstream ss; ss << "0x" << std::hex << std::noshowbase << value; + std::wstringstream ss2; ss2 << "0x" << std::hex << std::noshowbase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + } +} + +/* Output tester for ASKII c-style arrays with different notations + * Generates: + * - ASKII Octal + * - ASKII Hexadecimal, lowercase + * - ASKII Hexadecimal, uppercase + * - ASKII Decimal + * - ASKII Binary + * */ +TEST(Unsigned_Display, FormatAskii) { + constexpr auto testsAmount = 20, blocksNumber = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array askii {}; + + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + const Aeu aeu = value; + + switch(i % 5) { + case 0: { /* Octal */ + ss << std::oct << std::noshowbase << value; + const auto size = aeu.getString<8>(askii.data(), askii.size(), false); + break; + } + case 1: { /* Hexadecimal, lowercase */ + ss << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(askii.data(), askii.size(), false, false); + break; + } + case 2: { /* Hexadecimal, uppercase */ + ss << std::hex << std::noshowbase << std::uppercase << value; + const auto size = aeu.getString<16>(askii.data(), askii.size(), false, true); + break; + } + case 3: { /* Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = aeu.getString<10>(askii.data(), askii.size(), false); + break; + } + default: { /* Binary */ + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for(long long j = value.ByteCount() - 2; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + aeu.getString<2>(askii.data(), askii.size(), false); + } + } + + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + } +} + +/* Output tester for UTF c-style arrays with different notations + * Generates: + * - UTF Octal + * - UTF Hexadecimal, lowercase + * - UTF Hexadecimal, uppercase + * - UTF Decimal + * - UTF Binary + * */ +TEST(Unsigned_Display, FormatUtf) { + constexpr auto testsAmount = 20, blocksNumber = 2; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array utf{}; + + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + const Aeu aeu = value; + + switch (i % 5) { + case 0: { /* Octal */ + ss << std::oct << std::noshowbase << value; + const auto size = aeu.getString<8>(utf.data(), utf.size(), false); + break; + } + case 1: { /* Hexadecimal, lowercase */ + ss << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(utf.data(), utf.size(), false, false); + break; + } + case 2: { /* Hexadecimal, uppercase */ + ss << std::hex << std::noshowbase << std::uppercase << value; + const auto size = aeu.getString<16>(utf.data(), utf.size(), false, true); + break; + } + case 3: { /* Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = aeu.getString<10>(utf.data(), utf.size(), false); + break; + } + default: { /* Binary */ + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << std::string(binary.rbegin(), binary.rend()); + for (long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + aeu.getString<2>(utf.data(), utf.size(), false); + } + } + + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + } +} + +/* Output tester for SHOWBASE option for ASKII + * Generates: + * - Std::streams octal + * - Std::streams hexadecimal, lowercase + * - Std::streams hexadecimal, uppercase + * - Std::streams decimal + * + * - C-style ASKII Octal + * - C-style ASKII Hexadecimal, lowercase + * - C-style ASKII Hexadecimal, uppercase + * - C-style ASKII Decimal + * - C-style ASKII Binary + * */ +TEST(Unsigned_Display, ShowBaseAskii) { + constexpr auto testsAmount = 36, blocksNumber = 2; + for (std::size_t i = 8; i < testsAmount; ++i) { + static std::array askii {}; + + const auto value = CryptoPP::Integer(0b101100111111000100111010010010);//Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss, ss2; + const Aeu aeu = value; + + switch (i % 9) { + case 0: { /* Std::streams octal */ + ss << "0o" << std::oct << std::noshowbase << value; + ss2 << std::oct << std::showbase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 1: { /* Std::streams hexadecimal, lowercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + ss2 << std::hex << std::showbase << std::nouppercase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 2: { /* Std::streams hexadecimal, uppercase */ + ss << "0x" << std::hex << std::noshowbase << std::uppercase << value; + ss2 << std::hex << std::showbase << std::uppercase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 3: { /* Std::streams decimal */ + ss << std::dec << value; + ss2 << std::dec << std::showbase << aeu; + EXPECT_EQ(ss2.str(), ss.str()); + break; + } + case 4: { /* C-style ASKII Octal */ + ss << "0o" << std::oct << std::noshowbase << value; + const auto size = aeu.getString<8>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 5: { /* C-style ASKII Hexadecimal, lowercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(askii.data(), askii.size(), true, false); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 6: { /* C-style ASKII Hexadecimal, uppercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(askii.data(), askii.size(), true, false); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + case 7: { /* C-style ASKII Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = aeu.getString<10>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + break; + } + default: { /* C-style ASKII Binary */ + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << "0b" << std::string(binary.rbegin(), binary.rend()); + for(long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + aeu.getString<2>(askii.data(), askii.size(), true); + EXPECT_EQ(std::string_view(askii.data()), ss.str()); + } + } + } +} + +/* Output tester for SHOWBASE option for UTF + * Generates: + * - Std::Wstreams octal + * - Std::Wstreams hexadecimal, lowercase + * - Std::Wstreams hexadecimal, uppercase + * - Std::Wstreams decimal + * + * - C-style UTF Octal + * - C-style UTF Hexadecimal, lowercase + * - C-style UTF Hexadecimal, uppercase + * - C-style UTF Decimal + * - C-style UTF Binary + * */ +TEST(Unsigned_Display, ShowBaseUtf) { + constexpr auto testsAmount = 36, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + static std::array utf {}; + + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 32); + std::stringstream ss; + std::wstringstream ss2; + const Aeu aeu = value; + + switch (i % 9) { + case 0: { /* Std::streams octal */ + ss << "0o" << std::oct << std::noshowbase << value; + ss2 << std::oct << std::showbase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 1: { /* Std::streams hexadecimal, lowercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + ss2 << std::hex << std::showbase << std::nouppercase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 2: { /* Std::streams hexadecimal, uppercase */ + ss << "0x" << std::hex << std::noshowbase << std::uppercase << value; + ss2 << std::hex << std::showbase << std::uppercase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 3: { /* Std::streams decimal */ + ss << std::dec << value; + ss2 << std::dec << std::showbase << aeu; + const auto& ref = ss.str(); + std::wstring wstring (ref.begin(), ref.end()); + EXPECT_EQ(ss2.str(), wstring); + break; + } + case 4: { /* C-style ASKII Octal */ + ss << "0o" << std::oct << std::noshowbase << value; + const auto size = aeu.getString<8>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 5: { /* C-style ASKII Hexadecimal, lowercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(utf.data(), utf.size(), true, false); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 6: { /* C-style ASKII Hexadecimal, uppercase */ + ss << "0x" << std::hex << std::noshowbase << std::nouppercase << value; + const auto size = aeu.getString<16>(utf.data(), utf.size(), true, false); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + case 7: { /* C-style ASKII Decimal */ + ss << std::dec << std::noshowbase << value; + const auto size = aeu.getString<10>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + break; + } + default: { /* C-style ASKII Binary */ + std::string binary {}; + for (auto byte = value.GetByte((value.BitCount() - 1) / 8); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << "0b" << std::string(binary.rbegin(), binary.rend()); + for(long long j = (value.BitCount() - 1) / 8 - 1; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + aeu.getString<2>(utf.data(), utf.size(), true); + const auto &ref = ss.str(); + const std::wstring comparative(ref.begin(), ref.end()); + EXPECT_EQ(std::wstring_view(utf.data()), comparative); + } + } + } +} diff --git a/test/operations/initialization/cryptopp-integration.cpp b/test/operations/initialization/cryptopp-integration.cpp new file mode 100755 index 0000000..3e8ee66 --- /dev/null +++ b/test/operations/initialization/cryptopp-integration.cpp @@ -0,0 +1,30 @@ +#ifndef AESI_CRYPTOPP_INTEGRATION +#define AESI_CRYPTOPP_INTEGRATION +#endif + +#include +#include <../../../../Aesi.h> +#include <../../../../Aeu.h> +#include "../../generation.h" + +TEST(Signed_Initialization, CryptoPP) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto cryptopp = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + const Aesi aeu = cryptopp; + + std::stringstream ss, ss2; ss << cryptopp; ss2 << aeu; + EXPECT_EQ(ss.str(), ss2.str()); + } +} + +TEST(Unsigned_Initialization, CryptoPP) { + constexpr auto testsAmount = 256, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto cryptopp = Generation::getRandomWithBits(blocksNumber * 32 - 20); + const Aeu aeu = cryptopp; + + std::stringstream ss, ss2; ss << cryptopp; ss2 << aeu; + EXPECT_EQ(ss.str(), ss2.str()); + } +} \ No newline at end of file diff --git a/test/operations/initialization/gmp-integration.cpp b/test/operations/initialization/gmp-integration.cpp new file mode 100755 index 0000000..0593fbf --- /dev/null +++ b/test/operations/initialization/gmp-integration.cpp @@ -0,0 +1,30 @@ +#ifndef AESI_GMP_INTEGRATION +#define AESI_GMP_INTEGRATION +#endif + +#include +#include <../../../../Aesi.h> +#include <../../../../Aeu.h> +#include "../../generation.h" + +TEST(Signed_Initialization, GMP) { + constexpr auto testsAmount = 2, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const mpz_class gmp = Generation::getRandom(blocksNumber * 32 - 20) * (i % 2 == 0 ? 1 : -1); + const Aesi aeu = gmp; + + std::stringstream ss; ss << aeu; + EXPECT_EQ(ss.str(), gmp.get_str()); + } +} + +TEST(Unsigned_Initialization, GMP) { + constexpr auto testsAmount = 256, blocksNumber = 64; + for (std::size_t i = 0; i < testsAmount; ++i) { + const mpz_class gmp = Generation::getRandom(blocksNumber * 32 - 20); + const Aeu aeu = gmp; + + std::stringstream ss; ss << aeu; + EXPECT_EQ(ss.str(), gmp.get_str()); + } +} \ No newline at end of file diff --git a/test/operations/initialization/signed.cpp b/test/operations/initialization/signed.cpp new file mode 100755 index 0000000..34fbf82 --- /dev/null +++ b/test/operations/initialization/signed.cpp @@ -0,0 +1,189 @@ +#include +#include +#include "../../../Aesi.h" +#include "../../generation.h" + +TEST(Signed_Initialization, Basic) { + { + Aesi128 m0 {}, + m1(0), + m2 = 0, + m3 = Aesi128(0), + m4 = {}, + m5 = "0", + m6 = "-0", + m7 = "Somebody once told me...", + m8 = Aesi128(), + m9; + EXPECT_EQ(m0, 0); EXPECT_EQ(m1, 0); EXPECT_EQ(m2, 0); EXPECT_EQ(m3, 0); + EXPECT_EQ(m4, 0); EXPECT_EQ(m5, 0); EXPECT_EQ(m6, 0); EXPECT_EQ(m7, 0); EXPECT_EQ(m8, 0); + } + { + Aesi128 i01 = 1, i02 = -1, i03 = 127, i04 = -127, i05 = -128, i06 = +127; + EXPECT_EQ(i01, 1); EXPECT_EQ(i02, -1); EXPECT_EQ(i03, 127); + EXPECT_EQ(i04, -127); EXPECT_EQ(i05, -128); EXPECT_EQ(i06, 127); + } + { + Aesi128 ten = "10", negTen = "-10", fifty = "50", negFifty = "-50"; + EXPECT_EQ(ten, 10); EXPECT_EQ(negTen, -10); EXPECT_EQ(fifty, 50); EXPECT_EQ(negFifty, -50); + + Aesi128 octTenLC = "0o24", octTenHC = "0o24", negativeOctTenLC = "-0o24", negativeOctTenHC = "-0o24"; + EXPECT_EQ(octTenLC, 20); EXPECT_EQ(octTenHC, 20); EXPECT_EQ(negativeOctTenLC, -20); EXPECT_EQ(negativeOctTenHC, -20); + + Aesi128 hexTenLC = "0xa", hexTenHC = "0xA", negativeHexTenLC = "-0xa", negativeHexTenHC = "-0xA"; + EXPECT_EQ(hexTenLC, 10); EXPECT_EQ(hexTenHC, 10); EXPECT_EQ(negativeHexTenLC, -10); EXPECT_EQ(negativeHexTenHC, -10); + } + { + using namespace std::string_literals; using namespace std::string_view_literals; + Aesi512 d0 = "489133282872437279"s, d1 = "63018038201"sv, d2 = "-489133282872437279"s, d3 = "-63018038201"sv; + EXPECT_EQ(d0, 489133282872437279); EXPECT_EQ(d1, 63018038201); EXPECT_EQ(d2, -489133282872437279); EXPECT_EQ(d3, -63018038201); + + Aesi512 b0 = "0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279); + Aesi512 b1 = "0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201); + Aesi512 b2 = "-0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b2, -489133282872437279); + Aesi512 b3 = "-0b111010101100001010101111001110111001"sv; EXPECT_EQ(b3, -63018038201); + + Aesi512 o0 = "0o106274176273174613"s, o1 = "0o642054234601645202742"sv, o2 = "-0o106274176273174613"s, o3 = "-0o642054234601645202742"sv; + EXPECT_EQ(o0, 2475842268363147); EXPECT_EQ(o1, 7531577461358003682); EXPECT_EQ(o2, -2475842268363147); EXPECT_EQ(o3, -7531577461358003682); + + Aesi512 h0 = "0x688589CC0E9505E2"s, h1 = "0x3C9D4B9CB52FE"sv, h2 = "-0x688589CC0E9505E2"s, h3 = "-0x3C9D4B9CB52FE"sv; + EXPECT_EQ(h0, 7531577461358003682); EXPECT_EQ(h1, 1066340417491710); EXPECT_EQ(h2, -7531577461358003682); EXPECT_EQ(h3, -1066340417491710); + Aesi512 h4 = "0x688589cc0e9505e2"s, h5 = "0x3c9d4b9cb52fe"sv, h6 = "-0x688589cc0e9505e2"s, h7 = "-0x3c9d4b9cb52fe"sv; + EXPECT_EQ(h4, 7531577461358003682); EXPECT_EQ(h5, 1066340417491710); EXPECT_EQ(h6, -7531577461358003682); EXPECT_EQ(h7, -1066340417491710); + + d0 = L"489133282872437279"s, d1 = L"63018038201"sv, d2 = L"-489133282872437279"s, d3 = L"-63018038201"sv; + EXPECT_EQ(d0, 489133282872437279); EXPECT_EQ(d1, 63018038201); EXPECT_EQ(d2, -489133282872437279); EXPECT_EQ(d3, -63018038201); + + b0 = L"0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279); + b1 = L"0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201); + b2 = L"-0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b2, -489133282872437279); + b3 = L"-0b111010101100001010101111001110111001"sv; EXPECT_EQ(b3, -63018038201); + + b0 = L"-0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"--0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"---0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"----0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"-----0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"-------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"--------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"---------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"----------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"-----------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"-------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"--------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"---------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"----------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + b0 = L"-----------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); + b0 = L"------------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); + + o0 = L"0o106274176273174613"s, o1 = L"0o642054234601645202742"sv, o2 = L"-0o106274176273174613"s, o3 = L"-0o642054234601645202742"sv; + EXPECT_EQ(o0, 2475842268363147); EXPECT_EQ(o1, 7531577461358003682); EXPECT_EQ(o2, -2475842268363147); EXPECT_EQ(o3, -7531577461358003682); + + h0 = L"0x688589CC0E9505E2"s, h1 = L"0x3C9D4B9CB52FE"sv, h2 = L"-0x688589CC0E9505E2"s, h3 = L"-0x3C9D4B9CB52FE"sv; + EXPECT_EQ(h0, 7531577461358003682); EXPECT_EQ(h1, 1066340417491710); EXPECT_EQ(h2, -7531577461358003682); EXPECT_EQ(h3, -1066340417491710); + h4 = L"0x688589cc0e9505e2"s, h5 = L"0x3c9d4b9cb52fe"sv, h6 = L"-0x688589cc0e9505e2"s, h7 = L"-0x3c9d4b9cb52fe"sv; + EXPECT_EQ(h4, 7531577461358003682); EXPECT_EQ(h5, 1066340417491710); EXPECT_EQ(h6, -7531577461358003682); EXPECT_EQ(h7, -1066340417491710); + } +} + +TEST(Signed_Initialization, Different_precisions) { + { + uint64_t iValue0 = 3218136187561313218u; + Aesi < 96 > o00 = iValue0; + Aesi < 96 > o01 = iValue0; + + Aesi < 128 > o02 = iValue0; Aesi < 160 > o03 = iValue0; Aesi < 192 > o04 = iValue0; Aesi < 224 > o05 = iValue0; Aesi < 256 > o06 = iValue0; Aesi < 288 > o07 = iValue0; Aesi < 320 > o08 = iValue0; Aesi < 352 > o09 = iValue0; + Aesi < 384 > o010 = iValue0; Aesi < 416 > o011 = iValue0; Aesi < 448 > o012 = iValue0; Aesi < 480 > o013 = iValue0; Aesi < 512 > o014 = iValue0; Aesi < 544 > o015 = iValue0; Aesi < 576 > o016 = iValue0; Aesi < 608 > o017 = iValue0; Aesi < 640 > o018 = iValue0; + Aesi < 672 > o019 = iValue0; Aesi < 704 > o020 = iValue0; Aesi < 736 > o021 = iValue0; Aesi < 768 > o022 = iValue0; Aesi < 800 > o023 = iValue0; Aesi < 832 > o024 = iValue0; Aesi < 864 > o025 = iValue0; Aesi < 896 > o026 = iValue0; Aesi < 928 > o027 = iValue0; + Aesi < 960 > o028 = iValue0; Aesi < 992 > o029 = iValue0; Aesi < 1024 > o030 = iValue0; Aesi < 1056 > o031 = iValue0; Aesi < 1088 > o032 = iValue0; Aesi < 1120 > o033 = iValue0; Aesi < 1152 > o034 = iValue0; Aesi < 1184 > o035 = iValue0; Aesi < 1216 > o036 = iValue0; + Aesi < 1248 > o037 = iValue0; Aesi < 1280 > o038 = iValue0; Aesi < 1312 > o039 = iValue0; + + EXPECT_EQ(o00, iValue0); + EXPECT_EQ(o01, iValue0); EXPECT_EQ(o02, iValue0); EXPECT_EQ(o03, iValue0); EXPECT_EQ(o04, iValue0); EXPECT_EQ(o05, iValue0); EXPECT_EQ(o06, iValue0); EXPECT_EQ(o07, iValue0); EXPECT_EQ(o08, iValue0); EXPECT_EQ(o09, iValue0); + EXPECT_EQ(o010, iValue0); EXPECT_EQ(o011, iValue0); EXPECT_EQ(o012, iValue0); EXPECT_EQ(o013, iValue0); EXPECT_EQ(o014, iValue0); EXPECT_EQ(o015, iValue0); EXPECT_EQ(o016, iValue0); EXPECT_EQ(o017, iValue0); EXPECT_EQ(o018, iValue0); + EXPECT_EQ(o019, iValue0); EXPECT_EQ(o020, iValue0); EXPECT_EQ(o021, iValue0); EXPECT_EQ(o022, iValue0); EXPECT_EQ(o023, iValue0); EXPECT_EQ(o024, iValue0); EXPECT_EQ(o025, iValue0); EXPECT_EQ(o026, iValue0); EXPECT_EQ(o027, iValue0); + EXPECT_EQ(o028, iValue0); EXPECT_EQ(o029, iValue0); EXPECT_EQ(o030, iValue0); EXPECT_EQ(o031, iValue0); EXPECT_EQ(o032, iValue0); EXPECT_EQ(o033, iValue0); EXPECT_EQ(o034, iValue0); EXPECT_EQ(o035, iValue0); EXPECT_EQ(o036, iValue0); + EXPECT_EQ(o037, iValue0); EXPECT_EQ(o038, iValue0); EXPECT_EQ(o039, iValue0); + } + { + uint64_t iValue0 = -3218136187561313218u; + Aesi < 96 > o00 = iValue0; + Aesi < 96 > o01 = iValue0; + + Aesi < 128 > o02 = iValue0; Aesi < 160 > o03 = iValue0; Aesi < 192 > o04 = iValue0; Aesi < 224 > o05 = iValue0; Aesi < 256 > o06 = iValue0; Aesi < 288 > o07 = iValue0; Aesi < 320 > o08 = iValue0; Aesi < 352 > o09 = iValue0; + Aesi < 384 > o010 = iValue0; Aesi < 416 > o011 = iValue0; Aesi < 448 > o012 = iValue0; Aesi < 480 > o013 = iValue0; Aesi < 512 > o014 = iValue0; Aesi < 544 > o015 = iValue0; Aesi < 576 > o016 = iValue0; Aesi < 608 > o017 = iValue0; Aesi < 640 > o018 = iValue0; + Aesi < 672 > o019 = iValue0; Aesi < 704 > o020 = iValue0; Aesi < 736 > o021 = iValue0; Aesi < 768 > o022 = iValue0; Aesi < 800 > o023 = iValue0; Aesi < 832 > o024 = iValue0; Aesi < 864 > o025 = iValue0; Aesi < 896 > o026 = iValue0; Aesi < 928 > o027 = iValue0; + Aesi < 960 > o028 = iValue0; Aesi < 992 > o029 = iValue0; Aesi < 1024 > o030 = iValue0; Aesi < 1056 > o031 = iValue0; Aesi < 1088 > o032 = iValue0; Aesi < 1120 > o033 = iValue0; Aesi < 1152 > o034 = iValue0; Aesi < 1184 > o035 = iValue0; Aesi < 1216 > o036 = iValue0; + Aesi < 1248 > o037 = iValue0; Aesi < 1280 > o038 = iValue0; Aesi < 1312 > o039 = iValue0; + + EXPECT_EQ(o00, iValue0); + EXPECT_EQ(o01, iValue0); EXPECT_EQ(o02, iValue0); EXPECT_EQ(o03, iValue0); EXPECT_EQ(o04, iValue0); EXPECT_EQ(o05, iValue0); EXPECT_EQ(o06, iValue0); EXPECT_EQ(o07, iValue0); EXPECT_EQ(o08, iValue0); EXPECT_EQ(o09, iValue0); + EXPECT_EQ(o010, iValue0); EXPECT_EQ(o011, iValue0); EXPECT_EQ(o012, iValue0); EXPECT_EQ(o013, iValue0); EXPECT_EQ(o014, iValue0); EXPECT_EQ(o015, iValue0); EXPECT_EQ(o016, iValue0); EXPECT_EQ(o017, iValue0); EXPECT_EQ(o018, iValue0); + EXPECT_EQ(o019, iValue0); EXPECT_EQ(o020, iValue0); EXPECT_EQ(o021, iValue0); EXPECT_EQ(o022, iValue0); EXPECT_EQ(o023, iValue0); EXPECT_EQ(o024, iValue0); EXPECT_EQ(o025, iValue0); EXPECT_EQ(o026, iValue0); EXPECT_EQ(o027, iValue0); + EXPECT_EQ(o028, iValue0); EXPECT_EQ(o029, iValue0); EXPECT_EQ(o030, iValue0); EXPECT_EQ(o031, iValue0); EXPECT_EQ(o032, iValue0); EXPECT_EQ(o033, iValue0); EXPECT_EQ(o034, iValue0); EXPECT_EQ(o035, iValue0); EXPECT_EQ(o036, iValue0); + EXPECT_EQ(o037, iValue0); EXPECT_EQ(o038, iValue0); EXPECT_EQ(o039, iValue0); + } +} + +TEST(Signed_Initialization, Binary) { + constexpr auto testsAmount = 2, blocksNumber = 64; + + Aesi record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::string binary {}; + for (auto byte = value.GetByte(value.ByteCount() - 1); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + std::stringstream ss {}; + ss << (i % 2 == 0 ? "" : "-") << "0b" << std::string(binary.rbegin(), binary.rend()); + for(long long j = value.ByteCount() - 2; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Signed_Initialization, Decimal) { + constexpr auto testsAmount = 2, blocksNumber = 64; + + Aesi record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; ss << std::dec << value; + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Signed_Initialization, Octal) { + constexpr auto testsAmount = 2, blocksNumber = 64; + + Aesi record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; ss << (i % 2 == 0 ? "" : "-") << "0o" << std::oct << (i % 2 == 0 ? value : value * -1); + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Signed_Initialization, Hexadecimal) { + constexpr auto testsAmount = 2, blocksNumber = 64; + + Aesi record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = (i % 2 == 0 ? 1 : -1) * Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; + if(i % 2 == 0) + ss << (i % 2 == 0 ? "" : "-") << "0x" << std::hex << std::uppercase << (i % 2 == 0 ? value : value * -1); + else ss << (i % 2 == 0 ? "" : "-") << "0x" << std::hex << std::nouppercase << (i % 2 == 0 ? value : value * -1); + record = ss.str(); EXPECT_EQ(record, value); + } +} diff --git a/test/operations/initialization/unsigned.cpp b/test/operations/initialization/unsigned.cpp new file mode 100755 index 0000000..077e016 --- /dev/null +++ b/test/operations/initialization/unsigned.cpp @@ -0,0 +1,138 @@ +#include +#include +#include "../../../Aeu.h" +#include "../../generation.h" + +TEST(Unsigned_Initialization, Basic) { + { + Aeu128 m0{}, m1(0u), m2 = 0u, m3 = Aeu128(0u), m4 = {}, m5 = "0", m6 = "-0", m7 = "Somebody once told me..."; + EXPECT_EQ(m0, 0u); EXPECT_EQ(m1, 0u); EXPECT_EQ(m2, 0u); EXPECT_EQ(m3, 0u); + EXPECT_EQ(m4, 0u); EXPECT_EQ(m5, 0u); EXPECT_EQ(m6, 0u); EXPECT_EQ(m7, 0u); + } + { + Aeu128 i01 = 1u, i03 = 127u; + EXPECT_EQ(i01, 1u); EXPECT_EQ(i03, 127u); + } + { + Aeu128 ten = "10", fifty = "50"; + EXPECT_EQ(ten, 10u); + EXPECT_EQ(fifty, 50u); + + Aeu128 hexTenLC = "0xa", hexTenHC = "0xA"; + EXPECT_EQ(hexTenLC, 10u); EXPECT_EQ(hexTenHC, 10u); + + Aeu128 octTwentyLC = "0o24", octTwentyHC = "0o24"; + EXPECT_EQ(octTwentyLC, 20u); + EXPECT_EQ(octTwentyHC, 20u); + } + { + using namespace std::string_literals; using namespace std::string_view_literals; + Aeu512 d0 = "489133282872437279"s, d1 = "63018038201"sv; + EXPECT_EQ(d0, 489133282872437279u); EXPECT_EQ(d1, 63018038201u); + + Aeu512 b0 = "0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279u); + Aeu512 b1 = "0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201u); + + Aeu512 o0 = "0o106274176273174613"s, o1 = "0o642054234601645202742"sv; + EXPECT_EQ(o0, 2475842268363147u); EXPECT_EQ(o1, 7531577461358003682u); + + Aeu512 h0 = "0x688589CC0E9505E2"s, h1 = "0x3C9D4B9CB52FE"sv; + EXPECT_EQ(h0, 7531577461358003682u); EXPECT_EQ(h1, 1066340417491710u); + Aeu512 h4 = "0x688589cc0e9505e2"s, h5 = "0x3c9d4b9cb52fe"sv; + EXPECT_EQ(h4, 7531577461358003682u); EXPECT_EQ(h5, 1066340417491710u); + + d0 = L"489133282872437279"s, d1 = L"63018038201"sv; + EXPECT_EQ(d0, 489133282872437279u); EXPECT_EQ(d1, 63018038201u); + + b0 = L"0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279u); + b1 = L"0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201u); + + o0 = L"0o106274176273174613"s, o1 = L"0o642054234601645202742"sv; + EXPECT_EQ(o0, 2475842268363147u); EXPECT_EQ(o1, 7531577461358003682u); + + h0 = L"0x688589CC0E9505E2"s, h1 = L"0x3C9D4B9CB52FE"sv; + EXPECT_EQ(h0, 7531577461358003682u); EXPECT_EQ(h1, 1066340417491710u); + h4 = L"0x688589cc0e9505e2"s, h5 = L"0x3c9d4b9cb52fe"sv; + EXPECT_EQ(h4, 7531577461358003682u); EXPECT_EQ(h5, 1066340417491710u); + } +} + +TEST(Unsigned_Initialization, Different_precisions) { + uint64_t iValue0 = 3218136187561313218u; + Aeu < 96 > o00 = iValue0; + Aeu < 96 > o01 = iValue0; + + Aeu < 128 > o02 = iValue0; Aeu < 160 > o03 = iValue0; Aeu < 192 > o04 = iValue0; Aeu < 224 > o05 = iValue0; Aeu < 256 > o06 = iValue0; Aeu < 288 > o07 = iValue0; Aeu < 320 > o08 = iValue0; Aeu < 352 > o09 = iValue0; + Aeu < 384 > o010 = iValue0; Aeu < 416 > o011 = iValue0; Aeu < 448 > o012 = iValue0; Aeu < 480 > o013 = iValue0; Aeu < 512 > o014 = iValue0; Aeu < 544 > o015 = iValue0; Aeu < 576 > o016 = iValue0; Aeu < 608 > o017 = iValue0; Aeu < 640 > o018 = iValue0; + Aeu < 672 > o019 = iValue0; Aeu < 704 > o020 = iValue0; Aeu < 736 > o021 = iValue0; Aeu < 768 > o022 = iValue0; Aeu < 800 > o023 = iValue0; Aeu < 832 > o024 = iValue0; Aeu < 864 > o025 = iValue0; Aeu < 896 > o026 = iValue0; Aeu < 928 > o027 = iValue0; + Aeu < 960 > o028 = iValue0; Aeu < 992 > o029 = iValue0; Aeu < 1024 > o030 = iValue0; Aeu < 1056 > o031 = iValue0; Aeu < 1088 > o032 = iValue0; Aeu < 1120 > o033 = iValue0; Aeu < 1152 > o034 = iValue0; Aeu < 1184 > o035 = iValue0; Aeu < 1216 > o036 = iValue0; + Aeu < 1248 > o037 = iValue0; Aeu < 1280 > o038 = iValue0; Aeu < 1312 > o039 = iValue0; + + EXPECT_EQ(o00, iValue0); + EXPECT_EQ(o01, iValue0); EXPECT_EQ(o02, iValue0); EXPECT_EQ(o03, iValue0); EXPECT_EQ(o04, iValue0); EXPECT_EQ(o05, iValue0); EXPECT_EQ(o06, iValue0); EXPECT_EQ(o07, iValue0); EXPECT_EQ(o08, iValue0); EXPECT_EQ(o09, iValue0); + EXPECT_EQ(o010, iValue0); EXPECT_EQ(o011, iValue0); EXPECT_EQ(o012, iValue0); EXPECT_EQ(o013, iValue0); EXPECT_EQ(o014, iValue0); EXPECT_EQ(o015, iValue0); EXPECT_EQ(o016, iValue0); EXPECT_EQ(o017, iValue0); EXPECT_EQ(o018, iValue0); + EXPECT_EQ(o019, iValue0); EXPECT_EQ(o020, iValue0); EXPECT_EQ(o021, iValue0); EXPECT_EQ(o022, iValue0); EXPECT_EQ(o023, iValue0); EXPECT_EQ(o024, iValue0); EXPECT_EQ(o025, iValue0); EXPECT_EQ(o026, iValue0); EXPECT_EQ(o027, iValue0); + EXPECT_EQ(o028, iValue0); EXPECT_EQ(o029, iValue0); EXPECT_EQ(o030, iValue0); EXPECT_EQ(o031, iValue0); EXPECT_EQ(o032, iValue0); EXPECT_EQ(o033, iValue0); EXPECT_EQ(o034, iValue0); EXPECT_EQ(o035, iValue0); EXPECT_EQ(o036, iValue0); + EXPECT_EQ(o037, iValue0); EXPECT_EQ(o038, iValue0); EXPECT_EQ(o039, iValue0); +} + +TEST(Unsigned_Initialization, Binary) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + + Aeu record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; + std::string binary {}; + for (auto byte = value.GetByte(value.ByteCount() - 1); byte; byte >>= 1) + binary += (byte & 1 ? '1' : '0'); + ss << "0b" << std::string(binary.rbegin(), binary.rend()); + for(long long j = value.ByteCount() - 2; j >= 0; --j) + ss << std::bitset<8>(value.GetByte(j)); + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Unsigned_Initialization, Decimal) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + + Aeu record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; ss << std::dec << value; + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Unsigned_Initialization, Octal) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + + Aeu record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; ss << "0o" << std::oct << value; + record = ss.str(); EXPECT_EQ(record, value); + } +} + +TEST(Unsigned_Initialization, Hexadecimal) { + constexpr auto testsAmount = 2048, blocksNumber = 64; + + Aeu record {}; + for (std::size_t i = 0; i < testsAmount; ++i) { + const auto value = Generation::getRandomWithBits(blocksNumber * 32 - 20); + record = value; EXPECT_EQ(record, value); + + std::stringstream ss {}; + if(i % 2 == 0) + ss << "0x" << std::hex << std::uppercase << value; + else ss << "0x" << std::hex << std::nouppercase << value; + record = ss.str(); EXPECT_EQ(record, value); + } +} diff --git a/test/operations/initialization_different_notations.cpp b/test/operations/initialization_different_notations.cpp deleted file mode 100644 index 3b0adb2..0000000 --- a/test/operations/initialization_different_notations.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Initialization, Binary) { - Aesi512 m0 = 0b1111111111111111111111111111111111111111111111111111111111111111; - EXPECT_EQ(m0, 18446744073709551615ULL); - - Aesi512 m1 = -0b100001100011011110111101000001011010111101101; - EXPECT_EQ(m1, -18446744073709); - - Aesi512 m2 = "0b11011001001110000000010000100010101011011101010101000011111"; - EXPECT_EQ(m2, 489133282872437279); - - Aesi512 m3 = "-0b111010101100001010101111001110111001"; - EXPECT_EQ(m3, -63018038201); - - Aesi512 m4 = "0b1010101010101010101010101"; - EXPECT_EQ(m4, 22369621); - - Aesi512 m5 = "-0b10101001100010101001"; - EXPECT_EQ(m5, -694441); -} - -TEST(Initialization, Decimal) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = 99194853094755497; - EXPECT_EQ(m0, 99194853094755497); - - Aesi512 m1 = -2971215073; - EXPECT_EQ(m1, -2971215073); - - Aesi512 m01 = "13378377970851103139", m02 = "11719763643718140323", m03 = "9316006560503877973"; EXPECT_EQ(m01, 13378377970851103139ULL); EXPECT_EQ(m02, 11719763643718140323ULL); EXPECT_EQ(m03, 9316006560503877973ULL); - Aesi512 m11 = "11919543387665926677", m12 = "15958521639934138380", m13 = "17147361350897516454"; EXPECT_EQ(m11, 11919543387665926677ULL); EXPECT_EQ(m12, 15958521639934138380ULL); EXPECT_EQ(m13, 17147361350897516454ULL); - Aesi512 m21 = "10834542690373001614", m22 = "16148811040092645811", m23 = "17565826475182039024"; EXPECT_EQ(m21, 10834542690373001614ULL); EXPECT_EQ(m22, 16148811040092645811ULL); EXPECT_EQ(m23, 17565826475182039024ULL); - Aesi512 m31 = "12289857351508920895", m32 = "13622788999724709304", m33 = "10623019157349914743"; EXPECT_EQ(m31, 12289857351508920895ULL); EXPECT_EQ(m32, 13622788999724709304ULL); EXPECT_EQ(m33, 10623019157349914743ULL); - Aesi512 m41 = "10939320262724745060", m42 = "14643970812468467643", m43 = "16294323540172430452"; EXPECT_EQ(m41, 10939320262724745060ULL); EXPECT_EQ(m42, 14643970812468467643ULL); EXPECT_EQ(m43, 16294323540172430452ULL); - Aesi512 m51 = "14996741295232023491", m52 = "12593888633827380034", m53 = "10991749078867344443"; EXPECT_EQ(m51, 14996741295232023491ULL); EXPECT_EQ(m52, 12593888633827380034ULL); EXPECT_EQ(m53, 10991749078867344443ULL); - Aesi512 m61 = "17353956093056100033", m62 = "15228167772092495755", m63 = "17899631946389997807"; EXPECT_EQ(m61, 17353956093056100033ULL); EXPECT_EQ(m62, 15228167772092495755ULL); EXPECT_EQ(m63, 17899631946389997807ULL); - Aesi512 m71 = "10708654017429063267", m72 = "16998219926353610973", m73 = "10829133141072563026"; EXPECT_EQ(m71, 10708654017429063267ULL); EXPECT_EQ(m72, 16998219926353610973ULL); EXPECT_EQ(m73, 10829133141072563026ULL); - Aesi512 m81 = "13877847998957173964", m82 = "13922358005866315977", m83 = "11807516395193638556"; EXPECT_EQ(m81, 13877847998957173964ULL); EXPECT_EQ(m82, 13922358005866315977ULL); EXPECT_EQ(m83, 11807516395193638556ULL); - Aesi512 m91 = "10965280826866369676", m92 = "16905024729054783616", m93 = "10655055879745405085"; EXPECT_EQ(m91, 10965280826866369676ULL); EXPECT_EQ(m92, 16905024729054783616ULL); EXPECT_EQ(m93, 10655055879745405085ULL); - Aesi512 m101 = "14982630483848685105", m102 = "17393338613669623615", m103 = "16657270475026250676"; EXPECT_EQ(m101, 14982630483848685105ULL); EXPECT_EQ(m102, 17393338613669623615ULL); EXPECT_EQ(m103, 16657270475026250676ULL); - Aesi512 m111 = "13144465120434400767", m112 = "14130922418678570410", m113 = "11245229088607915820"; EXPECT_EQ(m111, 13144465120434400767ULL); EXPECT_EQ(m112, 14130922418678570410ULL); EXPECT_EQ(m113, 11245229088607915820ULL); - Aesi512 m121 = "12743038743527484009", m122 = "14051540288037776639", m123 = "18254549870032307073"; EXPECT_EQ(m121, 12743038743527484009ULL); EXPECT_EQ(m122, 14051540288037776639ULL); EXPECT_EQ(m123, 18254549870032307073ULL); - Aesi512 m131 = "9877403520469498488", m132 = "15236480681984638277", m133 = "15711155196283426421"; EXPECT_EQ(m131, 9877403520469498488ULL); EXPECT_EQ(m132, 15236480681984638277ULL); EXPECT_EQ(m133, 15711155196283426421ULL); - Aesi512 m141 = "11565963328281742044", m142 = "11300185697576051434", m143 = "10415500592691668327"; EXPECT_EQ(m141, 11565963328281742044ULL); EXPECT_EQ(m142, 11300185697576051434ULL); EXPECT_EQ(m143, 10415500592691668327ULL); - Aesi512 m151 = "9533336768989960163", m152 = "18032654289952846223", m153 = "13400300879241963399"; EXPECT_EQ(m151, 9533336768989960163ULL); EXPECT_EQ(m152, 18032654289952846223ULL); EXPECT_EQ(m153, 13400300879241963399ULL); - Aesi512 m161 = "13809956980460275959", m162 = "16259764889520594414", m163 = "14416493008719931512"; EXPECT_EQ(m161, 13809956980460275959ULL); EXPECT_EQ(m162, 16259764889520594414ULL); EXPECT_EQ(m163, 14416493008719931512ULL); - Aesi512 m171 = "10080594175187014088", m172 = "14598508520412284476", m173 = "14326100672420290705"; EXPECT_EQ(m171, 10080594175187014088ULL); EXPECT_EQ(m172, 14598508520412284476ULL); EXPECT_EQ(m173, 14326100672420290705ULL); - Aesi512 m181 = "14726615300475519804", m182 = "15084508502968579604", m183 = "16826240680823551203"; EXPECT_EQ(m181, 14726615300475519804ULL); EXPECT_EQ(m182, 15084508502968579604ULL); EXPECT_EQ(m183, 16826240680823551203ULL); - Aesi512 m191 = "16590644228955517948", m192 = "14659853423942915411", m193 = "16943322646564742408"; EXPECT_EQ(m191, 16590644228955517948ULL); EXPECT_EQ(m192, 14659853423942915411ULL); EXPECT_EQ(m193, 16943322646564742408ULL); - Aesi512 m201 = "17460201697985088669", m202 = "10749301176204308052", m203 = "9840481798005876870"; EXPECT_EQ(m201, 17460201697985088669ULL); EXPECT_EQ(m202, 10749301176204308052ULL); EXPECT_EQ(m203, 9840481798005876870ULL); - Aesi512 m211 = "14567833500654254706", m212 = "15254516935367624713", m213 = "14046170707165146580"; EXPECT_EQ(m211, 14567833500654254706ULL); EXPECT_EQ(m212, 15254516935367624713ULL); EXPECT_EQ(m213, 14046170707165146580ULL); - Aesi512 m221 = "11715267752589384243", m222 = "16798388065680175860", m223 = "12932403111323266208"; EXPECT_EQ(m221, 11715267752589384243ULL); EXPECT_EQ(m222, 16798388065680175860ULL); EXPECT_EQ(m223, 12932403111323266208ULL); - Aesi512 m231 = "11741962624212272108", m232 = "16872235591506657444", m233 = "17007784340030070709"; EXPECT_EQ(m231, 11741962624212272108ULL); EXPECT_EQ(m232, 16872235591506657444ULL); EXPECT_EQ(m233, 17007784340030070709ULL); - Aesi512 m241 = "10716958495897230341", m242 = "12616299434802097000", m243 = "12356637531456900366"; EXPECT_EQ(m241, 10716958495897230341ULL); EXPECT_EQ(m242, 12616299434802097000ULL); EXPECT_EQ(m243, 12356637531456900366ULL); - Aesi512 m251 = "13510764784405032200", m252 = "9562652326055500903", m253 = "17560363094583660198"; EXPECT_EQ(m251, 13510764784405032200ULL); EXPECT_EQ(m252, 9562652326055500903ULL); EXPECT_EQ(m253, 17560363094583660198ULL); - Aesi512 m261 = "18159266574238987111", m262 = "17929484563049526156", m263 = "16534146394427975442"; EXPECT_EQ(m261, 18159266574238987111ULL); EXPECT_EQ(m262, 17929484563049526156ULL); EXPECT_EQ(m263, 16534146394427975442ULL); - Aesi512 m271 = "18247964853177165095", m272 = "15722960907928129846", m273 = "12575491422617663401"; EXPECT_EQ(m271, 18247964853177165095ULL); EXPECT_EQ(m272, 15722960907928129846ULL); EXPECT_EQ(m273, 12575491422617663401ULL); - Aesi512 m281 = "13244619584684277914", m282 = "12163667933715760764", m283 = "15921155625312312983"; EXPECT_EQ(m281, 13244619584684277914ULL); EXPECT_EQ(m282, 12163667933715760764ULL); EXPECT_EQ(m283, 15921155625312312983ULL); - Aesi512 m291 = "9976228558524266532", m292 = "12539673636360360744", m293 = "10526583939993165403"; EXPECT_EQ(m291, 9976228558524266532ULL); EXPECT_EQ(m292, 12539673636360360744ULL); EXPECT_EQ(m293, 10526583939993165403ULL); - Aesi512 m301 = "17753183659171731728", m302 = "14463434098486334103", m303 = "15357720119322103911"; EXPECT_EQ(m301, 17753183659171731728ULL); EXPECT_EQ(m302, 14463434098486334103ULL); EXPECT_EQ(m303, 15357720119322103911ULL); - Aesi512 m311 = "14643647490655788898", m312 = "10971898858260389532", m313 = "14429047618089803069"; EXPECT_EQ(m311, 14643647490655788898ULL); EXPECT_EQ(m312, 10971898858260389532ULL); EXPECT_EQ(m313, 14429047618089803069ULL); - Aesi512 m321 = "9585165621928923370", m322 = "17585577617421941992", m323 = "17895421036698009695"; EXPECT_EQ(m321, 9585165621928923370ULL); EXPECT_EQ(m322, 17585577617421941992ULL); EXPECT_EQ(m323, 17895421036698009695ULL); - Aesi512 m331 = "13050895158711279280", m332 = "11049680588291607375", m333 = "17336307568298680003"; EXPECT_EQ(m331, 13050895158711279280ULL); EXPECT_EQ(m332, 11049680588291607375ULL); EXPECT_EQ(m333, 17336307568298680003ULL); - Aesi512 m341 = "18393856939739294855", m342 = "17367841609136451857", m343 = "12468795356925881647"; EXPECT_EQ(m341, 18393856939739294855ULL); EXPECT_EQ(m342, 17367841609136451857ULL); EXPECT_EQ(m343, 12468795356925881647ULL); - Aesi512 m351 = "12079454946163899256", m352 = "9924740807056941367", m353 = "15176448069539040879"; EXPECT_EQ(m351, 12079454946163899256ULL); EXPECT_EQ(m352, 9924740807056941367ULL); EXPECT_EQ(m353, 15176448069539040879ULL); - Aesi512 m361 = "12023727360014820216", m362 = "11164143595722096249", m363 = "12724342403314809165"; EXPECT_EQ(m361, 12023727360014820216ULL); EXPECT_EQ(m362, 11164143595722096249ULL); EXPECT_EQ(m363, 12724342403314809165ULL); - Aesi512 m371 = "15402730752957859188", m372 = "12403024845393261482", m373 = "16786818513087028608"; EXPECT_EQ(m371, 15402730752957859188ULL); EXPECT_EQ(m372, 12403024845393261482ULL); EXPECT_EQ(m373, 16786818513087028608ULL); - Aesi512 m381 = "17512390244775564735", m382 = "12576466365168130462", m383 = "16926382816349100091"; EXPECT_EQ(m381, 17512390244775564735ULL); EXPECT_EQ(m382, 12576466365168130462ULL); EXPECT_EQ(m383, 16926382816349100091ULL); - Aesi512 m391 = "16754267291394599395", m392 = "16875553851583926497", m393 = "17426858846699790569"; EXPECT_EQ(m391, 16754267291394599395ULL); EXPECT_EQ(m392, 16875553851583926497ULL); EXPECT_EQ(m393, 17426858846699790569ULL); - Aesi512 m401 = "9526020705636657256", m402 = "18284059637150623399", m403 = "13290214350392998969"; EXPECT_EQ(m401, 9526020705636657256ULL); EXPECT_EQ(m402, 18284059637150623399ULL); EXPECT_EQ(m403, 13290214350392998969ULL); - Aesi512 m411 = "17306681321201210587", m412 = "9553824127190244568", m413 = "15058319286857223208"; EXPECT_EQ(m411, 17306681321201210587ULL); EXPECT_EQ(m412, 9553824127190244568ULL); EXPECT_EQ(m413, 15058319286857223208ULL); - Aesi512 m421 = "16703594334367544228", m422 = "9709183811752107767", m423 = "14282984470933189872"; EXPECT_EQ(m421, 16703594334367544228ULL); EXPECT_EQ(m422, 9709183811752107767ULL); EXPECT_EQ(m423, 14282984470933189872ULL); - Aesi512 m431 = "9556679457830265164", m432 = "9822799274914353206", m433 = "12097307743251635085"; EXPECT_EQ(m431, 9556679457830265164ULL); EXPECT_EQ(m432, 9822799274914353206ULL); EXPECT_EQ(m433, 12097307743251635085ULL); - Aesi512 m441 = "13613184886375973574", m442 = "10358872243931045275", m443 = "9298761383743946685"; EXPECT_EQ(m441, 13613184886375973574ULL); EXPECT_EQ(m442, 10358872243931045275ULL); EXPECT_EQ(m443, 9298761383743946685ULL); - Aesi512 m451 = "14438674441466895820", m452 = "12943963508677869255", m453 = "13113276565613302743"; EXPECT_EQ(m451, 14438674441466895820ULL); EXPECT_EQ(m452, 12943963508677869255ULL); EXPECT_EQ(m453, 13113276565613302743ULL); - Aesi512 m461 = "13617572520967023080", m462 = "12596208924218474229", m463 = "11206275659156837562"; EXPECT_EQ(m461, 13617572520967023080ULL); EXPECT_EQ(m462, 12596208924218474229ULL); EXPECT_EQ(m463, 11206275659156837562ULL); - Aesi512 m471 = "17784669543737251499", m472 = "14201062765192332341", m473 = "16224984775783005142"; EXPECT_EQ(m471, 17784669543737251499ULL); EXPECT_EQ(m472, 14201062765192332341ULL); EXPECT_EQ(m473, 16224984775783005142ULL); - Aesi512 m481 = "16472899448046760550", m482 = "17950352882176089499", m483 = "15811180152515576389"; EXPECT_EQ(m481, 16472899448046760550ULL); EXPECT_EQ(m482, 17950352882176089499ULL); EXPECT_EQ(m483, 15811180152515576389ULL); - Aesi512 m491 = "15561238486743158869", m492 = "12100379568652275533", m493 = "9406939632453216753"; EXPECT_EQ(m491, 15561238486743158869ULL); EXPECT_EQ(m492, 12100379568652275533ULL); EXPECT_EQ(m493, 9406939632453216753ULL); - - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count());; -} - -TEST(Initialization, Octal) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = 05403223057620506251; - EXPECT_EQ(m0, 99194853094755497); - - Aesi512 m1 = 026106222341; - EXPECT_EQ(m1, 2971215073); - - Aesi512 m01 = "0o1542441572575603627123", m02 = "0o1323151762666470770164", m03 = "0o1353055204621613313726"; EXPECT_EQ(m01, 15610663419945889363ULL); EXPECT_EQ(m02, 13028138762593628276ULL); EXPECT_EQ(m03, 13458348108222928854ULL); - Aesi512 m11 = "0o1656326414567774016647", m12 = "0o1756526751422451437777", m13 = "0o1572360607706245323212"; EXPECT_EQ(m11, 16977111318843628967ULL); EXPECT_EQ(m12, 18134551596471042047ULL); EXPECT_EQ(m13, 16041285853033899658ULL); - Aesi512 m21 = "0o1754251462700776152055", m22 = "0o1711261326117126506470", m23 = "0o1765100013732552176571"; EXPECT_EQ(m21, 18092423350826095661ULL); EXPECT_EQ(m22, 17462194506141699384ULL); EXPECT_EQ(m23, 18250838309547343225ULL); - Aesi512 m31 = "0o1000230335370122704543", m32 = "0o1551044003005446423101", m33 = "0o1522073745444544371545"; EXPECT_EQ(m31, 9228735281724361059ULL); EXPECT_EQ(m32, 15727836743079700033ULL); EXPECT_EQ(m33, 15314347979244172133ULL); - Aesi512 m41 = "0o1620065170561711314464", m42 = "0o1627467501127046056103", m43 = "0o1243614251342031400062"; EXPECT_EQ(m41, 16431004508351732020ULL); EXPECT_EQ(m42, 16566196640572529731ULL); EXPECT_EQ(m43, 12173663649178976306ULL); - Aesi512 m51 = "0o1757001063262047033461", m52 = "0o1003245172761760113412", m53 = "0o1575325762704573774350"; EXPECT_EQ(m51, 18140538012014753585ULL); EXPECT_EQ(m52, 9283229104390313738ULL); EXPECT_EQ(m53, 16094386423287773416ULL); - Aesi512 m61 = "0o1116236441075131433421", m62 = "0o1522670151652611125644", m63 = "0o1641505612666375057057"; EXPECT_EQ(m61, 10634074119523940113ULL); EXPECT_EQ(m62, 15327727129603648420ULL); EXPECT_EQ(m63, 16746838270565178927ULL); - Aesi512 m71 = "0o1633173760756520634406", m72 = "0o1461433602057356066226", m73 = "0o1451442550254744370526"; EXPECT_EQ(m71, 16631651653271107846ULL); EXPECT_EQ(m72, 14727747291636591766ULL); EXPECT_EQ(m73, 14583876624300765526ULL); - Aesi512 m81 = "0o1560616346027405005465", m82 = "0o1532703267025703764556", m83 = "0o1333732337601224060077"; EXPECT_EQ(m81, 15866689877070580533ULL); EXPECT_EQ(m82, 15472234651548903790ULL); EXPECT_EQ(m83, 13185218078957396031ULL); - Aesi512 m91 = "0o1014241170725046144267", m92 = "0o1065662064156065420716", m93 = "0o1004573160170252025071"; EXPECT_EQ(m91, 9445217812170197175ULL); EXPECT_EQ(m92, 10193408763534647758ULL); EXPECT_EQ(m93, 9308772220646468153ULL); - Aesi512 m101 = "0o1527240145737240771555", m102 = "0o1256214570311346707617", m103 = "0o1563053242350413620154"; EXPECT_EQ(m101, 15407947230140953453ULL); EXPECT_EQ(m102, 12362829055158620047ULL); EXPECT_EQ(m103, 15908237975636353132ULL); - Aesi512 m111 = "0o1475656011217222731120", m112 = "0o1361705616647127513322", m113 = "0o1062066473034231620003"; EXPECT_EQ(m111, 14949066282065703504ULL); EXPECT_EQ(m112, 13580808005344990930ULL); EXPECT_EQ(m113, 10126013568855252995ULL); - Aesi512 m121 = "0o1646237045665665761313", m122 = "0o1646643162424657317107", m123 = "0o1432070313710226234365"; EXPECT_EQ(m121, 16831045124406895307ULL); EXPECT_EQ(m122, 16840198330938924615ULL); EXPECT_EQ(m123, 14305416752662132981ULL); - Aesi512 m131 = "0o1100313750460461440025", m132 = "0o1026102161000740171312", m133 = "0o1526232462203771447403"; EXPECT_EQ(m131, 10383469544982593557ULL); EXPECT_EQ(m132, 9622018738048004810ULL); EXPECT_EQ(m133, 15389735766274232067ULL); - Aesi512 m141 = "0o1703755735153725122401", m142 = "0o1467135470222326736631", m143 = "0o1232064745506551101163"; EXPECT_EQ(m141, 17365244453745632513ULL); EXPECT_EQ(m142, 14829143580036808089ULL); EXPECT_EQ(m143, 11999452367459484275ULL); - Aesi512 m151 = "0o1764566452335561076102", m152 = "0o1533406427113036552457", m153 = "0o1524430715722515072344"; EXPECT_EQ(m151, 18243750754919939138ULL); EXPECT_EQ(m152, 15483605807940687151ULL); EXPECT_EQ(m153, 15358150896575083748ULL); - Aesi512 m161 = "0o1515735743242056542246", m162 = "0o1703412342601443547426", m163 = "0o1470334525310161222411"; EXPECT_EQ(m161, 15238982899261424806ULL); EXPECT_EQ(m162, 17357240389958815510ULL); EXPECT_EQ(m163, 14851628393887507721ULL); - Aesi512 m171 = "0o1331257552333010271013", m172 = "0o1220717263357407505406", m173 = "0o1171000444054777431625"; EXPECT_EQ(m171, 13138678684374364683ULL); EXPECT_EQ(m172, 11833748119430793990ULL); EXPECT_EQ(m173, 11403134328628982677ULL); - Aesi512 m181 = "0o1771551304615371527425", m182 = "0o1733640754252027710525", m183 = "0o1712244543517751457444"; EXPECT_EQ(m181, 18333358364834574101ULL); EXPECT_EQ(m182, 17794881860453503317ULL); EXPECT_EQ(m183, 17479761231725616932ULL); - Aesi512 m191 = "0o1355776630772401211730", m192 = "0o1541601566234150712627", m193 = "0o1770615461236375124702"; EXPECT_EQ(m191, 13510756618895430616ULL); EXPECT_EQ(m192, 15596026416005879191ULL); EXPECT_EQ(m193, 18316618062066133442ULL); - Aesi512 m201 = "0o1767063374045375766172", m202 = "0o1157323745752203675201", m203 = "0o1441555116277227076256"; EXPECT_EQ(m201, 18286426212441517178ULL); EXPECT_EQ(m202, 11230427568665492097ULL); EXPECT_EQ(m203, 14442380887701879982ULL); - Aesi512 m211 = "0o1426165667511464467225", m212 = "0o1124243225744674456413", m213 = "0o1316100456333061155455"; EXPECT_EQ(m211, 14235521606113980053ULL); EXPECT_EQ(m212, 10742326868581702923ULL); EXPECT_EQ(m213, 12936610712310307629ULL); - Aesi512 m221 = "0o1642641656527705630513", m222 = "0o1462176427701712040217", m223 = "0o1430616654370515366523"; EXPECT_EQ(m221, 16768092092509925707ULL); EXPECT_EQ(m222, 14740230444757303439ULL); EXPECT_EQ(m223, 14281436444910546259ULL); - Aesi512 m231 = "0o1254344156331115434664", m232 = "0o1311770663322435210111", m233 = "0o1511104754666660255732"; EXPECT_EQ(m231, 12329878205609949620ULL); EXPECT_EQ(m232, 12862028982026309705ULL); EXPECT_EQ(m233, 15152535552659643354ULL); - Aesi512 m241 = "0o1162077543230777230713", m242 = "0o1160761670637074556354", m243 = "0o1604340224035754614074"; EXPECT_EQ(m241, 11279254498326688203ULL); EXPECT_EQ(m242, 11258501595130944748ULL); EXPECT_EQ(m243, 16220850132385732668ULL); - Aesi512 m251 = "0o1110251611601014400156", m252 = "0o1520733742122651326443", m253 = "0o1643220755064266270654"; EXPECT_EQ(m251, 10526381946851950702ULL); EXPECT_EQ(m252, 15292955646688079139ULL); EXPECT_EQ(m253, 16776505447637676460ULL); - Aesi512 m261 = "0o1516340333641435066153", m262 = "0o1215443013354241517021", m263 = "0o1357736676503272545160"; EXPECT_EQ(m261, 15248077543978593387ULL); EXPECT_EQ(m262, 11773641666601590289ULL); EXPECT_EQ(m263, 13545662102767323760ULL); - Aesi512 m271 = "0o1764226343010361767242", m272 = "0o1072133043641274516633", m273 = "0o1333473625622424123175"; EXPECT_EQ(m271, 18235864547867487906ULL); EXPECT_EQ(m272, 10271411389464747419ULL); EXPECT_EQ(m273, 13179636273055311485ULL); - Aesi512 m281 = "0o1751560410471010402440", m282 = "0o1470667406557222520500", m283 = "0o1652755164103505272417"; EXPECT_EQ(m281, 18045378940874392864ULL); EXPECT_EQ(m282, 14859328364959408448ULL); EXPECT_EQ(m283, 16914859677871076623ULL); - Aesi512 m291 = "0o1525535143553122100702", m292 = "0o1441021403066524222571", m293 = "0o1717372135637656414602"; EXPECT_EQ(m291, 15378568126417895874ULL); EXPECT_EQ(m292, 14430149146102015353ULL); EXPECT_EQ(m293, 17572841086491695490ULL); - Aesi512 m301 = "0o1023005474602677076553", m302 = "0o1405720432033531520544", m303 = "0o1521733567061616303752"; EXPECT_EQ(m301, 9565843297675279723ULL); EXPECT_EQ(m302, 13941474979085721956ULL); EXPECT_EQ(m303, 15310962687777277930ULL); - Aesi512 m311 = "0o1457353074030340116351", m312 = "0o1012521242556003507342", m313 = "0o1011426423114100356107"; EXPECT_EQ(m311, 14690007239117282537ULL); EXPECT_EQ(m312, 9415384337023405794ULL); EXPECT_EQ(m313, 9395301786954357831ULL); - Aesi512 m321 = "0o1336732615003011622106", m322 = "0o1251054313707502010471", m323 = "0o1516540626216361101365"; EXPECT_EQ(m321, 13239273180367365190ULL); EXPECT_EQ(m322, 12269367508536398137ULL); EXPECT_EQ(m323, 15252593957226709749ULL); - Aesi512 m331 = "0o1442720447321510742576", m332 = "0o1436273550464415737051", m333 = "0o1436100202046430205025"; EXPECT_EQ(m331, 14463893453637141886ULL); EXPECT_EQ(m332, 14382094268568682025ULL); EXPECT_EQ(m333, 14377750749086026261ULL); - Aesi512 m341 = "0o1256700035462341611420", m342 = "0o1022170475051177133457", m343 = "0o1764460266144026504263"; EXPECT_EQ(m341, 12373642010195071760ULL); EXPECT_EQ(m342, 9551875124286502703ULL); EXPECT_EQ(m343, 18241279861083244723ULL); - Aesi512 m351 = "0o1650224462367704040254", m352 = "0o1264302114264244602302", m353 = "0o1450720700134567172673"; EXPECT_EQ(m351, 16866705353374449836ULL); EXPECT_EQ(m352, 12472794783629378754ULL); EXPECT_EQ(m353, 14571990343082636731ULL); - Aesi512 m361 = "0o1405023354265067623227", m362 = "0o1264266520657630765460", m363 = "0o1475560041033173122171"; EXPECT_EQ(m361, 13925814793003804311ULL); EXPECT_EQ(m362, 12472390471980935984ULL); EXPECT_EQ(m363, 14946886484688151673ULL); - Aesi512 m371 = "0o1437454337041534412376", m372 = "0o1330044554565244514713", m373 = "0o1075032406127651210670"; EXPECT_EQ(m371, 14404075049666614526ULL); EXPECT_EQ(m372, 13115773816293988811ULL); EXPECT_EQ(m373, 10323183155898814904ULL); - Aesi512 m381 = "0o1466050607211717105545", m382 = "0o1666421162216506617316", m383 = "0o1534117032701545072114"; EXPECT_EQ(m381, 14809269837502384997ULL); EXPECT_EQ(m382, 17123291770753064654ULL); EXPECT_EQ(m383, 15495164130613294156ULL); - Aesi512 m391 = "0o1067727414740570545500", m392 = "0o1137444316325105542513", m393 = "0o1677602566222466752432"; EXPECT_EQ(m391, 10230754275473148736ULL); EXPECT_EQ(m392, 10945027916724356427ULL); EXPECT_EQ(m393, 17289415058981115162ULL); - Aesi512 m401 = "0o1621026503627636726233", m402 = "0o1211421547420553411730", m403 = "0o1002133425317110160712"; EXPECT_EQ(m401, 16447942146469375131ULL); EXPECT_EQ(m402, 11700974673128723416ULL); EXPECT_EQ(m403, 9262621674830881226ULL); - Aesi512 m411 = "0o1511442060001613406204", m412 = "0o1526647202603076577402", m413 = "0o1743377673500332414631"; EXPECT_EQ(m411, 15160315913152892036ULL); EXPECT_EQ(m412, 15399188301981875970ULL); EXPECT_EQ(m413, 17933329017552378265ULL); - Aesi512 m421 = "0o1623676130625363322711", m422 = "0o1471056324507415147430", m423 = "0o1612127001532033434112"; EXPECT_EQ(m421, 16498872967863576009ULL); EXPECT_EQ(m422, 14863511863927557912ULL); EXPECT_EQ(m423, 16324106205128439882ULL); - Aesi512 m431 = "0o1217124602160267456312", m432 = "0o1714455774721070220350", m433 = "0o1423626033205524101617"; EXPECT_EQ(m431, 11802413051764694218ULL); EXPECT_EQ(m432, 17520620819135406312ULL); EXPECT_EQ(m433, 14191618355396379535ULL); - Aesi512 m441 = "0o1774001701374407617435", m442 = "0o1006051220671406245026", m443 = "0o1012740114200710550654"; EXPECT_EQ(m441, 18374752552980782877ULL); EXPECT_EQ(m442, 9332910942030744086ULL); EXPECT_EQ(m443, 9420409760532058540ULL); - Aesi512 m451 = "0o1571654527337612632554", m452 = "0o1556535210433436734275", m453 = "0o1211451170375303203603"; EXPECT_EQ(m451, 16029882786998072684ULL); EXPECT_EQ(m452, 15828930621091854525ULL); EXPECT_EQ(m453, 11701802671509669763ULL); - Aesi512 m461 = "0o1476165631353632530605", m462 = "0o1532332771152744463647", m463 = "0o1531533621475777204047"; EXPECT_EQ(m461, 14956095472319246725ULL); EXPECT_EQ(m462, 15464058831940773799ULL); EXPECT_EQ(m463, 15450576098932099111ULL); - Aesi512 m471 = "0o1773471630626071116447", m472 = "0o1156463277237047730167", m473 = "0o1613125470505377336302"; EXPECT_EQ(m471, 18367712881679834407ULL); EXPECT_EQ(m472, 11215770621900206199ULL); EXPECT_EQ(m473, 16342071603892174018ULL); - Aesi512 m481 = "0o1475136216457375242077", m482 = "0o1340527162106000006667", m483 = "0o1134562323734224705534"; EXPECT_EQ(m481, 14937253494236988479ULL); EXPECT_EQ(m482, 13270673386020801975ULL); EXPECT_EQ(m483, 10893729481136245596ULL); - Aesi512 m491 = "0o1165631315605731440131", m492 = "0o1541243747012163056475", m493 = "0o1044543755341236157750"; EXPECT_EQ(m491, 11345461210476068953ULL); EXPECT_EQ(m492, 15588223231109913917ULL); EXPECT_EQ(m493, 9884414744230158312ULL); - - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count());; -} - -TEST(Initialization, Hexadecimal) { - const auto timeStart = std::chrono::system_clock::now(); - - Aesi512 m0 = 0xFFFFFFFFFFFFFFFF; - EXPECT_EQ(m0, 18446744073709551615ULL); - - Aesi512 m1 = 0x191347024000932; - EXPECT_EQ(m1, 112929121905936690); - - Aesi512 m01 = "0xa0a474fd436972ef", m02 = "0x835ec1fa33ce1c68", m03 = "0xB519FFD33CD8F79A"; EXPECT_EQ(m01, 11575505573355549423ULL); EXPECT_EQ(m02, 9466216747134491752ULL); EXPECT_EQ(m03, 13049742678006757274ULL); - Aesi512 m11 = "0x907f3d0cd9f627b8", m12 = "0xb11a79830cdadfde", m13 = "0xE8C2DE763D0D9349"; EXPECT_EQ(m11, 10412107988909565880ULL); EXPECT_EQ(m12, 12761646097871069150ULL); EXPECT_EQ(m13, 16772212561692955465ULL); - Aesi512 m21 = "0xD699306B6A44DEA6", m22 = "0xC1A79345DF3F0EC9", m23 = "0x8beaec4f92f4b388"; EXPECT_EQ(m21, 15463444033455840934ULL); EXPECT_EQ(m22, 13954283898738249417ULL); EXPECT_EQ(m23, 10082130542334358408ULL); - Aesi512 m31 = "0xc2f11b77e6f229b1", m32 = "0xA682212854327B67", m33 = "0xc8fb4b5288f2edf3"; EXPECT_EQ(m31, 14047038914534975921ULL); EXPECT_EQ(m32, 11998188814363425639ULL); EXPECT_EQ(m33, 14482251844596985331ULL); - Aesi512 m41 = "0xb1c9293077543762", m42 = "0xBD28DD9E8CF3FF69", m43 = "0x8398c78ad1b67f1a"; EXPECT_EQ(m41, 12810815903169263458ULL); EXPECT_EQ(m42, 13630387945276178281ULL); EXPECT_EQ(m43, 9482548414466391834ULL); - Aesi512 m51 = "0x8A0C7EBA08664616", m52 = "0xAC97BC47F2801163", m53 = "0xca5cd34071d2be71"; EXPECT_EQ(m51, 9947465014424520214ULL); EXPECT_EQ(m52, 12436615913204093283ULL); EXPECT_EQ(m53, 14581761967259827825ULL); - Aesi512 m61 = "0xF7D9C3EB4F21523A", m62 = "0xf43c0850ef33377b", m63 = "0x9E5F808FB1B36F1A"; EXPECT_EQ(m61, 17859521212726727226ULL); EXPECT_EQ(m62, 17598950587560572795ULL); EXPECT_EQ(m63, 11411981335430131482ULL); - Aesi512 m71 = "0xFBBE65FFC692C5F5", m72 = "0xB5496F854E2BFB9E", m73 = "0x8D4EBF9985FDC0CC"; EXPECT_EQ(m71, 18140048498317510133ULL); EXPECT_EQ(m72, 13063094812497673118ULL); EXPECT_EQ(m73, 10182286473630171340ULL); - Aesi512 m81 = "0xd98340dcd0a28f58", m82 = "0xA2462E96DC13D395", m83 = "0xAD687914CBD47721"; EXPECT_EQ(m81, 15673442445316755288ULL); EXPECT_EQ(m82, 11693084707986330517ULL); EXPECT_EQ(m83, 12495370296365446945ULL); - Aesi512 m91 = "0x9c652b2979a23b7a", m92 = "0xE34C57BA6800CBE8", m93 = "0xAA2C27DD41FE1C77"; EXPECT_EQ(m91, 11269461099698862970ULL); EXPECT_EQ(m92, 16378562402960067560ULL); EXPECT_EQ(m93, 12262219716671446135ULL); - Aesi512 m101 = "0x901a96ad6862f3e2", m102 = "0x82a98e84373f2686", m103 = "0x93E07D398803F243"; EXPECT_EQ(m101, 10383777562380923874ULL); EXPECT_EQ(m102, 9415213194508445318ULL); EXPECT_EQ(m103, 10655654404407161411ULL); - Aesi512 m111 = "0xf196b6b694e47acb", m112 = "0xFA2EBED1C7A8B1E1", m113 = "0xBF0FCB1F0513ABB1"; EXPECT_EQ(m111, 17408302304945535691ULL); EXPECT_EQ(m112, 18027556166617838049ULL); EXPECT_EQ(m113, 13767445919984495537ULL); - Aesi512 m121 = "0xEEA85604B4684E0C", m122 = "0x9CEEF0EE8D64038E", m123 = "0x8516EA32F5D2FBB5"; EXPECT_EQ(m121, 17197089755320831500ULL); EXPECT_EQ(m122, 11308240621738918798ULL); EXPECT_EQ(m123, 9590109961125559221ULL); - Aesi512 m131 = "0x92761648F9D95C83", m132 = "0xECC8CB52926AAB52", m133 = "0xb3907691c92aebfe"; EXPECT_EQ(m131, 10553647279474564227ULL); EXPECT_EQ(m132, 17062110743797345106ULL); EXPECT_EQ(m133, 12938972097952803838ULL); - Aesi512 m141 = "0xcd17ceaf36df5df6", m142 = "0xa18bd4808cf8dde9", m143 = "0xCD29BA7D7DD4C31D"; EXPECT_EQ(m141, 14778507954174778870ULL); EXPECT_EQ(m142, 11640631310455201257ULL); EXPECT_EQ(m143, 14783552299965137693ULL); - Aesi512 m151 = "0xF9266F436EF6FBA1", m152 = "0xB04545C6B719E370", m153 = "0x8cede8e3a0843879"; EXPECT_EQ(m151, 17953159299974232993ULL); EXPECT_EQ(m152, 12701635043846120304ULL); EXPECT_EQ(m153, 10155028799138576505ULL); - Aesi512 m161 = "0xAFFEDB2B7DBA2DDB", m162 = "0xB12D8E490A12CDE8", m163 = "0x805ED95955EDC7E6"; EXPECT_EQ(m161, 12681814580561325531ULL); EXPECT_EQ(m162, 12767016963017985512ULL); EXPECT_EQ(m163, 9250069662382540774ULL); - Aesi512 m171 = "0xbd9b643a6a4cabb4", m172 = "0x93E95EC82B110A23", m173 = "0xFD9D4D7C34B4BE6B"; EXPECT_EQ(m171, 13662624096612821940ULL); EXPECT_EQ(m172, 10658154206957996579ULL); EXPECT_EQ(m173, 18274848058794884715ULL); - Aesi512 m181 = "0x9c16645d3940b65f", m182 = "0x9f20c60fb3d3f12c", m183 = "0xf7e9edd3aba10e51"; EXPECT_EQ(m181, 11247287470959670879ULL); EXPECT_EQ(m182, 11466382422029103404ULL); EXPECT_EQ(m183, 17864070890315124305ULL); - Aesi512 m191 = "0xcc23a96cb33ac433", m192 = "0x8E58E82D44F2B719", m193 = "0xb93c663b671d1590"; EXPECT_EQ(m191, 14709787092250706995ULL); EXPECT_EQ(m192, 10257203432464234265ULL); EXPECT_EQ(m193, 13347655800938370448ULL); - Aesi512 m201 = "0xFF361CE926EC3BDC", m202 = "0xb5a3e4ed795774c1", m203 = "0xE3868D53C36D0008"; EXPECT_EQ(m201, 18389917916119972828ULL); EXPECT_EQ(m202, 13088556650662950081ULL); EXPECT_EQ(m203, 16394946884389371912ULL); - Aesi512 m211 = "0xdeedcd75609baf4b", m212 = "0x8659FF3A453EA668", m213 = "0xCFA28F9C4E17D995"; EXPECT_EQ(m211, 16063721349916110667ULL); EXPECT_EQ(m212, 9681049499744511592ULL); EXPECT_EQ(m213, 14961678813566065045ULL); - Aesi512 m221 = "0x83A3C5B151B8CF68", m222 = "0xCBE8BE10846305C6", m223 = "0xB494F5CAEC8F1744"; EXPECT_EQ(m221, 9485642605543346024ULL); EXPECT_EQ(m222, 14693202762446079430ULL); EXPECT_EQ(m223, 13012295475281205060ULL); - Aesi512 m231 = "0xa18a65a36a5adc2d", m232 = "0xbf081ce4ffb2e596", m233 = "0xd77e40c46efe2a23"; EXPECT_EQ(m231, 11640227939430882349ULL); EXPECT_EQ(m232, 13765284030925956502ULL); EXPECT_EQ(m233, 15527919777639967267ULL); - Aesi512 m241 = "0x8d8108e0b87db2f7", m242 = "0xbd119e98ba591412", m243 = "0xC8FA08D6D97EB78A"; EXPECT_EQ(m241, 10196440792604455671ULL); EXPECT_EQ(m242, 13623844726571078674ULL); EXPECT_EQ(m243, 14481897270628235146ULL); - Aesi512 m251 = "0xfc8cafe01533ac91", m252 = "0xb61c6f91298fef27", m253 = "0xc5729b3511627b21"; EXPECT_EQ(m251, 18198113571260574865ULL); EXPECT_EQ(m252, 13122486083509022503ULL); EXPECT_EQ(m253, 14227604825044056865ULL); - Aesi512 m261 = "0xDEB0000A795BBC61", m262 = "0xFC1CC1A5708C8B3D", m263 = "0xBED245D1107F7D48"; EXPECT_EQ(m261, 16046325517306805345ULL); EXPECT_EQ(m262, 18166607913207761725ULL); EXPECT_EQ(m263, 13750129376542817608ULL); - Aesi512 m271 = "0xd44a3f1e8f211824", m272 = "0xd49f8a8ee9120a9b", m273 = "0xc38a35c81fe84e1e"; EXPECT_EQ(m271, 15297108484800190500ULL); EXPECT_EQ(m272, 15321116803737979547ULL); EXPECT_EQ(m273, 14090133517827067422ULL); - Aesi512 m281 = "0xc803bcc1424155bb", m282 = "0xbdfd59a60291c048", m283 = "0x9C1D5AF2E23784A1"; EXPECT_EQ(m281, 14412570770742007227ULL); EXPECT_EQ(m282, 13690197011818725448ULL); EXPECT_EQ(m283, 11249247443465241761ULL); - Aesi512 m291 = "0xDA90B512B23015B7", m292 = "0xb4d27650c462f717", m293 = "0x97c78aa508b66d06"; EXPECT_EQ(m291, 15749286988818159031ULL); EXPECT_EQ(m292, 13029606761200547607ULL); EXPECT_EQ(m293, 10936862661512948998ULL); - Aesi512 m301 = "0xEB387C0FEE0CBC43", m302 = "0xdea32d717ee3da65", m303 = "0xFD93E955CD05289E"; EXPECT_EQ(m301, 16949433605469027395ULL); EXPECT_EQ(m302, 16042716263107254885ULL); EXPECT_EQ(m303, 18272204667893393566ULL); - Aesi512 m311 = "0xa8a21285ac426ba0", m312 = "0xC2F943CD271A30AB", m313 = "0xd66bddd9795e93f8"; EXPECT_EQ(m311, 12151295109929003936ULL); EXPECT_EQ(m312, 14049335060962357419ULL); EXPECT_EQ(m313, 15450686872738501624ULL); - Aesi512 m321 = "0x882aaaebf4d11cdf", m322 = "0xedbc4d2e5c688e39", m323 = "0xde8aacd52270b8c1"; EXPECT_EQ(m321, 9811842668581428447ULL); EXPECT_EQ(m322, 17130651944124714553ULL); EXPECT_EQ(m323, 16035819454611896513ULL); - Aesi512 m331 = "0xc75ab3bd684d8079", m332 = "0x9811531C6B466320", m333 = "0xb820cdb25c93bc3b"; EXPECT_EQ(m331, 14364991587531718777ULL); EXPECT_EQ(m332, 10957630749893092128ULL); EXPECT_EQ(m333, 13267830668174539835ULL); - Aesi512 m341 = "0xE2A25914057C5298", m342 = "0xFB205A42499E771F", m343 = "0xb6fc7cd036219e0e"; EXPECT_EQ(m341, 16330713141325091480ULL); EXPECT_EQ(m342, 18095562543524116255ULL); EXPECT_EQ(m343, 13185551042737184270ULL); - Aesi512 m351 = "0xB46A0593F7EF7EA8", m352 = "0xF88E932EED0904F3", m353 = "0xa71b49306f512e60"; EXPECT_EQ(m351, 13000209407436357288ULL); EXPECT_EQ(m352, 17910414597853611251ULL); EXPECT_EQ(m353, 12041298501080002144ULL); - Aesi512 m361 = "0xAAD0B9A955163FF3", m362 = "0x84C372988029C3C0", m363 = "0xe265c3ed6da9afa6"; EXPECT_EQ(m361, 12308541918531698675ULL); EXPECT_EQ(m362, 9566616032775881664ULL); EXPECT_EQ(m363, 16313660649733992358ULL); - Aesi512 m371 = "0xD99A0BA5BA2AEE65", m372 = "0xb4c6f76fd3648293", m373 = "0xeca15a58bf8cfcb2"; EXPECT_EQ(m371, 15679857859064688229ULL); EXPECT_EQ(m372, 13026371031875748499ULL); EXPECT_EQ(m373, 17051009001418718386ULL); - Aesi512 m381 = "0xC17A0FF0906294F0", m382 = "0xFD8D2AAE4994C230", m383 = "0xFC1377A54CFB9715"; EXPECT_EQ(m381, 13941473122367739120ULL); EXPECT_EQ(m382, 18270306191359132208ULL); EXPECT_EQ(m383, 18163993273960208149ULL); - Aesi512 m391 = "0xC748F23D9F12B1A0", m392 = "0xf6b165bce08e4af9", m393 = "0xEEE37DB46EB62468"; EXPECT_EQ(m391, 14359993758346555808ULL); EXPECT_EQ(m392, 17776101066103737081ULL); EXPECT_EQ(m393, 17213740414645183592ULL); - Aesi512 m401 = "0xB0F8E1D220EFC50F", m402 = "0xB76AF027164847A2", m403 = "0xaa92afeb14393927"; EXPECT_EQ(m401, 12752190637511525647ULL); EXPECT_EQ(m402, 13216640107140368290ULL); EXPECT_EQ(m403, 12291079757238974759ULL); - Aesi512 m411 = "0xce84da09393840db", m412 = "0x80C2612B611443E9", m413 = "0xf79e1347cec39b55"; EXPECT_EQ(m411, 14881258801888510171ULL); EXPECT_EQ(m412, 9278085021276849129ULL); EXPECT_EQ(m413, 17842719972821015381ULL); - Aesi512 m421 = "0x8f7058413304186b", m422 = "0xC94C0FD7F9A421C9", m423 = "0x90c2f8ea04660390"; EXPECT_EQ(m421, 10335858181867313259ULL); EXPECT_EQ(m422, 14504985920134193609ULL); EXPECT_EQ(m423, 10431173370923320208ULL); - Aesi512 m431 = "0xea4f2cecc7e54e03", m432 = "0x893810B0CDBFFD6B", m433 = "0x9114d321e1efd5b5"; EXPECT_EQ(m431, 16883762923512876547ULL); EXPECT_EQ(m432, 9887671333444124011ULL); EXPECT_EQ(m433, 10454212777511736757ULL); - Aesi512 m441 = "0x9ede9ab7eb7be048", m442 = "0xe72dfcaa73b8cc71", m443 = "0xED0C17E94B14BC46"; EXPECT_EQ(m441, 11447757417542836296ULL); EXPECT_EQ(m442, 16658248405729463409ULL); EXPECT_EQ(m443, 17081053777463917638ULL); - Aesi512 m451 = "0x988DCD89BA20AD31", m452 = "0xbeec43d6e898ce81", m453 = "0xdcf83dc66d631004"; EXPECT_EQ(m451, 10992668256898166065ULL); EXPECT_EQ(m452, 13757445552014413441ULL); EXPECT_EQ(m453, 15922544405016416260ULL); - Aesi512 m461 = "0xAEB90C1E8526521A", m462 = "0xe6b0f3816a458562", m463 = "0xA8E1B7BBB08EDCF7"; EXPECT_EQ(m461, 12590107558513365530ULL); EXPECT_EQ(m462, 16623053961783772514ULL); EXPECT_EQ(m463, 12169209684880710903ULL); - Aesi512 m471 = "0xddbee9e19acfc41d", m472 = "0xAE59EAF54DBF6B2D", m473 = "0xc807e41831e56bbe"; EXPECT_EQ(m471, 15978465683131319325ULL); EXPECT_EQ(m472, 12563330974818986797ULL); EXPECT_EQ(m473, 14413739924990028734ULL); - Aesi512 m481 = "0xa773fbd9f49f399a", m482 = "0xfba69cf8314c843e", m483 = "0xaa8daf0c322ed564"; EXPECT_EQ(m481, 12066264740186241434ULL); EXPECT_EQ(m482, 18133353539446801470ULL); EXPECT_EQ(m483, 12289671425080350052ULL); - Aesi512 m491 = "0xfa56fb5e3d0c01e3", m492 = "0xfc45d62e6351335b", m493 = "0x9b99b10ee0300918"; EXPECT_EQ(m491, 18038881739648795107ULL); EXPECT_EQ(m492, 18178170965673980763ULL); EXPECT_EQ(m493, 11212187424764463384ULL); - -#ifdef NDEBUG - Logging::addRecord("Hexadecimal_initialization", - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/operations/integral_cast.cpp b/test/operations/integral_cast.cpp deleted file mode 100644 index 27e532d..0000000 --- a/test/operations/integral_cast.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Casting, IntegralCast) { - const auto timeStart = std::chrono::system_clock::now(); - - { - short v0 = 12660; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - short v1 = 1291; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - short v2 = 9379; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - short v3 = -5507; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - short v4 = 10503; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - short v5 = -15803; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - short v6 = -25434; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - short v7 = 31225; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - short v8 = 27368; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - short v9 = 3854; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - short v10 = -31821; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - short v11 = -14224; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - short v12 = 16812; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - short v13 = 24874; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - short v14 = 18866; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - short v15 = -14076; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - short v16 = 31911; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - short v17 = -8633; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - short v18 = 18120; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - short v19 = 3968; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - unsigned short v0 = 1941; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - unsigned short v1 = 65126; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - unsigned short v2 = 31635; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - unsigned short v3 = 57499; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - unsigned short v4 = 38058; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - unsigned short v5 = 63039; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - unsigned short v6 = 8296; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - unsigned short v7 = 24236; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - unsigned short v8 = 29619; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - unsigned short v9 = 60555; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - unsigned short v10 = 38254; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - unsigned short v11 = 59479; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - unsigned short v12 = 63392; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - unsigned short v13 = 25152; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - unsigned short v14 = 3758; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - unsigned short v15 = 18321; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - unsigned short v16 = 39353; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - unsigned short v17 = 8739; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - unsigned short v18 = 42112; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - unsigned short v19 = 19620; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - int v0 = 1633072347; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - int v1 = 1373045468; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - int v2 = -168273879; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - int v3 = 1946447499; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - int v4 = -182071435; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - int v5 = 1000724497; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - int v6 = 690522175; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - int v7 = 2085869570; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - int v8 = 1710099476; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - int v9 = -1830783184; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - int v10 = 1171383165; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - int v11 = -1751249685; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - int v12 = -1668504170; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - int v13 = -241908811; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - int v14 = 540291974; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - int v15 = -1643457674; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - int v16 = 902106685; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - int v17 = -39871497; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - int v18 = 888304759; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - int v19 = 1568953909; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - unsigned v0 = 2005690205; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - unsigned v1 = 1449627982; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - unsigned v2 = 1101302552; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - unsigned v3 = 595765511; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - unsigned v4 = 3553780719; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - unsigned v5 = 1594854713; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - unsigned v6 = 1443312011; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - unsigned v7 = 4050435786; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - unsigned v8 = 2322528604; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - unsigned v9 = 659532747; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - unsigned v10 = 4162423578; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - unsigned v11 = 2641111926; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - unsigned v12 = 4253288915; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - unsigned v13 = 3110878193; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - unsigned v14 = 587696870; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - unsigned v15 = 1153568748; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - unsigned v16 = 4175266679; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - unsigned v17 = 346810525; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - unsigned v18 = 274355692; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - unsigned v19 = 3087867327; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - long v0 = 634812322182757621; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - long v1 = -927449906461017615; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - long v2 = -3504628980837960044; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - long v3 = -2155375560745272488; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - long v4 = -6526318726215051137; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - long v5 = -2694746162811842986; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - long v6 = 1631485759082327833; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - long v7 = 8407645366062381801; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - long v8 = 5841857305468410835; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - long v9 = 9165801435086311778; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - long v10 = 7049900736852272389; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - long v11 = -1116039134974475934; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - long v12 = 6134624124941989956; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - long v13 = -1989814207699167888; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - long v14 = -5162674662935837073; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - long v15 = 361978787381322157; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - long v16 = 2358318038699402381; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - long v17 = 6721455152406516439; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - long v18 = 6240728962025263647; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - long v19 = -7516849453343319431; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - unsigned long v0 = 1458432336447339549UL; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - unsigned long v1 = 15166986956279526495UL; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - unsigned long v2 = 843907744079905873UL; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - unsigned long v3 = 16831641047459684976UL; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - unsigned long v4 = 8233716564210995814UL; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - unsigned long v5 = 12056099167404879864UL; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - unsigned long v6 = 9195468763811385966UL; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - unsigned long v7 = 6838015201710322987UL; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - unsigned long v8 = 15909623765770348916UL; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - unsigned long v9 = 580359803260052445UL; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - unsigned long v10 = 1562144106091796071UL; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - unsigned long v11 = 9499213611466063262UL; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - unsigned long v12 = 12515821306029840702UL; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - unsigned long v13 = 5666922082602738570UL; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - unsigned long v14 = 12546046344820481203UL; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - unsigned long v15 = 13562221276840283927UL; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - unsigned long v16 = 12646097440568072921UL; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - unsigned long v17 = 14099814405939634110UL; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - unsigned long v18 = 13036786147570218084UL; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - unsigned long v19 = 14809679552796761321UL; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - long long v0 = -966320832989284844; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - long long v1 = -2539299047194883024; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - long long v2 = -4072657627411227702; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - long long v3 = 6676151703625450453; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - long long v4 = 6024657647873919769; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - long long v5 = -3436387051813180897; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - long long v6 = -930863918495184864; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - long long v7 = -2648679724062892078; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - long long v8 = 163799229998191542; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - long long v9 = 7096985823516738807; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - long long v10 = 9021468662796673265; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - long long v11 = 7329596342632026139; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - long long v12 = 2830097210272796867; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - long long v13 = -8165373913969389069; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - long long v14 = 1849790133061638302; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - long long v15 = -8953474544892738048; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - long long v16 = -4256943809212026391; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - long long v17 = 5358224103492354631; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - long long v18 = -1353061819987477708; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - long long v19 = 5852270391142351733; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - { - unsigned long long v0 = 7056752338713246902ULL; Aesi512 o0 = v0; EXPECT_EQ(o0.integralCast(), v0); - unsigned long long v1 = 1752111911588599450ULL; Aesi512 o1 = v1; EXPECT_EQ(o1.integralCast(), v1); - unsigned long long v2 = 9479044036425476019ULL; Aesi512 o2 = v2; EXPECT_EQ(o2.integralCast(), v2); - unsigned long long v3 = 5193170295485823118ULL; Aesi512 o3 = v3; EXPECT_EQ(o3.integralCast(), v3); - unsigned long long v4 = 7329594209829406618ULL; Aesi512 o4 = v4; EXPECT_EQ(o4.integralCast(), v4); - unsigned long long v5 = 17408589177287406633ULL; Aesi512 o5 = v5; EXPECT_EQ(o5.integralCast(), v5); - unsigned long long v6 = 10049699202423151920ULL; Aesi512 o6 = v6; EXPECT_EQ(o6.integralCast(), v6); - unsigned long long v7 = 14893142280413871075ULL; Aesi512 o7 = v7; EXPECT_EQ(o7.integralCast(), v7); - unsigned long long v8 = 14477514342547457937ULL; Aesi512 o8 = v8; EXPECT_EQ(o8.integralCast(), v8); - unsigned long long v9 = 14158198760418317512ULL; Aesi512 o9 = v9; EXPECT_EQ(o9.integralCast(), v9); - unsigned long long v10 = 1737450455060823428ULL; Aesi512 o10 = v10; EXPECT_EQ(o10.integralCast(), v10); - unsigned long long v11 = 12956079072589122739ULL; Aesi512 o11 = v11; EXPECT_EQ(o11.integralCast(), v11); - unsigned long long v12 = 15263083373573044880ULL; Aesi512 o12 = v12; EXPECT_EQ(o12.integralCast(), v12); - unsigned long long v13 = 11589228342409016981ULL; Aesi512 o13 = v13; EXPECT_EQ(o13.integralCast(), v13); - unsigned long long v14 = 12279481383607276825ULL; Aesi512 o14 = v14; EXPECT_EQ(o14.integralCast(), v14); - unsigned long long v15 = 11338438110938113974ULL; Aesi512 o15 = v15; EXPECT_EQ(o15.integralCast(), v15); - unsigned long long v16 = 14528990072287077479ULL; Aesi512 o16 = v16; EXPECT_EQ(o16.integralCast(), v16); - unsigned long long v17 = 13754684638618159726ULL; Aesi512 o17 = v17; EXPECT_EQ(o17.integralCast(), v17); - unsigned long long v18 = 6821012615472018674ULL; Aesi512 o18 = v18; EXPECT_EQ(o18.integralCast(), v18); - unsigned long long v19 = 5576836686719978266ULL; Aesi512 o19 = v19; EXPECT_EQ(o19.integralCast(), v19); - } - - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/operations/precision_cast.cpp b/test/operations/precision_cast.cpp deleted file mode 100644 index 9dc7048..0000000 --- a/test/operations/precision_cast.cpp +++ /dev/null @@ -1,315 +0,0 @@ -#include -#include "../../Aesi.h" -#include "../benchmarks/benchmarks.h" - -TEST(Casting, PrecisionCast) { - const auto timeStart = std::chrono::system_clock::now(); - - long long init0 = 7524839891475014690; Aesi256 m0 = init0; - EXPECT_EQ(m0.precisionCast<288>(), init0); EXPECT_EQ(m0.precisionCast<320>(), init0); EXPECT_EQ(m0.precisionCast<352>(), init0); EXPECT_EQ(m0.precisionCast<384>(), init0); - EXPECT_EQ(m0.precisionCast<416>(), init0); EXPECT_EQ(m0.precisionCast<448>(), init0); EXPECT_EQ(m0.precisionCast<480>(), init0); EXPECT_EQ(m0.precisionCast<512>(), init0); - EXPECT_EQ(m0.precisionCast<544>(), init0); EXPECT_EQ(m0.precisionCast<576>(), init0); EXPECT_EQ(m0.precisionCast<608>(), init0); EXPECT_EQ(m0.precisionCast<640>(), init0); - EXPECT_EQ(m0.precisionCast<672>(), init0); EXPECT_EQ(m0.precisionCast<704>(), init0); EXPECT_EQ(m0.precisionCast<736>(), init0); EXPECT_EQ(m0.precisionCast<768>(), init0); - EXPECT_EQ(m0.precisionCast<800>(), init0); EXPECT_EQ(m0.precisionCast<832>(), init0); EXPECT_EQ(m0.precisionCast<864>(), init0); EXPECT_EQ(m0.precisionCast<896>(), init0); - - - long long init1 = 8504238977266685499; Aesi256 m1 = init1; - EXPECT_EQ(m1.precisionCast<288>(), init1); EXPECT_EQ(m1.precisionCast<320>(), init1); EXPECT_EQ(m1.precisionCast<352>(), init1); EXPECT_EQ(m1.precisionCast<384>(), init1); - EXPECT_EQ(m1.precisionCast<416>(), init1); EXPECT_EQ(m1.precisionCast<448>(), init1); EXPECT_EQ(m1.precisionCast<480>(), init1); EXPECT_EQ(m1.precisionCast<512>(), init1); - EXPECT_EQ(m1.precisionCast<544>(), init1); EXPECT_EQ(m1.precisionCast<576>(), init1); EXPECT_EQ(m1.precisionCast<608>(), init1); EXPECT_EQ(m1.precisionCast<640>(), init1); - EXPECT_EQ(m1.precisionCast<672>(), init1); EXPECT_EQ(m1.precisionCast<704>(), init1); EXPECT_EQ(m1.precisionCast<736>(), init1); EXPECT_EQ(m1.precisionCast<768>(), init1); - EXPECT_EQ(m1.precisionCast<800>(), init1); EXPECT_EQ(m1.precisionCast<832>(), init1); EXPECT_EQ(m1.precisionCast<864>(), init1); EXPECT_EQ(m1.precisionCast<896>(), init1); - - - long long init2 = -7698721489817646536; Aesi256 m2 = init2; - EXPECT_EQ(m2.precisionCast<288>(), init2); EXPECT_EQ(m2.precisionCast<320>(), init2); EXPECT_EQ(m2.precisionCast<352>(), init2); EXPECT_EQ(m2.precisionCast<384>(), init2); - EXPECT_EQ(m2.precisionCast<416>(), init2); EXPECT_EQ(m2.precisionCast<448>(), init2); EXPECT_EQ(m2.precisionCast<480>(), init2); EXPECT_EQ(m2.precisionCast<512>(), init2); - EXPECT_EQ(m2.precisionCast<544>(), init2); EXPECT_EQ(m2.precisionCast<576>(), init2); EXPECT_EQ(m2.precisionCast<608>(), init2); EXPECT_EQ(m2.precisionCast<640>(), init2); - EXPECT_EQ(m2.precisionCast<672>(), init2); EXPECT_EQ(m2.precisionCast<704>(), init2); EXPECT_EQ(m2.precisionCast<736>(), init2); EXPECT_EQ(m2.precisionCast<768>(), init2); - EXPECT_EQ(m2.precisionCast<800>(), init2); EXPECT_EQ(m2.precisionCast<832>(), init2); EXPECT_EQ(m2.precisionCast<864>(), init2); EXPECT_EQ(m2.precisionCast<896>(), init2); - - - long long init3 = -6306961477277496307; Aesi256 m3 = init3; - EXPECT_EQ(m3.precisionCast<288>(), init3); EXPECT_EQ(m3.precisionCast<320>(), init3); EXPECT_EQ(m3.precisionCast<352>(), init3); EXPECT_EQ(m3.precisionCast<384>(), init3); - EXPECT_EQ(m3.precisionCast<416>(), init3); EXPECT_EQ(m3.precisionCast<448>(), init3); EXPECT_EQ(m3.precisionCast<480>(), init3); EXPECT_EQ(m3.precisionCast<512>(), init3); - EXPECT_EQ(m3.precisionCast<544>(), init3); EXPECT_EQ(m3.precisionCast<576>(), init3); EXPECT_EQ(m3.precisionCast<608>(), init3); EXPECT_EQ(m3.precisionCast<640>(), init3); - EXPECT_EQ(m3.precisionCast<672>(), init3); EXPECT_EQ(m3.precisionCast<704>(), init3); EXPECT_EQ(m3.precisionCast<736>(), init3); EXPECT_EQ(m3.precisionCast<768>(), init3); - EXPECT_EQ(m3.precisionCast<800>(), init3); EXPECT_EQ(m3.precisionCast<832>(), init3); EXPECT_EQ(m3.precisionCast<864>(), init3); EXPECT_EQ(m3.precisionCast<896>(), init3); - - - long long init4 = -1439223510727390957; Aesi256 m4 = init4; - EXPECT_EQ(m4.precisionCast<288>(), init4); EXPECT_EQ(m4.precisionCast<320>(), init4); EXPECT_EQ(m4.precisionCast<352>(), init4); EXPECT_EQ(m4.precisionCast<384>(), init4); - EXPECT_EQ(m4.precisionCast<416>(), init4); EXPECT_EQ(m4.precisionCast<448>(), init4); EXPECT_EQ(m4.precisionCast<480>(), init4); EXPECT_EQ(m4.precisionCast<512>(), init4); - EXPECT_EQ(m4.precisionCast<544>(), init4); EXPECT_EQ(m4.precisionCast<576>(), init4); EXPECT_EQ(m4.precisionCast<608>(), init4); EXPECT_EQ(m4.precisionCast<640>(), init4); - EXPECT_EQ(m4.precisionCast<672>(), init4); EXPECT_EQ(m4.precisionCast<704>(), init4); EXPECT_EQ(m4.precisionCast<736>(), init4); EXPECT_EQ(m4.precisionCast<768>(), init4); - EXPECT_EQ(m4.precisionCast<800>(), init4); EXPECT_EQ(m4.precisionCast<832>(), init4); EXPECT_EQ(m4.precisionCast<864>(), init4); EXPECT_EQ(m4.precisionCast<896>(), init4); - - - long long init5 = -9108790223466577088; Aesi256 m5 = init5; - EXPECT_EQ(m5.precisionCast<288>(), init5); EXPECT_EQ(m5.precisionCast<320>(), init5); EXPECT_EQ(m5.precisionCast<352>(), init5); EXPECT_EQ(m5.precisionCast<384>(), init5); - EXPECT_EQ(m5.precisionCast<416>(), init5); EXPECT_EQ(m5.precisionCast<448>(), init5); EXPECT_EQ(m5.precisionCast<480>(), init5); EXPECT_EQ(m5.precisionCast<512>(), init5); - EXPECT_EQ(m5.precisionCast<544>(), init5); EXPECT_EQ(m5.precisionCast<576>(), init5); EXPECT_EQ(m5.precisionCast<608>(), init5); EXPECT_EQ(m5.precisionCast<640>(), init5); - EXPECT_EQ(m5.precisionCast<672>(), init5); EXPECT_EQ(m5.precisionCast<704>(), init5); EXPECT_EQ(m5.precisionCast<736>(), init5); EXPECT_EQ(m5.precisionCast<768>(), init5); - EXPECT_EQ(m5.precisionCast<800>(), init5); EXPECT_EQ(m5.precisionCast<832>(), init5); EXPECT_EQ(m5.precisionCast<864>(), init5); EXPECT_EQ(m5.precisionCast<896>(), init5); - - - long long init6 = 7336368703164388051; Aesi256 m6 = init6; - EXPECT_EQ(m6.precisionCast<288>(), init6); EXPECT_EQ(m6.precisionCast<320>(), init6); EXPECT_EQ(m6.precisionCast<352>(), init6); EXPECT_EQ(m6.precisionCast<384>(), init6); - EXPECT_EQ(m6.precisionCast<416>(), init6); EXPECT_EQ(m6.precisionCast<448>(), init6); EXPECT_EQ(m6.precisionCast<480>(), init6); EXPECT_EQ(m6.precisionCast<512>(), init6); - EXPECT_EQ(m6.precisionCast<544>(), init6); EXPECT_EQ(m6.precisionCast<576>(), init6); EXPECT_EQ(m6.precisionCast<608>(), init6); EXPECT_EQ(m6.precisionCast<640>(), init6); - EXPECT_EQ(m6.precisionCast<672>(), init6); EXPECT_EQ(m6.precisionCast<704>(), init6); EXPECT_EQ(m6.precisionCast<736>(), init6); EXPECT_EQ(m6.precisionCast<768>(), init6); - EXPECT_EQ(m6.precisionCast<800>(), init6); EXPECT_EQ(m6.precisionCast<832>(), init6); EXPECT_EQ(m6.precisionCast<864>(), init6); EXPECT_EQ(m6.precisionCast<896>(), init6); - - - long long init7 = 2314166570054255036; Aesi256 m7 = init7; - EXPECT_EQ(m7.precisionCast<288>(), init7); EXPECT_EQ(m7.precisionCast<320>(), init7); EXPECT_EQ(m7.precisionCast<352>(), init7); EXPECT_EQ(m7.precisionCast<384>(), init7); - EXPECT_EQ(m7.precisionCast<416>(), init7); EXPECT_EQ(m7.precisionCast<448>(), init7); EXPECT_EQ(m7.precisionCast<480>(), init7); EXPECT_EQ(m7.precisionCast<512>(), init7); - EXPECT_EQ(m7.precisionCast<544>(), init7); EXPECT_EQ(m7.precisionCast<576>(), init7); EXPECT_EQ(m7.precisionCast<608>(), init7); EXPECT_EQ(m7.precisionCast<640>(), init7); - EXPECT_EQ(m7.precisionCast<672>(), init7); EXPECT_EQ(m7.precisionCast<704>(), init7); EXPECT_EQ(m7.precisionCast<736>(), init7); EXPECT_EQ(m7.precisionCast<768>(), init7); - EXPECT_EQ(m7.precisionCast<800>(), init7); EXPECT_EQ(m7.precisionCast<832>(), init7); EXPECT_EQ(m7.precisionCast<864>(), init7); EXPECT_EQ(m7.precisionCast<896>(), init7); - - - long long init8 = 7305419937287767522; Aesi256 m8 = init8; - EXPECT_EQ(m8.precisionCast<288>(), init8); EXPECT_EQ(m8.precisionCast<320>(), init8); EXPECT_EQ(m8.precisionCast<352>(), init8); EXPECT_EQ(m8.precisionCast<384>(), init8); - EXPECT_EQ(m8.precisionCast<416>(), init8); EXPECT_EQ(m8.precisionCast<448>(), init8); EXPECT_EQ(m8.precisionCast<480>(), init8); EXPECT_EQ(m8.precisionCast<512>(), init8); - EXPECT_EQ(m8.precisionCast<544>(), init8); EXPECT_EQ(m8.precisionCast<576>(), init8); EXPECT_EQ(m8.precisionCast<608>(), init8); EXPECT_EQ(m8.precisionCast<640>(), init8); - EXPECT_EQ(m8.precisionCast<672>(), init8); EXPECT_EQ(m8.precisionCast<704>(), init8); EXPECT_EQ(m8.precisionCast<736>(), init8); EXPECT_EQ(m8.precisionCast<768>(), init8); - EXPECT_EQ(m8.precisionCast<800>(), init8); EXPECT_EQ(m8.precisionCast<832>(), init8); EXPECT_EQ(m8.precisionCast<864>(), init8); EXPECT_EQ(m8.precisionCast<896>(), init8); - - - long long init9 = -2561303725389650172; Aesi256 m9 = init9; - EXPECT_EQ(m9.precisionCast<288>(), init9); EXPECT_EQ(m9.precisionCast<320>(), init9); EXPECT_EQ(m9.precisionCast<352>(), init9); EXPECT_EQ(m9.precisionCast<384>(), init9); - EXPECT_EQ(m9.precisionCast<416>(), init9); EXPECT_EQ(m9.precisionCast<448>(), init9); EXPECT_EQ(m9.precisionCast<480>(), init9); EXPECT_EQ(m9.precisionCast<512>(), init9); - EXPECT_EQ(m9.precisionCast<544>(), init9); EXPECT_EQ(m9.precisionCast<576>(), init9); EXPECT_EQ(m9.precisionCast<608>(), init9); EXPECT_EQ(m9.precisionCast<640>(), init9); - EXPECT_EQ(m9.precisionCast<672>(), init9); EXPECT_EQ(m9.precisionCast<704>(), init9); EXPECT_EQ(m9.precisionCast<736>(), init9); EXPECT_EQ(m9.precisionCast<768>(), init9); - EXPECT_EQ(m9.precisionCast<800>(), init9); EXPECT_EQ(m9.precisionCast<832>(), init9); EXPECT_EQ(m9.precisionCast<864>(), init9); EXPECT_EQ(m9.precisionCast<896>(), init9); - - - long long init10 = 3383802386880547846; Aesi256 m10 = init10; - EXPECT_EQ(m10.precisionCast<288>(), init10); EXPECT_EQ(m10.precisionCast<320>(), init10); EXPECT_EQ(m10.precisionCast<352>(), init10); EXPECT_EQ(m10.precisionCast<384>(), init10); - EXPECT_EQ(m10.precisionCast<416>(), init10); EXPECT_EQ(m10.precisionCast<448>(), init10); EXPECT_EQ(m10.precisionCast<480>(), init10); EXPECT_EQ(m10.precisionCast<512>(), init10); - EXPECT_EQ(m10.precisionCast<544>(), init10); EXPECT_EQ(m10.precisionCast<576>(), init10); EXPECT_EQ(m10.precisionCast<608>(), init10); EXPECT_EQ(m10.precisionCast<640>(), init10); - EXPECT_EQ(m10.precisionCast<672>(), init10); EXPECT_EQ(m10.precisionCast<704>(), init10); EXPECT_EQ(m10.precisionCast<736>(), init10); EXPECT_EQ(m10.precisionCast<768>(), init10); - EXPECT_EQ(m10.precisionCast<800>(), init10); EXPECT_EQ(m10.precisionCast<832>(), init10); EXPECT_EQ(m10.precisionCast<864>(), init10); EXPECT_EQ(m10.precisionCast<896>(), init10); - - - long long init11 = 5703252986956204740; Aesi256 m11 = init11; - EXPECT_EQ(m11.precisionCast<288>(), init11); EXPECT_EQ(m11.precisionCast<320>(), init11); EXPECT_EQ(m11.precisionCast<352>(), init11); EXPECT_EQ(m11.precisionCast<384>(), init11); - EXPECT_EQ(m11.precisionCast<416>(), init11); EXPECT_EQ(m11.precisionCast<448>(), init11); EXPECT_EQ(m11.precisionCast<480>(), init11); EXPECT_EQ(m11.precisionCast<512>(), init11); - EXPECT_EQ(m11.precisionCast<544>(), init11); EXPECT_EQ(m11.precisionCast<576>(), init11); EXPECT_EQ(m11.precisionCast<608>(), init11); EXPECT_EQ(m11.precisionCast<640>(), init11); - EXPECT_EQ(m11.precisionCast<672>(), init11); EXPECT_EQ(m11.precisionCast<704>(), init11); EXPECT_EQ(m11.precisionCast<736>(), init11); EXPECT_EQ(m11.precisionCast<768>(), init11); - EXPECT_EQ(m11.precisionCast<800>(), init11); EXPECT_EQ(m11.precisionCast<832>(), init11); EXPECT_EQ(m11.precisionCast<864>(), init11); EXPECT_EQ(m11.precisionCast<896>(), init11); - - - long long init12 = 1248358330450460190; Aesi256 m12 = init12; - EXPECT_EQ(m12.precisionCast<288>(), init12); EXPECT_EQ(m12.precisionCast<320>(), init12); EXPECT_EQ(m12.precisionCast<352>(), init12); EXPECT_EQ(m12.precisionCast<384>(), init12); - EXPECT_EQ(m12.precisionCast<416>(), init12); EXPECT_EQ(m12.precisionCast<448>(), init12); EXPECT_EQ(m12.precisionCast<480>(), init12); EXPECT_EQ(m12.precisionCast<512>(), init12); - EXPECT_EQ(m12.precisionCast<544>(), init12); EXPECT_EQ(m12.precisionCast<576>(), init12); EXPECT_EQ(m12.precisionCast<608>(), init12); EXPECT_EQ(m12.precisionCast<640>(), init12); - EXPECT_EQ(m12.precisionCast<672>(), init12); EXPECT_EQ(m12.precisionCast<704>(), init12); EXPECT_EQ(m12.precisionCast<736>(), init12); EXPECT_EQ(m12.precisionCast<768>(), init12); - EXPECT_EQ(m12.precisionCast<800>(), init12); EXPECT_EQ(m12.precisionCast<832>(), init12); EXPECT_EQ(m12.precisionCast<864>(), init12); EXPECT_EQ(m12.precisionCast<896>(), init12); - - - long long init13 = 4175697953158773741; Aesi256 m13 = init13; - EXPECT_EQ(m13.precisionCast<288>(), init13); EXPECT_EQ(m13.precisionCast<320>(), init13); EXPECT_EQ(m13.precisionCast<352>(), init13); EXPECT_EQ(m13.precisionCast<384>(), init13); - EXPECT_EQ(m13.precisionCast<416>(), init13); EXPECT_EQ(m13.precisionCast<448>(), init13); EXPECT_EQ(m13.precisionCast<480>(), init13); EXPECT_EQ(m13.precisionCast<512>(), init13); - EXPECT_EQ(m13.precisionCast<544>(), init13); EXPECT_EQ(m13.precisionCast<576>(), init13); EXPECT_EQ(m13.precisionCast<608>(), init13); EXPECT_EQ(m13.precisionCast<640>(), init13); - EXPECT_EQ(m13.precisionCast<672>(), init13); EXPECT_EQ(m13.precisionCast<704>(), init13); EXPECT_EQ(m13.precisionCast<736>(), init13); EXPECT_EQ(m13.precisionCast<768>(), init13); - EXPECT_EQ(m13.precisionCast<800>(), init13); EXPECT_EQ(m13.precisionCast<832>(), init13); EXPECT_EQ(m13.precisionCast<864>(), init13); EXPECT_EQ(m13.precisionCast<896>(), init13); - - - long long init14 = -2938517079411100489; Aesi256 m14 = init14; - EXPECT_EQ(m14.precisionCast<288>(), init14); EXPECT_EQ(m14.precisionCast<320>(), init14); EXPECT_EQ(m14.precisionCast<352>(), init14); EXPECT_EQ(m14.precisionCast<384>(), init14); - EXPECT_EQ(m14.precisionCast<416>(), init14); EXPECT_EQ(m14.precisionCast<448>(), init14); EXPECT_EQ(m14.precisionCast<480>(), init14); EXPECT_EQ(m14.precisionCast<512>(), init14); - EXPECT_EQ(m14.precisionCast<544>(), init14); EXPECT_EQ(m14.precisionCast<576>(), init14); EXPECT_EQ(m14.precisionCast<608>(), init14); EXPECT_EQ(m14.precisionCast<640>(), init14); - EXPECT_EQ(m14.precisionCast<672>(), init14); EXPECT_EQ(m14.precisionCast<704>(), init14); EXPECT_EQ(m14.precisionCast<736>(), init14); EXPECT_EQ(m14.precisionCast<768>(), init14); - EXPECT_EQ(m14.precisionCast<800>(), init14); EXPECT_EQ(m14.precisionCast<832>(), init14); EXPECT_EQ(m14.precisionCast<864>(), init14); EXPECT_EQ(m14.precisionCast<896>(), init14); - - - long long init15 = -6902692574326511305; Aesi256 m15 = init15; - EXPECT_EQ(m15.precisionCast<288>(), init15); EXPECT_EQ(m15.precisionCast<320>(), init15); EXPECT_EQ(m15.precisionCast<352>(), init15); EXPECT_EQ(m15.precisionCast<384>(), init15); - EXPECT_EQ(m15.precisionCast<416>(), init15); EXPECT_EQ(m15.precisionCast<448>(), init15); EXPECT_EQ(m15.precisionCast<480>(), init15); EXPECT_EQ(m15.precisionCast<512>(), init15); - EXPECT_EQ(m15.precisionCast<544>(), init15); EXPECT_EQ(m15.precisionCast<576>(), init15); EXPECT_EQ(m15.precisionCast<608>(), init15); EXPECT_EQ(m15.precisionCast<640>(), init15); - EXPECT_EQ(m15.precisionCast<672>(), init15); EXPECT_EQ(m15.precisionCast<704>(), init15); EXPECT_EQ(m15.precisionCast<736>(), init15); EXPECT_EQ(m15.precisionCast<768>(), init15); - EXPECT_EQ(m15.precisionCast<800>(), init15); EXPECT_EQ(m15.precisionCast<832>(), init15); EXPECT_EQ(m15.precisionCast<864>(), init15); EXPECT_EQ(m15.precisionCast<896>(), init15); - - - long long init16 = -2409078837645875887; Aesi256 m16 = init16; - EXPECT_EQ(m16.precisionCast<288>(), init16); EXPECT_EQ(m16.precisionCast<320>(), init16); EXPECT_EQ(m16.precisionCast<352>(), init16); EXPECT_EQ(m16.precisionCast<384>(), init16); - EXPECT_EQ(m16.precisionCast<416>(), init16); EXPECT_EQ(m16.precisionCast<448>(), init16); EXPECT_EQ(m16.precisionCast<480>(), init16); EXPECT_EQ(m16.precisionCast<512>(), init16); - EXPECT_EQ(m16.precisionCast<544>(), init16); EXPECT_EQ(m16.precisionCast<576>(), init16); EXPECT_EQ(m16.precisionCast<608>(), init16); EXPECT_EQ(m16.precisionCast<640>(), init16); - EXPECT_EQ(m16.precisionCast<672>(), init16); EXPECT_EQ(m16.precisionCast<704>(), init16); EXPECT_EQ(m16.precisionCast<736>(), init16); EXPECT_EQ(m16.precisionCast<768>(), init16); - EXPECT_EQ(m16.precisionCast<800>(), init16); EXPECT_EQ(m16.precisionCast<832>(), init16); EXPECT_EQ(m16.precisionCast<864>(), init16); EXPECT_EQ(m16.precisionCast<896>(), init16); - - - long long init17 = -7506774356715976030; Aesi256 m17 = init17; - EXPECT_EQ(m17.precisionCast<288>(), init17); EXPECT_EQ(m17.precisionCast<320>(), init17); EXPECT_EQ(m17.precisionCast<352>(), init17); EXPECT_EQ(m17.precisionCast<384>(), init17); - EXPECT_EQ(m17.precisionCast<416>(), init17); EXPECT_EQ(m17.precisionCast<448>(), init17); EXPECT_EQ(m17.precisionCast<480>(), init17); EXPECT_EQ(m17.precisionCast<512>(), init17); - EXPECT_EQ(m17.precisionCast<544>(), init17); EXPECT_EQ(m17.precisionCast<576>(), init17); EXPECT_EQ(m17.precisionCast<608>(), init17); EXPECT_EQ(m17.precisionCast<640>(), init17); - EXPECT_EQ(m17.precisionCast<672>(), init17); EXPECT_EQ(m17.precisionCast<704>(), init17); EXPECT_EQ(m17.precisionCast<736>(), init17); EXPECT_EQ(m17.precisionCast<768>(), init17); - EXPECT_EQ(m17.precisionCast<800>(), init17); EXPECT_EQ(m17.precisionCast<832>(), init17); EXPECT_EQ(m17.precisionCast<864>(), init17); EXPECT_EQ(m17.precisionCast<896>(), init17); - - - long long init18 = 227163478686314711; Aesi256 m18 = init18; - EXPECT_EQ(m18.precisionCast<288>(), init18); EXPECT_EQ(m18.precisionCast<320>(), init18); EXPECT_EQ(m18.precisionCast<352>(), init18); EXPECT_EQ(m18.precisionCast<384>(), init18); - EXPECT_EQ(m18.precisionCast<416>(), init18); EXPECT_EQ(m18.precisionCast<448>(), init18); EXPECT_EQ(m18.precisionCast<480>(), init18); EXPECT_EQ(m18.precisionCast<512>(), init18); - EXPECT_EQ(m18.precisionCast<544>(), init18); EXPECT_EQ(m18.precisionCast<576>(), init18); EXPECT_EQ(m18.precisionCast<608>(), init18); EXPECT_EQ(m18.precisionCast<640>(), init18); - EXPECT_EQ(m18.precisionCast<672>(), init18); EXPECT_EQ(m18.precisionCast<704>(), init18); EXPECT_EQ(m18.precisionCast<736>(), init18); EXPECT_EQ(m18.precisionCast<768>(), init18); - EXPECT_EQ(m18.precisionCast<800>(), init18); EXPECT_EQ(m18.precisionCast<832>(), init18); EXPECT_EQ(m18.precisionCast<864>(), init18); EXPECT_EQ(m18.precisionCast<896>(), init18); - - - long long init19 = -4966632676207774604; Aesi256 m19 = init19; - EXPECT_EQ(m19.precisionCast<288>(), init19); EXPECT_EQ(m19.precisionCast<320>(), init19); EXPECT_EQ(m19.precisionCast<352>(), init19); EXPECT_EQ(m19.precisionCast<384>(), init19); - EXPECT_EQ(m19.precisionCast<416>(), init19); EXPECT_EQ(m19.precisionCast<448>(), init19); EXPECT_EQ(m19.precisionCast<480>(), init19); EXPECT_EQ(m19.precisionCast<512>(), init19); - EXPECT_EQ(m19.precisionCast<544>(), init19); EXPECT_EQ(m19.precisionCast<576>(), init19); EXPECT_EQ(m19.precisionCast<608>(), init19); EXPECT_EQ(m19.precisionCast<640>(), init19); - EXPECT_EQ(m19.precisionCast<672>(), init19); EXPECT_EQ(m19.precisionCast<704>(), init19); EXPECT_EQ(m19.precisionCast<736>(), init19); EXPECT_EQ(m19.precisionCast<768>(), init19); - EXPECT_EQ(m19.precisionCast<800>(), init19); EXPECT_EQ(m19.precisionCast<832>(), init19); EXPECT_EQ(m19.precisionCast<864>(), init19); EXPECT_EQ(m19.precisionCast<896>(), init19); - - - long long init20 = -4021786551316732423; Aesi256 m20 = init20; - EXPECT_EQ(m20.precisionCast<288>(), init20); EXPECT_EQ(m20.precisionCast<320>(), init20); EXPECT_EQ(m20.precisionCast<352>(), init20); EXPECT_EQ(m20.precisionCast<384>(), init20); - EXPECT_EQ(m20.precisionCast<416>(), init20); EXPECT_EQ(m20.precisionCast<448>(), init20); EXPECT_EQ(m20.precisionCast<480>(), init20); EXPECT_EQ(m20.precisionCast<512>(), init20); - EXPECT_EQ(m20.precisionCast<544>(), init20); EXPECT_EQ(m20.precisionCast<576>(), init20); EXPECT_EQ(m20.precisionCast<608>(), init20); EXPECT_EQ(m20.precisionCast<640>(), init20); - EXPECT_EQ(m20.precisionCast<672>(), init20); EXPECT_EQ(m20.precisionCast<704>(), init20); EXPECT_EQ(m20.precisionCast<736>(), init20); EXPECT_EQ(m20.precisionCast<768>(), init20); - EXPECT_EQ(m20.precisionCast<800>(), init20); EXPECT_EQ(m20.precisionCast<832>(), init20); EXPECT_EQ(m20.precisionCast<864>(), init20); EXPECT_EQ(m20.precisionCast<896>(), init20); - - - long long init21 = 7309039963756908723; Aesi256 m21 = init21; - EXPECT_EQ(m21.precisionCast<288>(), init21); EXPECT_EQ(m21.precisionCast<320>(), init21); EXPECT_EQ(m21.precisionCast<352>(), init21); EXPECT_EQ(m21.precisionCast<384>(), init21); - EXPECT_EQ(m21.precisionCast<416>(), init21); EXPECT_EQ(m21.precisionCast<448>(), init21); EXPECT_EQ(m21.precisionCast<480>(), init21); EXPECT_EQ(m21.precisionCast<512>(), init21); - EXPECT_EQ(m21.precisionCast<544>(), init21); EXPECT_EQ(m21.precisionCast<576>(), init21); EXPECT_EQ(m21.precisionCast<608>(), init21); EXPECT_EQ(m21.precisionCast<640>(), init21); - EXPECT_EQ(m21.precisionCast<672>(), init21); EXPECT_EQ(m21.precisionCast<704>(), init21); EXPECT_EQ(m21.precisionCast<736>(), init21); EXPECT_EQ(m21.precisionCast<768>(), init21); - EXPECT_EQ(m21.precisionCast<800>(), init21); EXPECT_EQ(m21.precisionCast<832>(), init21); EXPECT_EQ(m21.precisionCast<864>(), init21); EXPECT_EQ(m21.precisionCast<896>(), init21); - - - long long init22 = -4037333522000484564; Aesi256 m22 = init22; - EXPECT_EQ(m22.precisionCast<288>(), init22); EXPECT_EQ(m22.precisionCast<320>(), init22); EXPECT_EQ(m22.precisionCast<352>(), init22); EXPECT_EQ(m22.precisionCast<384>(), init22); - EXPECT_EQ(m22.precisionCast<416>(), init22); EXPECT_EQ(m22.precisionCast<448>(), init22); EXPECT_EQ(m22.precisionCast<480>(), init22); EXPECT_EQ(m22.precisionCast<512>(), init22); - EXPECT_EQ(m22.precisionCast<544>(), init22); EXPECT_EQ(m22.precisionCast<576>(), init22); EXPECT_EQ(m22.precisionCast<608>(), init22); EXPECT_EQ(m22.precisionCast<640>(), init22); - EXPECT_EQ(m22.precisionCast<672>(), init22); EXPECT_EQ(m22.precisionCast<704>(), init22); EXPECT_EQ(m22.precisionCast<736>(), init22); EXPECT_EQ(m22.precisionCast<768>(), init22); - EXPECT_EQ(m22.precisionCast<800>(), init22); EXPECT_EQ(m22.precisionCast<832>(), init22); EXPECT_EQ(m22.precisionCast<864>(), init22); EXPECT_EQ(m22.precisionCast<896>(), init22); - - - long long init23 = 3067962240659289255; Aesi256 m23 = init23; - EXPECT_EQ(m23.precisionCast<288>(), init23); EXPECT_EQ(m23.precisionCast<320>(), init23); EXPECT_EQ(m23.precisionCast<352>(), init23); EXPECT_EQ(m23.precisionCast<384>(), init23); - EXPECT_EQ(m23.precisionCast<416>(), init23); EXPECT_EQ(m23.precisionCast<448>(), init23); EXPECT_EQ(m23.precisionCast<480>(), init23); EXPECT_EQ(m23.precisionCast<512>(), init23); - EXPECT_EQ(m23.precisionCast<544>(), init23); EXPECT_EQ(m23.precisionCast<576>(), init23); EXPECT_EQ(m23.precisionCast<608>(), init23); EXPECT_EQ(m23.precisionCast<640>(), init23); - EXPECT_EQ(m23.precisionCast<672>(), init23); EXPECT_EQ(m23.precisionCast<704>(), init23); EXPECT_EQ(m23.precisionCast<736>(), init23); EXPECT_EQ(m23.precisionCast<768>(), init23); - EXPECT_EQ(m23.precisionCast<800>(), init23); EXPECT_EQ(m23.precisionCast<832>(), init23); EXPECT_EQ(m23.precisionCast<864>(), init23); EXPECT_EQ(m23.precisionCast<896>(), init23); - - - long long init24 = -3707800888550614839; Aesi256 m24 = init24; - EXPECT_EQ(m24.precisionCast<288>(), init24); EXPECT_EQ(m24.precisionCast<320>(), init24); EXPECT_EQ(m24.precisionCast<352>(), init24); EXPECT_EQ(m24.precisionCast<384>(), init24); - EXPECT_EQ(m24.precisionCast<416>(), init24); EXPECT_EQ(m24.precisionCast<448>(), init24); EXPECT_EQ(m24.precisionCast<480>(), init24); EXPECT_EQ(m24.precisionCast<512>(), init24); - EXPECT_EQ(m24.precisionCast<544>(), init24); EXPECT_EQ(m24.precisionCast<576>(), init24); EXPECT_EQ(m24.precisionCast<608>(), init24); EXPECT_EQ(m24.precisionCast<640>(), init24); - EXPECT_EQ(m24.precisionCast<672>(), init24); EXPECT_EQ(m24.precisionCast<704>(), init24); EXPECT_EQ(m24.precisionCast<736>(), init24); EXPECT_EQ(m24.precisionCast<768>(), init24); - EXPECT_EQ(m24.precisionCast<800>(), init24); EXPECT_EQ(m24.precisionCast<832>(), init24); EXPECT_EQ(m24.precisionCast<864>(), init24); EXPECT_EQ(m24.precisionCast<896>(), init24); - - - long long init25 = -6878944643378492415; Aesi256 m25 = init25; - EXPECT_EQ(m25.precisionCast<288>(), init25); EXPECT_EQ(m25.precisionCast<320>(), init25); EXPECT_EQ(m25.precisionCast<352>(), init25); EXPECT_EQ(m25.precisionCast<384>(), init25); - EXPECT_EQ(m25.precisionCast<416>(), init25); EXPECT_EQ(m25.precisionCast<448>(), init25); EXPECT_EQ(m25.precisionCast<480>(), init25); EXPECT_EQ(m25.precisionCast<512>(), init25); - EXPECT_EQ(m25.precisionCast<544>(), init25); EXPECT_EQ(m25.precisionCast<576>(), init25); EXPECT_EQ(m25.precisionCast<608>(), init25); EXPECT_EQ(m25.precisionCast<640>(), init25); - EXPECT_EQ(m25.precisionCast<672>(), init25); EXPECT_EQ(m25.precisionCast<704>(), init25); EXPECT_EQ(m25.precisionCast<736>(), init25); EXPECT_EQ(m25.precisionCast<768>(), init25); - EXPECT_EQ(m25.precisionCast<800>(), init25); EXPECT_EQ(m25.precisionCast<832>(), init25); EXPECT_EQ(m25.precisionCast<864>(), init25); EXPECT_EQ(m25.precisionCast<896>(), init25); - - - long long init26 = -590213465179246446; Aesi256 m26 = init26; - EXPECT_EQ(m26.precisionCast<288>(), init26); EXPECT_EQ(m26.precisionCast<320>(), init26); EXPECT_EQ(m26.precisionCast<352>(), init26); EXPECT_EQ(m26.precisionCast<384>(), init26); - EXPECT_EQ(m26.precisionCast<416>(), init26); EXPECT_EQ(m26.precisionCast<448>(), init26); EXPECT_EQ(m26.precisionCast<480>(), init26); EXPECT_EQ(m26.precisionCast<512>(), init26); - EXPECT_EQ(m26.precisionCast<544>(), init26); EXPECT_EQ(m26.precisionCast<576>(), init26); EXPECT_EQ(m26.precisionCast<608>(), init26); EXPECT_EQ(m26.precisionCast<640>(), init26); - EXPECT_EQ(m26.precisionCast<672>(), init26); EXPECT_EQ(m26.precisionCast<704>(), init26); EXPECT_EQ(m26.precisionCast<736>(), init26); EXPECT_EQ(m26.precisionCast<768>(), init26); - EXPECT_EQ(m26.precisionCast<800>(), init26); EXPECT_EQ(m26.precisionCast<832>(), init26); EXPECT_EQ(m26.precisionCast<864>(), init26); EXPECT_EQ(m26.precisionCast<896>(), init26); - - - long long init27 = 6023706187360170892; Aesi256 m27 = init27; - EXPECT_EQ(m27.precisionCast<288>(), init27); EXPECT_EQ(m27.precisionCast<320>(), init27); EXPECT_EQ(m27.precisionCast<352>(), init27); EXPECT_EQ(m27.precisionCast<384>(), init27); - EXPECT_EQ(m27.precisionCast<416>(), init27); EXPECT_EQ(m27.precisionCast<448>(), init27); EXPECT_EQ(m27.precisionCast<480>(), init27); EXPECT_EQ(m27.precisionCast<512>(), init27); - EXPECT_EQ(m27.precisionCast<544>(), init27); EXPECT_EQ(m27.precisionCast<576>(), init27); EXPECT_EQ(m27.precisionCast<608>(), init27); EXPECT_EQ(m27.precisionCast<640>(), init27); - EXPECT_EQ(m27.precisionCast<672>(), init27); EXPECT_EQ(m27.precisionCast<704>(), init27); EXPECT_EQ(m27.precisionCast<736>(), init27); EXPECT_EQ(m27.precisionCast<768>(), init27); - EXPECT_EQ(m27.precisionCast<800>(), init27); EXPECT_EQ(m27.precisionCast<832>(), init27); EXPECT_EQ(m27.precisionCast<864>(), init27); EXPECT_EQ(m27.precisionCast<896>(), init27); - - - long long init28 = 5869361540369536229; Aesi256 m28 = init28; - EXPECT_EQ(m28.precisionCast<288>(), init28); EXPECT_EQ(m28.precisionCast<320>(), init28); EXPECT_EQ(m28.precisionCast<352>(), init28); EXPECT_EQ(m28.precisionCast<384>(), init28); - EXPECT_EQ(m28.precisionCast<416>(), init28); EXPECT_EQ(m28.precisionCast<448>(), init28); EXPECT_EQ(m28.precisionCast<480>(), init28); EXPECT_EQ(m28.precisionCast<512>(), init28); - EXPECT_EQ(m28.precisionCast<544>(), init28); EXPECT_EQ(m28.precisionCast<576>(), init28); EXPECT_EQ(m28.precisionCast<608>(), init28); EXPECT_EQ(m28.precisionCast<640>(), init28); - EXPECT_EQ(m28.precisionCast<672>(), init28); EXPECT_EQ(m28.precisionCast<704>(), init28); EXPECT_EQ(m28.precisionCast<736>(), init28); EXPECT_EQ(m28.precisionCast<768>(), init28); - EXPECT_EQ(m28.precisionCast<800>(), init28); EXPECT_EQ(m28.precisionCast<832>(), init28); EXPECT_EQ(m28.precisionCast<864>(), init28); EXPECT_EQ(m28.precisionCast<896>(), init28); - - - long long init29 = 1220581244790115876; Aesi256 m29 = init29; - EXPECT_EQ(m29.precisionCast<288>(), init29); EXPECT_EQ(m29.precisionCast<320>(), init29); EXPECT_EQ(m29.precisionCast<352>(), init29); EXPECT_EQ(m29.precisionCast<384>(), init29); - EXPECT_EQ(m29.precisionCast<416>(), init29); EXPECT_EQ(m29.precisionCast<448>(), init29); EXPECT_EQ(m29.precisionCast<480>(), init29); EXPECT_EQ(m29.precisionCast<512>(), init29); - EXPECT_EQ(m29.precisionCast<544>(), init29); EXPECT_EQ(m29.precisionCast<576>(), init29); EXPECT_EQ(m29.precisionCast<608>(), init29); EXPECT_EQ(m29.precisionCast<640>(), init29); - EXPECT_EQ(m29.precisionCast<672>(), init29); EXPECT_EQ(m29.precisionCast<704>(), init29); EXPECT_EQ(m29.precisionCast<736>(), init29); EXPECT_EQ(m29.precisionCast<768>(), init29); - EXPECT_EQ(m29.precisionCast<800>(), init29); EXPECT_EQ(m29.precisionCast<832>(), init29); EXPECT_EQ(m29.precisionCast<864>(), init29); EXPECT_EQ(m29.precisionCast<896>(), init29); - - Aesi < 448 > l0 = "554241380131154142962417280417998404754929828012346097179687246704910303315350311367744175378443304128036758983824324734859979768793199."; - EXPECT_EQ(l0.precisionCast<288>(), "408360527252105534419027813905394704348416525449517229626145092686873334890812834908271."); - Aesi < 576 > l1 = "173149006578507408541558843749803097456182801623666290320265239338181642132588175569300761116459015677654013937947922994294373883893325690805618652779686048163576445320646483."; - EXPECT_EQ(l1.precisionCast<128>(), "210443040993062611785785420324814540627."); - Aesi < 576 > l2 = "66531456573720529442216757952933331047332848598711407403162907502778746277356003198417676048381460115126892609965612607567352416913344652080416627158294298245466839069775512."; - EXPECT_EQ(l2.precisionCast<160>(), "1443229828299692348357792670919834022979176257176."); - Aesi < 384 > l3 = "1098897099174270538478178379535802020226067483295913532002005072123857444388599717512365115154922424475266850503120."; - EXPECT_EQ(l3.precisionCast<320>(), "1913199418936122088346837076981965348887692948209008066197015782466463820230886895375591805565392."); - Aesi < 512 > l4 = "3069476797928086052610870903467024437789501028462434594919744663711449127505497769599003817092647117494652657649787519339440892062605145266124294683385280."; - EXPECT_EQ(l4.precisionCast<288>(), "404126981474586070624526050760237057921124714973395197115667617772232279058850682265024."); - Aesi < 352 > l5 = "2948016904402708200913240914482790524802448562129494737510300849124666954825609112501202095235581771983067."; - EXPECT_EQ(l5.precisionCast<192>(), "1120442763073472009948111228858560283233140945287272409307."); - Aesi < 544 > l6 = "10812628969630480520296504856105212223514943626905130339806055726389997460671652738109321632680730144583156832174036283780045422846847056560092948355830105461452561."; - EXPECT_EQ(l6.precisionCast<128>(), "330342928733391374787712324367724277521."); - Aesi < 544 > l7 = "4112600136041780850943347403651201772866193144792995503451651200434798923608930918174270859878921981299563448120913143826254282006786082095303150341646975970259785."; - EXPECT_EQ(l7.precisionCast<288>(), "257304491601243764544329915240262128843475594535859368626521507218543067528530890011465."); - Aesi < 384 > l8 = "28048835949300858284373720359733481364253247860667645736041649560388756406925265368724245525050388699493492127215396."; - EXPECT_EQ(l8.precisionCast<256>(), "41878091393227431195219434526290235492405672892345774495477168807404321681188."); - Aesi < 640 > l9 = "3848583613533234298953998803964435640019755235139553979562211441430877304606643444685829881598731682613890268054287149783980908651187506403654762887423297734191981318623098337988025363561114940."; - EXPECT_EQ(l9.precisionCast<160>(), "541300877713023860093328693961789219540436446524."); - Aesi < 512 > l10 = "8488462826013523989070679682331534259557436274695014765129319667636222109541019846966725069632607848463488852770772093964627525568328843684570072600088832."; - EXPECT_EQ(l10.precisionCast<160>(), "523538838524052847229876918926034085392282358016."); - Aesi < 576 > l11 = "11236969385546154746878679488297868602806916111627187642798923353498840149284473359875405738278850824908974037092662116610981773121895588572197349961886691945064651776229050."; - EXPECT_EQ(l11.precisionCast<128>(), "29179789164106523943541955618292268730."); - Aesi < 480 > l12 = "924082864945322453283057577897421592990774691137290429034141806501722486590884960785337810624006801980116699350354269354398363040536296529326681."; - EXPECT_EQ(l12.precisionCast<256>(), "15790246827509817793328866413084671789409373095293932456575888129892184748633."); - Aesi < 512 > l13 = "9607535504179656540242447115527397529604623905521687360978734063119313561780639573012578165648934865049773849480530263572594554247909207343890208529325178."; - EXPECT_EQ(l13.precisionCast<96>(), "43716316362024562473758891130."); - Aesi < 352 > l14 = "504397667162110386921588331778312416154169943905827797809093816111203720055808585599403524127547394508185."; - EXPECT_EQ(l14.precisionCast<320>(), "366270022681278488140630850294606110994384776947473041868263123438838372271196545770306825766297."); - Aesi < 544 > l15 = "27608764507031531319380382106462863564782632077695501707054751614193288192180423340509534352068491112085645377731761780973224450169988873068318780343686563718281728."; - EXPECT_EQ(l15.precisionCast<128>(), "299026899257808842617251361117814438400."); - Aesi < 352 > l16 = "1978129624964056450214026876059300487877996643140932950061364608660420356925042564405231900323677600676732."; - EXPECT_EQ(l16.precisionCast<320>(), "365332643823514689801663993143371567677009732484894048068501453581388238598858847283260927441788."); - Aesi < 576 > l17 = "195265355728943716865923619155375969530111891393015085388776834717930166073822658430177349287072569812662023940174467801397134386843815407817766067594355521616265929622366898."; - EXPECT_EQ(l17.precisionCast<160>(), "221431119546753700832094394260270558954283936434."); - Aesi < 448 > l18 = "414657978233561248876686250413054606900177295904410399578041220021615424324810017863916222257119299661647319122459751028412186388057654."; - EXPECT_EQ(l18.precisionCast<160>(), "287129154900729631574915186396319442248636812854."); - Aesi < 416 > l19 = "56687510612260333551549640577823250078355837097233108084669493198465659199087411861462621495608437125573216962137258061197924."; - EXPECT_EQ(l19.precisionCast<192>(), "3671611332121323818239920054049877596259686932276771811940."); - Aesi < 640 > l20 = "1546223449542899971558886608789690118697134740086024592798235620930020323290348765670723997823619247765209481873838363731256837657816604584457400460176692587426042570895554473755247436115230189."; - EXPECT_EQ(l20.precisionCast<320>(), "1705058499460706178048346990812902342294295809567394699482134087317553182108908996873089872575981."); - Aesi < 544 > l21 = "174065680196633578590894771435895688468079098486287540664921962829963159709119456409138894766839898574579608494679948491219544731370758383681896937747086278361071."; - EXPECT_EQ(l21.precisionCast<160>(), "220794710368648048438000780675654519053309411311."); - Aesi < 448 > l22 = "136337341513559528961653942676228706381771186833849367631461720301064785651836843206251270469997623786977461200400063656318366284038665."; - EXPECT_EQ(l22.precisionCast<224>(), "816945909177209805889026909383334983853515920833335341477807047177."); - Aesi < 352 > l23 = "5882616107094423670384170997721509360066167036113934904312412848395219509023523677500755059444938780072409."; - EXPECT_EQ(l23.precisionCast<192>(), "2482927072274059692659564052439247617034525043020273441241."); - Aesi < 576 > l24 = "49857691326617957339080952718292050690932576020199908481126156219200801064319573633766216649464944745473827870799580369859357610319478396095070633417622983092014069297900742."; - EXPECT_EQ(l24.precisionCast<96>(), "20676605872175966156536081606."); - Aesi < 384 > l25 = "28597517267806223597843711502305823530466336309097073757475161768363138442370308787956725565043616828782360287501138."; - EXPECT_EQ(l25.precisionCast<192>(), "2349989946988515365971908154524797542461532293278087240530."); - Aesi < 352 > l26 = "5359709770582948688991943818180669926832250789635927200530270394005210447928718134456374737387522683948933."; - EXPECT_EQ(l26.precisionCast<96>(), "30780870628112076616018546565."); - Aesi < 608 > l27 = "800374186897442994345991532287383427669343624463618411247954314190792985454915883373717659254388118542800958906763592267710368929085300529376043722066941548681087911311229845689540460."; - EXPECT_EQ(l27.precisionCast<128>(), "2854867648611582803837292073272156012."); - Aesi < 384 > l28 = "33405800918446002208040817593884350731087014451427547055891417316377644807769010652297688512536252488106030729965818."; - EXPECT_EQ(l28.precisionCast<224>(), "459273051701248468242064512442751256897801283813240021045830922490."); - Aesi < 448 > l29 = "545136889659423149046640496483142589267039543174772529930583944491083582156213563276447863450923726927200116011820859957964687342869311."; - EXPECT_EQ(l29.precisionCast<224>(), "11564578527812652389272649650310409698199102565460528063263161490239."); - -#ifdef NDEBUG - Logging::addRecord(testing::UnitTest::GetInstance()->current_test_info()->name(), - std::chrono::system_clock::to_time_t(timeStart), - (std::chrono::system_clock::now() - timeStart).count()); -#else - std::cout << "Time estimated: " << (std::chrono::system_clock::now() - timeStart).count() << " ms." << std::endl; -#endif /* NDEBUG */ -} \ No newline at end of file diff --git a/test/operations/prezentation.cpp b/test/operations/prezentation.cpp old mode 100644 new mode 100755 index 9189680..5eaf167 --- a/test/operations/prezentation.cpp +++ b/test/operations/prezentation.cpp @@ -1,14 +1,10 @@ #include -#include "../../Aesi.h" +#include "../../Aeu.h" TEST(Prezentation, Factorial) { - Aesi1024 f = 1; + Aeu1024 f = 1u; for(unsigned i = 2; i <= 100; ++i) f *= i; - std::stringstream ss {}; ss << f; - EXPECT_EQ(ss.str(), "93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000"); - - std::stringstream ss1 {}; ss1 << std::hex << f; - EXPECT_EQ(ss1.str(), "1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000"); + std::cout << std::showbase << std::hex << f << std::endl; } \ No newline at end of file diff --git a/test/test-generation/CMakeLists.txt b/test/test-generation/CMakeLists.txt deleted file mode 100644 index e5adab9..0000000 --- a/test/test-generation/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.27) -project(CryptoPP) - -set(CMAKE_CXX_STANDARD 20) - -include(FetchContent) -FetchContent_Declare( - CryptoPPLib - GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git - GIT_TAG master -) -FetchContent_Populate(CryptoPPLib) - -message(${cryptopplib_SOURCE_DIR}) -add_subdirectory(${cryptopplib_SOURCE_DIR} ${cryptopplib_BINARY_DIR}) - -add_executable(CryptoPP main.cpp) -target_link_libraries(CryptoPP cryptopp) \ No newline at end of file diff --git a/test/test-generation/main.cpp b/test/test-generation/main.cpp deleted file mode 100644 index b3dec53..0000000 --- a/test/test-generation/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -auto& ss = std::cout; - -std::random_device dev; -std::mt19937 gen(dev()); -std::uniform_int_distribution dist(1u << 30, 1u << 31); - -using CryptoPP::Integer; -using Unsigned = Integer; - -Unsigned getRandomWithBits(std::size_t bitLength, bool prime = false) { - CryptoPP::AutoSeededRandomPool prng; - Unsigned value {}; - value.Randomize(prng, Unsigned::Zero(), Unsigned::Power2(bitLength), prime ? Unsigned::RandomNumberType::PRIME : Unsigned::RandomNumberType::ANY); - return value; -} - -void binaryRead() { - for (unsigned i = 0; i < 30; ++i) { - std::array blocks {}; - for(auto& block: blocks) - block = dist(gen); - - - - if(i % 2 == 0) { - ss << "{\n\tstd::array blocks = { "; - for(auto block: blocks) - ss << "0b" << std::bitset<32>(block) << ", "; - ss << " };\n\tstd::stringstream ss; "; - - ss << "for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true);\n\t"; - ss << "EXPECT_EQ(a, \"0b"; - for(auto block: blocks) - std::cout << std::bitset<32>(block); - ss << "\");\n}\n"; - } else { - ss << "{\n\tstd::array blocks = { "; - for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) - ss << "0b" << std::bitset<32>(*it) << ", "; - ss << " };\n\tstd::stringstream ss; "; - - ss << "for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) ss.write(reinterpret_cast(&*it), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false);\n\t"; - ss << "EXPECT_EQ(a, \"0b"; - for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) - std::cout << std::bitset<32>(*it); - ss << "\");\n}\n"; - } - } -} - -//{ -// unsigned blocks [] = { 0b01000010010011110100011111111110, 0b11010100010001111100100001010110, 0b10010101011011111001000001000101, 0b10100101101100001111101101111010, 0b10001001011001011010111010101100, 0b10111000110011110011010101010011, 0b10011101011111101100111010111111, 0b00011111011110111001010101000101, }; -// std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); -// EXPECT_EQ(a, "0b0100001001001111010001111111111011010100010001111100100001010110100101010110111110010000010001011010010110110000111110110111101010001001011001011010111010101100101110001100111100110101010100111001110101111110110011101011111100011111011110111001010101000101"); -//} - -int main() { - binaryRead(); - return 0; -}