#include "format.h" #include #include Y_UNIT_TEST_SUITE(StdOstreamFormattingTest) { template TString ToStringViaOstream(T baseNumber) { std::stringstream ss; ss << baseNumber; return ss.str(); } Y_UNIT_TEST(TestBin) { UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(2), nullptr)), "10"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(SBin(static_cast(-2), nullptr)), "-10"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(SBin(static_cast(-2))), "-0b00000000000000000000000000000010"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(SBin(static_cast(-2), HF_FULL)), "-00000000000000000000000000000010"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(15), nullptr)), "1111"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(1))), "0b00000000000000000000000000000001"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(-1))), "0b11111111111111111111111111111111"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(-1))), "0b11111111111111111111111111111111"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(-1), nullptr)), "11111111111111111111111111111111"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(256))), "0b00000000000000000000000100000000"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(16))), "0b00010000"); UNIT_ASSERT_VALUES_EQUAL(ToStringViaOstream(Bin(static_cast(1234587912357ull))), "0b0000000000000000000000010001111101110011001011001000100010100101"); } }