mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 01:57:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -24,12 +24,12 @@ static int read_event(int fd)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static String get_event_name()
|
||||
static DeprecatedString get_event_name()
|
||||
{
|
||||
if (event->name_length == 0)
|
||||
return String();
|
||||
return DeprecatedString();
|
||||
|
||||
return String { event->name, event->name_length - 1 };
|
||||
return DeprecatedString { event->name, event->name_length - 1 };
|
||||
}
|
||||
|
||||
TEST_CASE(inode_watcher_metadata_modified_event)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -23,7 +23,7 @@ TEST_CASE(test_mktemp_unique_filename)
|
|||
|
||||
if (fork() == 0) {
|
||||
char path[] = "/tmp/test.mktemp.XXXXXX";
|
||||
auto temp_path = String::formatted("{}", mktemp(path));
|
||||
auto temp_path = DeprecatedString::formatted("{}", mktemp(path));
|
||||
EXPECT(temp_path.characters());
|
||||
unlink(path);
|
||||
|
||||
|
@ -33,10 +33,10 @@ TEST_CASE(test_mktemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mktemp.XXXXXX";
|
||||
auto path2 = String::formatted("{}", mktemp(path));
|
||||
auto path2 = DeprecatedString::formatted("{}", mktemp(path));
|
||||
EXPECT(path2.characters());
|
||||
unlink(path);
|
||||
|
||||
|
@ -53,7 +53,7 @@ TEST_CASE(test_mkdtemp_unique_filename)
|
|||
|
||||
if (fork() == 0) {
|
||||
char path[] = "/tmp/test.mkdtemp.XXXXXX";
|
||||
auto temp_path = String::formatted("{}", mkdtemp(path));
|
||||
auto temp_path = DeprecatedString::formatted("{}", mkdtemp(path));
|
||||
EXPECT(temp_path.characters());
|
||||
rmdir(path);
|
||||
|
||||
|
@ -63,10 +63,10 @@ TEST_CASE(test_mkdtemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkdtemp.XXXXXX";
|
||||
auto path2 = String::formatted("{}", mkdtemp(path));
|
||||
auto path2 = DeprecatedString::formatted("{}", mkdtemp(path));
|
||||
EXPECT(path2.characters());
|
||||
rmdir(path);
|
||||
|
||||
|
@ -86,7 +86,7 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
auto fd = mkstemp(path);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!temp_path_or_error.is_error());
|
||||
|
||||
auto temp_path = temp_path_or_error.release_value();
|
||||
|
@ -101,13 +101,13 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkstemp.XXXXXX";
|
||||
auto fd = mkstemp(path);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!path2_or_error.is_error());
|
||||
|
||||
auto path2 = path2_or_error.release_value();
|
||||
|
@ -132,7 +132,7 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
auto fd = mkstemps(path, 6);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!temp_path_or_error.is_error());
|
||||
|
||||
auto temp_path = temp_path_or_error.release_value();
|
||||
|
@ -151,13 +151,13 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkstemps.prefixXXXXXXsuffix";
|
||||
auto fd = mkstemps(path, 6);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!path2_or_error.is_error());
|
||||
|
||||
auto path2 = path2_or_error.release_value();
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_CASE(memmem_search)
|
|||
auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr;
|
||||
auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length);
|
||||
if (result != expected) {
|
||||
FAIL(String::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
|
||||
FAIL(DeprecatedString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static String random_dirname()
|
||||
static DeprecatedString random_dirname()
|
||||
{
|
||||
return String::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
|
||||
return DeprecatedString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
|
||||
}
|
||||
|
||||
TEST_SETUP
|
||||
|
@ -46,7 +46,7 @@ TEST_CASE(insufficient_permissions)
|
|||
TEST_CASE(nonexistent_parent)
|
||||
{
|
||||
auto parent = random_dirname();
|
||||
auto child = String::formatted("{}/foo", parent);
|
||||
auto child = DeprecatedString::formatted("{}/foo", parent);
|
||||
int res = mkdir(child.characters(), 0755);
|
||||
int cached_errno = errno;
|
||||
EXPECT(res < 0);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <pwd.h>
|
||||
|
||||
struct PasswdEntry {
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
uid_t uid {};
|
||||
};
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -63,7 +63,7 @@ TEST_CASE(quick_sort)
|
|||
auto const& key1 = test_objects[i].m_key;
|
||||
auto const& key2 = test_objects[i + 1].m_key;
|
||||
if (key1 > key2) {
|
||||
FAIL(String::formatted("saw key {} before key {}\n", key1, key2));
|
||||
FAIL(DeprecatedString::formatted("saw key {} before key {}\n", key1, key2));
|
||||
}
|
||||
}
|
||||
// Check that the object's payloads have not been corrupted
|
||||
|
@ -71,7 +71,7 @@ TEST_CASE(quick_sort)
|
|||
auto const expected = calc_payload_for_pos(i);
|
||||
auto const payload = test_objects[i].m_payload;
|
||||
if (payload != expected) {
|
||||
FAIL(String::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
|
||||
FAIL(DeprecatedString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
@ -21,10 +21,10 @@ static constexpr char PATH_LOREM_250[] = "This-is-an-annoyingly-long-name-that-s
|
|||
|
||||
static constexpr size_t ITERATION_DEPTH = 17;
|
||||
|
||||
static void check_result(char const* what, String const& expected, char const* actual)
|
||||
static void check_result(char const* what, DeprecatedString const& expected, char const* actual)
|
||||
{
|
||||
if (expected != actual)
|
||||
FAIL(String::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
|
||||
FAIL(DeprecatedString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
|
||||
}
|
||||
|
||||
TEST_CASE(overlong_realpath)
|
||||
|
@ -59,7 +59,7 @@ TEST_CASE(overlong_realpath)
|
|||
ret = mkdir(PATH_LOREM_250, S_IRWXU);
|
||||
if (ret < 0) {
|
||||
perror("mkdir iter");
|
||||
FAIL(String::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
|
||||
FAIL(DeprecatedString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
|
||||
return;
|
||||
}
|
||||
expected.append('/');
|
||||
|
@ -67,7 +67,7 @@ TEST_CASE(overlong_realpath)
|
|||
ret = chdir(PATH_LOREM_250);
|
||||
if (ret < 0) {
|
||||
perror("chdir iter");
|
||||
FAIL(String::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
|
||||
FAIL(DeprecatedString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ void twalk_action(void const* node, VISIT order, int depth)
|
|||
// Special case: End signaled by tester.
|
||||
if (depth == TWALK_CHECK_END) {
|
||||
if (tests[count].depth != TWALK_END_MARKER) {
|
||||
FAIL(String::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
|
||||
FAIL(DeprecatedString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
|
||||
tests[count].node, U8(tests[count].order), tests[count].depth));
|
||||
}
|
||||
return;
|
||||
|
@ -174,7 +174,7 @@ void twalk_action(void const* node, VISIT order, int depth)
|
|||
|
||||
// Special case: End marker reached.
|
||||
if (tests[count].depth == TWALK_END_MARKER) {
|
||||
FAIL(String::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
|
||||
FAIL(DeprecatedString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
|
||||
node, U8(order), depth));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ struct Testcase {
|
|||
size_t dest_expected_n; // == dest_n
|
||||
};
|
||||
|
||||
static String show(ByteBuffer const& buf)
|
||||
static DeprecatedString show(ByteBuffer const& buf)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < buf.size(); ++i) {
|
||||
|
|
|
@ -22,7 +22,7 @@ struct Testcase {
|
|||
size_t dest_expected_n; // == dest_n
|
||||
};
|
||||
|
||||
static String show(ByteBuffer const& buf)
|
||||
static DeprecatedString show(ByteBuffer const& buf)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < buf.size(); ++i) {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/String.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -330,7 +330,7 @@ static long long hex_to_ll(char const* hex)
|
|||
} else if ('a' <= ch && ch <= 'f') {
|
||||
digit = ch - 'a' + 10;
|
||||
} else {
|
||||
FAIL(String::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
|
||||
FAIL(DeprecatedString::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
|
||||
return result;
|
||||
}
|
||||
result <<= 4;
|
||||
|
@ -366,7 +366,7 @@ TEST_CASE(strtod_accuracy)
|
|||
}
|
||||
outln("Out of {} tests, saw {} successes and {} fails.", NUM_TESTCASES, successes, fails);
|
||||
if (fails != 0) {
|
||||
FAIL(String::formatted("{} strtod tests failed", fails));
|
||||
FAIL(DeprecatedString::formatted("{} strtod tests failed", fails));
|
||||
}
|
||||
|
||||
outln("PASS (with leniency up to {} ULP from the exact solution)", LENIENCY);
|
||||
|
|
|
@ -215,7 +215,7 @@ TEST_CASE(mbsinit)
|
|||
size_t ret = mbrtowc(nullptr, "\xdf", 1, &state);
|
||||
|
||||
if (ret != -2ul)
|
||||
FAIL(String::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
|
||||
FAIL(DeprecatedString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
|
||||
|
||||
// Ensure that we are not in an initial state.
|
||||
EXPECT(mbsinit(&state) == 0);
|
||||
|
@ -224,7 +224,7 @@ TEST_CASE(mbsinit)
|
|||
ret = mbrtowc(nullptr, "\xbf", 1, &state);
|
||||
|
||||
if (ret != 1ul)
|
||||
FAIL(String::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
|
||||
FAIL(DeprecatedString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
|
||||
|
||||
// Ensure that we are in an initial state again.
|
||||
EXPECT(mbsinit(&state) != 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue