mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:27:35 +00:00
AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
This commit is contained in:
parent
da81041e97
commit
6e7459322d
129 changed files with 213 additions and 219 deletions
|
@ -252,7 +252,7 @@ TEST_CASE(builder_zero_initial_capacity)
|
|||
{
|
||||
StringBuilder builder(0);
|
||||
builder.append(""sv);
|
||||
auto built = builder.build();
|
||||
auto built = builder.to_deprecated_string();
|
||||
EXPECT_EQ(built.is_null(), false);
|
||||
EXPECT_EQ(built.length(), 0u);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar
|
|||
builder.appendff("{:p}", fake_params[i]);
|
||||
}
|
||||
builder.append(']');
|
||||
dbgln("{}", builder.build());
|
||||
dbgln("{}", builder.to_deprecated_string());
|
||||
|
||||
// Actually do the syscall ('fake_params' is passed indirectly, if any of arg1, arg2, or arg3 point to it.
|
||||
int rc = syscall(Syscall::Function(syscall_fn), arg1, arg2, arg3);
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST_CASE(overlong_realpath)
|
|||
expected.append({ tmp_dir, strlen(tmp_dir) });
|
||||
|
||||
// But first, demonstrate the functionality at a reasonable depth:
|
||||
auto expected_str = expected.build();
|
||||
auto expected_str = expected.to_deprecated_string();
|
||||
check_result("getwd", expected_str, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
|
||||
check_result("getcwd", expected_str, getcwd(nullptr, 0));
|
||||
check_result("realpath", expected_str, realpath(".", nullptr));
|
||||
|
@ -74,7 +74,7 @@ TEST_CASE(overlong_realpath)
|
|||
outln("cwd should now be ridiculously large");
|
||||
|
||||
// Evaluate
|
||||
expected_str = expected.build();
|
||||
expected_str = expected.to_deprecated_string();
|
||||
|
||||
check_result("getwd", {}, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
|
||||
check_result("getcwd", expected_str, getcwd(nullptr, 0));
|
||||
|
|
|
@ -43,7 +43,7 @@ static DeprecatedString show(ByteBuffer const& buf)
|
|||
builder.append('_');
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.build();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
|
|
|
@ -37,7 +37,7 @@ static DeprecatedString show(ByteBuffer const& buf)
|
|||
builder.append('_');
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.build();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
static bool test_single(Testcase const& testcase)
|
||||
|
|
|
@ -143,7 +143,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
// First in ere
|
||||
b.clear();
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -153,7 +153,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append("a|"sv);
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -163,7 +163,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('^');
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -173,7 +173,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('$');
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -184,7 +184,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.append('(');
|
||||
b.append(ch);
|
||||
b.append(')');
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -722,7 +722,7 @@ TEST_CASE(ECMA262_unicode_match)
|
|||
StringBuilder builder;
|
||||
for (u32 code_point : space_and_line_terminator_code_points)
|
||||
builder.append_code_point(code_point);
|
||||
auto space_and_line_terminators = builder.build();
|
||||
auto space_and_line_terminators = builder.to_deprecated_string();
|
||||
|
||||
struct _test {
|
||||
StringView pattern;
|
||||
|
|
|
@ -325,7 +325,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
// First in ere
|
||||
b.clear();
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -334,7 +334,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append("a|"sv);
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -343,7 +343,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('^');
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -352,7 +352,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('$');
|
||||
b.append(ch);
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -362,7 +362,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.append('(');
|
||||
b.append(ch);
|
||||
b.append(')');
|
||||
pattern = b.build();
|
||||
pattern = b.to_deprecated_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
|
|
@ -51,7 +51,7 @@ void insert_into_table(SQL::Database& db, int count)
|
|||
StringBuilder builder;
|
||||
builder.appendff("Test{}", ix);
|
||||
|
||||
row["TextColumn"] = builder.build();
|
||||
row["TextColumn"] = builder.to_deprecated_string();
|
||||
row["IntColumn"] = ix;
|
||||
auto maybe_error = db.insert(row);
|
||||
EXPECT(!maybe_error.is_error());
|
||||
|
@ -69,7 +69,7 @@ void verify_table_contents(SQL::Database& db, int expected_count)
|
|||
for (auto& row : rows_or_error.value()) {
|
||||
StringBuilder builder;
|
||||
builder.appendff("Test{}", row["IntColumn"].to_int<i32>().value());
|
||||
EXPECT_EQ(row["TextColumn"].to_deprecated_string(), builder.build());
|
||||
EXPECT_EQ(row["TextColumn"].to_deprecated_string(), builder.to_deprecated_string());
|
||||
count++;
|
||||
sum += row["IntColumn"].to_int<i32>().value();
|
||||
}
|
||||
|
|
|
@ -249,14 +249,14 @@ TEST_CASE(binary_operator)
|
|||
StringBuilder builder;
|
||||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
EXPECT(parse(builder.build()).is_error());
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
|
||||
builder.clear();
|
||||
|
||||
if (op.key != "+" && op.key != "-") { // "+1" and "-1" are fine (unary operator).
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
EXPECT(parse(builder.build()).is_error());
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ TEST_CASE(binary_operator)
|
|||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.build(), op.value);
|
||||
validate(builder.to_deprecated_string(), op.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,12 +485,12 @@ TEST_CASE(match_expression)
|
|||
StringBuilder builder;
|
||||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
EXPECT(parse(builder.build()).is_error());
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
|
||||
builder.clear();
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
EXPECT(parse(builder.build()).is_error());
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
}
|
||||
|
||||
auto validate = [](StringView sql, SQL::AST::MatchOperator expected_operator, bool expected_invert_expression, bool expect_escape) {
|
||||
|
@ -513,19 +513,19 @@ TEST_CASE(match_expression)
|
|||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.build(), op.value, false, false);
|
||||
validate(builder.to_deprecated_string(), op.value, false, false);
|
||||
|
||||
builder.clear();
|
||||
builder.append("1 NOT "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.build(), op.value, true, false);
|
||||
validate(builder.to_deprecated_string(), op.value, true, false);
|
||||
|
||||
builder.clear();
|
||||
builder.append("1 NOT "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1 ESCAPE '+'"sv);
|
||||
validate(builder.build(), op.value, true, true);
|
||||
validate(builder.to_deprecated_string(), op.value, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue