From 51ade79641e0156b07a6dba95e0f06f2791e4876 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 3 Jan 2022 03:31:57 -0500 Subject: [PATCH] itoa unit test, not a very detailed one --- firmware/util/efilib.cpp | 1 - firmware/util/efilib.h | 1 + unit_tests/tests/test_util.cpp | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp index 71ceefac7e..d91a2c8c33 100644 --- a/firmware/util/efilib.cpp +++ b/firmware/util/efilib.cpp @@ -193,7 +193,6 @@ static char* itoa_signed(char *p, int num, unsigned radix) { * @return pointer at the end zero symbol after the digits */ char* itoa10(char *p, int num) { -// todo: unit test return itoa_signed(p, num, 10); } diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 36a167376c..a400ca0b86 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -74,6 +74,7 @@ int maxI(int i1, int i2); int minI(int i1, int i2); float maxF(float i1, float i2); float minF(float i1, float i2); +// sometimes known as 'itoa' char* itoa10(char *p, int num); bool isSameF(float v1, float v2); diff --git a/unit_tests/tests/test_util.cpp b/unit_tests/tests/test_util.cpp index 89322e5a45..503b5eacc7 100644 --- a/unit_tests/tests/test_util.cpp +++ b/unit_tests/tests/test_util.cpp @@ -21,6 +21,12 @@ #include "crc.h" #include "fl_stack.h" +TEST(util, testitoa) { + char buffer[12]; + itoa10(buffer, 239); + ASSERT_TRUE(strEqual(buffer, "239")); +} + TEST(util, negativeZero) { ASSERT_TRUE(IS_NEGATIVE_ZERO(-0.0));