mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Restrict hex string generation to non-negative values.
It turns out the specific generator I use doesn't support signed integers, which is OK, since I only ever plug unsigned integers into it. Updated the function argument type to reflect that.
This commit is contained in:
@@ -92,7 +92,7 @@ namespace loot {
|
||||
}
|
||||
|
||||
//Converts an integer to a hex string using BOOST's Spirit.Karma, which is apparently a lot faster than a stringstream conversion...
|
||||
std::string IntToHexString(const int n) {
|
||||
std::string IntToHexString(const uint32_t n) {
|
||||
string out;
|
||||
back_insert_iterator<string> sink(out);
|
||||
karma::generate(sink, karma::upper[karma::hex], n);
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace loot {
|
||||
//Calculate the CRC of the given file for comparison purposes.
|
||||
uint32_t GetCrc32(const boost::filesystem::path& filename);
|
||||
|
||||
//Converts an integer to a hex string using BOOST's Spirit.Karma. Faster than a stringstream conversion.
|
||||
std::string IntToHexString(const int n);
|
||||
//Converts an unsigned 32-bit integer to a hex string using BOOST's Spirit.Karma. Faster than a stringstream conversion.
|
||||
std::string IntToHexString(const uint32_t n);
|
||||
|
||||
#ifdef _WIN32
|
||||
//Get registry subkey value string.
|
||||
|
||||
@@ -39,9 +39,8 @@ TEST_F(GetCrc32, ValidFile) {
|
||||
EXPECT_EQ(0x0B5B7B90, loot::GetCrc32(dataPath / "Blank.esp"));
|
||||
}
|
||||
|
||||
TEST(IntToHexString, PositiveNegativeZeroValues) {
|
||||
TEST(IntToHexString, PositiveAndZeroValues) {
|
||||
EXPECT_EQ("14", loot::IntToHexString(20));
|
||||
EXPECT_EQ("-14", loot::IntToHexString(-20));
|
||||
EXPECT_EQ("0", loot::IntToHexString(0));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user