From e15d6125b21bcbf0d05019f124f7c1bbf529fa51 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Mon, 4 Jul 2022 13:28:16 +0200 Subject: Tests: Move sprintf test from AK/ to LibC/ This test doesn't test AK::String, but LibC's sprintf instead, so it does not belong in `Tests/AK`. This also means this test won't be ran on Lagom using the host OS's printf implementation. Fixes a deprecated declaration warning when compiling with macOS SDK 13. --- Tests/LibC/TestStdio.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Tests/LibC') diff --git a/Tests/LibC/TestStdio.cpp b/Tests/LibC/TestStdio.cpp index 0c0b818d0e..b23176b8e6 100644 --- a/Tests/LibC/TestStdio.cpp +++ b/Tests/LibC/TestStdio.cpp @@ -40,3 +40,17 @@ TEST_CASE(flush_on_exit) EXPECT_EQ(strcmp(test_str, buf), 0); } } + +TEST_CASE(sprintf_sign) +{ + char buf1[128]; + int ret1 = sprintf(buf1, "%+d", 12); + EXPECT_EQ(ret1, 3); + + char buf2[128]; + int ret2 = sprintf(buf2, "%+d", -12); + EXPECT_EQ(ret2, 3); + + EXPECT_EQ(buf1, "+12"sv); + EXPECT_EQ(buf2, "-12"sv); +} -- cgit v1.2.3