Skip to content

Commit

Permalink
fix leading zeros in numeric string (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Nov 10, 2023
1 parent eeed72b commit 9ee5465
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/modules/string/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ std::string String::numeric(unsigned int length, bool allowLeadingZeros)
{
if (i == 0 && allowLeadingZeros)
{
alphanumeric += Helper::arrayElement<char>(numericCharactersWithoutZero);
alphanumeric += Helper::arrayElement<char>(numericCharacters);
}
else
{
alphanumeric += Helper::arrayElement<char>(numericCharacters);
alphanumeric += Helper::arrayElement<char>(numericCharactersWithoutZero);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/string/StringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ TEST_F(StringTest, shouldGenerateNumericWithoutLeadingZeros)
{
const auto numericLength = 13;

const auto numeric = String::numeric(numericLength, true);
const auto numeric = String::numeric(numericLength, false);

const auto nonZeroCharacter = numeric[0];
const auto numericWithPossibleZeroCharacters = numeric.substr(1);
Expand Down

0 comments on commit 9ee5465

Please sign in to comment.