From 9ee54658e355947631693bac6f4bc3ee8da0a390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blar?= Date: Fri, 10 Nov 2023 11:52:50 +0100 Subject: [PATCH] fix leading zeros in numeric string (#228) --- src/modules/string/String.cpp | 4 ++-- src/modules/string/StringTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/string/String.cpp b/src/modules/string/String.cpp index b8d127cab..9c197fa66 100644 --- a/src/modules/string/String.cpp +++ b/src/modules/string/String.cpp @@ -148,11 +148,11 @@ std::string String::numeric(unsigned int length, bool allowLeadingZeros) { if (i == 0 && allowLeadingZeros) { - alphanumeric += Helper::arrayElement(numericCharactersWithoutZero); + alphanumeric += Helper::arrayElement(numericCharacters); } else { - alphanumeric += Helper::arrayElement(numericCharacters); + alphanumeric += Helper::arrayElement(numericCharactersWithoutZero); } } diff --git a/src/modules/string/StringTest.cpp b/src/modules/string/StringTest.cpp index 0128504d5..80b297e32 100644 --- a/src/modules/string/StringTest.cpp +++ b/src/modules/string/StringTest.cpp @@ -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);