summaryrefslogtreecommitdiff
path: root/Tests/LibC
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2022-07-04 13:28:16 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-04 21:46:02 +0200
commite15d6125b21bcbf0d05019f124f7c1bbf529fa51 (patch)
tree2968cc167d7351a5626a074854b6aa0c2d87bfb3 /Tests/LibC
parentfc3532e9b7b69d8bcbc8a8be3ce7f97c4460561a (diff)
downloadserenity-e15d6125b21bcbf0d05019f124f7c1bbf529fa51.zip
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.
Diffstat (limited to 'Tests/LibC')
-rw-r--r--Tests/LibC/TestStdio.cpp14
1 files changed, 14 insertions, 0 deletions
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);
+}