Skip to content

Commit

Permalink
Removed std::format.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander committed Sep 15, 2024
1 parent c1d6925 commit e24a1be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions test/bitwise/not.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <gtest/gtest.h>
#include <format>
#include "../../Aeu.h"
#include "../../Aesi.h"
#include "../generation.h"
Expand All @@ -12,7 +11,10 @@ TEST(Unsigned_Bitwise, NOT) {
value <<= (blocksNumber * 32 - value.BitCount());

std::stringstream ss {};
ss << std::format("0b{:b}", static_cast<uint8_t>(~value.GetByte(value.ByteCount() - 1)));
std::string binary {};
for (auto byte = static_cast<uint8_t>(~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));

Expand Down
6 changes: 4 additions & 2 deletions test/operations/initialization/signed.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <gtest/gtest.h>
#include <bitset>
#include <format>
#include "../../../Aesi.h"
#include "../../generation.h"

Expand Down Expand Up @@ -136,8 +135,11 @@ TEST(Signed_Initialization, Binary) {
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::format("{:b}", value.GetByte(value.ByteCount() - 1));
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);
Expand Down
6 changes: 4 additions & 2 deletions test/operations/initialization/unsigned.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <gtest/gtest.h>
#include <bitset>
#include <format>
#include "../../../Aeu.h"
#include "../../generation.h"

Expand Down Expand Up @@ -86,7 +85,10 @@ TEST(Unsigned_Initialization, Binary) {
record = value; EXPECT_EQ(record, value);

std::stringstream ss {};
ss << "0b" << std::format("{:b}", value.GetByte(value.ByteCount() - 1));
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);
Expand Down

0 comments on commit e24a1be

Please sign in to comment.