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.
This commit is contained in:
Daniel Bertalan 2022-07-04 13:28:16 +02:00 committed by Andreas Kling
parent fc3532e9b7
commit e15d6125b2
Notes: sideshowbarker 2024-07-17 09:43:32 +09:00
2 changed files with 14 additions and 14 deletions

View File

@ -257,20 +257,6 @@ TEST_CASE(builder_zero_initial_capacity)
EXPECT_EQ(built.length(), 0u);
}
TEST_CASE(sprintf)
{
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(String(buf1), String("+12"));
EXPECT_EQ(String(buf2), String("-12"));
}
TEST_CASE(find)
{
String a = "foobarbar";

View File

@ -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);
}