Skip to content
Snippets Groups Projects
Commit 6419b1d6 authored by hcasse's avatar hcasse
Browse files

io: fixed "0" reading for Input::scanU[L]Long().

parent 06d876db
No related branches found
No related tags found
No related merge requests found
......@@ -261,6 +261,7 @@ static inline int test_base(char chr, int base) {
* @throw IOException In case of IO error.
*/
t::uint32 Input::scanULong(int base) {
bool one = false;
t::uint32 val = 0;
// Read the base
......@@ -277,6 +278,7 @@ t::uint32 Input::scanULong(int base) {
chr = get();
break;
default:
one = true;
base = 8;
break;
}
......@@ -285,7 +287,6 @@ t::uint32 Input::scanULong(int base) {
}
// read the digits
bool one = false;
int digit = test_base(chr, base);
while(digit >= 0) {
t::uint32 old = val;
......@@ -365,6 +366,7 @@ t::uint64 Input::scanULLong(int base) {
break;
default:
base = 8;
one = true;
break;
}
else
......
......@@ -329,6 +329,23 @@ TEST_BEGIN(io_format)
CHECK_EQUAL(v, 0x80);
}
{
auto in = io::scan("0");
t::uint32 v;
in >> v;
CHECK_EQUAL(int(v), 0);
CHECK(!in.failed());
CHECK(in.ended());
}
{
auto in = io::scan("0");
t::uint64 v;
in >> v;
CHECK_EQUAL(v, 0UL);
CHECK(!in.failed());
CHECK(in.ended());
}
}
TEST_END
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment