Handle negative numbers in print

This commit is contained in:
2025-08-10 19:54:58 +01:00
parent 662b99a40f
commit ba0a543a4c
2 changed files with 16 additions and 1 deletions

View File

@@ -50,6 +50,14 @@ static void test_integer_10(void)
TEST_ASSERT_EQUAL_MEMORY("10", buffer, 2);
}
static void test_integer_minus_4321(void)
{
am.val = expr_integer(&am, -4321);
const size_t len = print(&am, buffer, BUFFER_SIZE);
TEST_ASSERT_EQUAL(5, len);
TEST_ASSERT_EQUAL_MEMORY("-4321", buffer, 5);
}
int main(void)
{
UNITY_BEGIN();
@@ -57,5 +65,6 @@ int main(void)
RUN_TEST(test_integer_1234);
RUN_TEST(test_integer_0);
RUN_TEST(test_integer_10);
RUN_TEST(test_integer_minus_4321);
return UNITY_END();
}