Removed double subtraction of float size from 'bits_remaining' for floating point reads

This commit is contained in:
John Wellbelove 2020-12-03 19:16:09 +00:00
parent 4bcd734dad
commit 536fd412a3
2 changed files with 26 additions and 2 deletions

View File

@ -314,8 +314,6 @@ namespace etl
from_bytes(data, value);
bits_remaining -= width;
success = true;
}
}

View File

@ -1041,5 +1041,31 @@ namespace
CHECK_EQUAL(object1, object1a);
CHECK_EQUAL(object2, object2a);
}
//*************************************************************************
TEST(put_get_multiple_float)
{
float f = 3.1415927f;
double d = 3.1415927;
std::array<unsigned char, 12> storage;
etl::bit_stream bit_stream(storage.data(), storage.size());
bit_stream.put(f);
bit_stream.put(d);
bit_stream.restart();
float rf;
double rd;
CHECK(bit_stream.get(rf));
CHECK_CLOSE(f, rf, 0.1f);
CHECK(bit_stream.get(rd));
CHECK_CLOSE(f, rd, 0.1f);
}
};
}