Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8ce59d2

Browse files
Add a test case demonstrating the issue when trying to print a zero value for uint64_t.
1 parent b052976 commit 8ce59d2

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎test/src/Print/test_print.cpp‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,24 @@ TEST_CASE ("Print::print(unsigned long long, int = DEC|HEX|OCT|BIN)", "[Print-pr
110110
{
111111
PrintMock mock;
112112

113-
unsigned long long const val = 17;
113+
GIVEN("a value of zero ...")
114+
{
115+
unsigned long long const val = 0;
114116

115-
WHEN("DEC") { mock.print(val, DEC); REQUIRE(mock._str == "17"); }
116-
WHEN("HEX") { mock.print(val, HEX); REQUIRE(mock._str == "11"); }
117-
WHEN("OCT") { mock.print(val, OCT); REQUIRE(mock._str == "21"); }
118-
WHEN("BIN") { mock.print(val, BIN); REQUIRE(mock._str == "10001"); }
117+
WHEN("DEC") { mock.print(val, DEC); REQUIRE(mock._str == "0"); }
118+
WHEN("HEX") { mock.print(val, HEX); REQUIRE(mock._str == "0"); }
119+
WHEN("OCT") { mock.print(val, OCT); REQUIRE(mock._str == "0"); }
120+
WHEN("BIN") { mock.print(val, BIN); REQUIRE(mock._str == "0"); }
121+
}
122+
GIVEN("a non-zero value ...")
123+
{
124+
unsigned long long const val = 17;
125+
126+
WHEN("DEC") { mock.print(val, DEC); REQUIRE(mock._str == "17"); }
127+
WHEN("HEX") { mock.print(val, HEX); REQUIRE(mock._str == "11"); }
128+
WHEN("OCT") { mock.print(val, OCT); REQUIRE(mock._str == "21"); }
129+
WHEN("BIN") { mock.print(val, BIN); REQUIRE(mock._str == "10001"); }
130+
}
119131
}
120132

121133
TEST_CASE ("Print::print(double, int = 2)", "[Print-print-10]")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /