1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -46,7 +46,7 @@ static void insert_into_table(SQL::Database& db, int count)
StringBuilder builder;
builder.appendff("Test{}", ix);
row["TextColumn"] = builder.to_deprecated_string();
row["TextColumn"] = builder.to_byte_string();
row["IntColumn"] = ix;
TRY_OR_FAIL(db.insert(row));
}
@ -62,7 +62,7 @@ static void verify_table_contents(SQL::Database& db, int expected_count)
for (auto& row : rows) {
StringBuilder builder;
builder.appendff("Test{}", row["IntColumn"].to_int<i32>().value());
EXPECT_EQ(row["TextColumn"].to_deprecated_string(), builder.to_deprecated_string());
EXPECT_EQ(row["TextColumn"].to_byte_string(), builder.to_byte_string());
count++;
sum += row["IntColumn"].to_int<i32>().value();
}

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/Result.h>
#include <AK/StringBuilder.h>
@ -31,7 +31,7 @@ public:
}
};
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, DeprecatedString>;
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, ByteString>;
ParseResult parse(StringView sql)
{
@ -39,7 +39,7 @@ ParseResult parse(StringView sql)
auto expression = parser.parse();
if (parser.has_errors()) {
return parser.errors()[0].to_deprecated_string();
return parser.errors()[0].to_byte_string();
}
return expression;
@ -225,14 +225,14 @@ TEST_CASE(binary_operator)
StringBuilder builder;
builder.append("1 "sv);
builder.append(op.key);
EXPECT(parse(builder.to_deprecated_string()).is_error());
EXPECT(parse(builder.to_byte_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.to_deprecated_string()).is_error());
EXPECT(parse(builder.to_byte_string()).is_error());
}
}
@ -251,7 +251,7 @@ TEST_CASE(binary_operator)
builder.append("1 "sv);
builder.append(op.key);
builder.append(" 1"sv);
validate(builder.to_deprecated_string(), op.value);
validate(builder.to_byte_string(), op.value);
}
}
@ -438,12 +438,12 @@ TEST_CASE(match_expression)
StringBuilder builder;
builder.append("1 "sv);
builder.append(op.key);
EXPECT(parse(builder.to_deprecated_string()).is_error());
EXPECT(parse(builder.to_byte_string()).is_error());
builder.clear();
builder.append(op.key);
builder.append(" 1"sv);
EXPECT(parse(builder.to_deprecated_string()).is_error());
EXPECT(parse(builder.to_byte_string()).is_error());
}
auto validate = [](StringView sql, SQL::AST::MatchOperator expected_operator, bool expected_invert_expression, bool expect_escape) {
@ -463,19 +463,19 @@ TEST_CASE(match_expression)
builder.append("1 "sv);
builder.append(op.key);
builder.append(" 1"sv);
validate(builder.to_deprecated_string(), op.value, false, false);
validate(builder.to_byte_string(), op.value, false, false);
builder.clear();
builder.append("1 NOT "sv);
builder.append(op.key);
builder.append(" 1"sv);
validate(builder.to_deprecated_string(), op.value, true, false);
validate(builder.to_byte_string(), op.value, true, false);
builder.clear();
builder.append("1 NOT "sv);
builder.append(op.key);
builder.append(" 1 ESCAPE '+'"sv);
validate(builder.to_deprecated_string(), op.value, true, true);
validate(builder.to_byte_string(), op.value, true, true);
}
}
@ -598,7 +598,7 @@ TEST_CASE(in_selection_expression)
TEST_CASE(expression_tree_depth_limit)
{
auto too_deep_expression = DeprecatedString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
auto too_deep_expression = ByteString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
EXPECT(!parse(too_deep_expression.substring_view(1)).is_error());
EXPECT(parse(too_deep_expression).is_error());
}

View file

@ -21,17 +21,17 @@ namespace {
constexpr char const* db_name = "/tmp/test.db";
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql, Vector<SQL::Value> placeholder_values = {})
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, ByteString const& sql, Vector<SQL::Value> placeholder_values = {})
{
auto parser = SQL::AST::Parser(SQL::AST::Lexer(sql));
auto statement = parser.next_statement();
EXPECT(!parser.has_errors());
if (parser.has_errors())
outln("{}", parser.errors()[0].to_deprecated_string());
outln("{}", parser.errors()[0].to_byte_string());
return statement->execute(move(database), placeholder_values);
}
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql, Vector<SQL::Value> placeholder_values = {})
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, ByteString const& sql, Vector<SQL::Value> placeholder_values = {})
{
auto result = try_execute(move(database), sql, move(placeholder_values));
if (result.is_error()) {
@ -101,7 +101,7 @@ TEST_CASE(insert_into_table)
int count = 0;
auto rows = TRY_OR_FAIL(database->select_all(*table));
for (auto& row : rows) {
EXPECT_EQ(row["TEXTCOLUMN"].to_deprecated_string(), "Test");
EXPECT_EQ(row["TEXTCOLUMN"].to_byte_string(), "Test");
EXPECT_EQ(row["INTCOLUMN"].to_int<i32>(), 42);
count++;
}
@ -380,8 +380,8 @@ TEST_CASE(select_inner_join)
EXPECT_EQ(result.size(), 1u);
EXPECT_EQ(result[0].row.size(), 3u);
EXPECT_EQ(result[0].row[0].to_int<i32>(), 42);
EXPECT_EQ(result[0].row[1].to_deprecated_string(), "Test_1");
EXPECT_EQ(result[0].row[2].to_deprecated_string(), "Test_12");
EXPECT_EQ(result[0].row[1].to_byte_string(), "Test_1");
EXPECT_EQ(result[0].row[2].to_byte_string(), "Test_12");
}
TEST_CASE(select_with_like)
@ -467,11 +467,11 @@ TEST_CASE(select_with_order)
result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn;");
EXPECT_EQ(result.size(), 5u);
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1");
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2");
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_3");
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4");
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5");
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1");
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2");
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_3");
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4");
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5");
}
TEST_CASE(select_with_regexp)
@ -542,15 +542,15 @@ TEST_CASE(select_with_order_two_columns)
result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn, IntColumn;");
EXPECT_EQ(result.size(), 5u);
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1");
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1");
EXPECT_EQ(result[0].row[1].to_int<i32>(), 47);
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2");
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2");
EXPECT_EQ(result[1].row[1].to_int<i32>(), 40);
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2");
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2");
EXPECT_EQ(result[2].row[1].to_int<i32>(), 42);
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4");
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4");
EXPECT_EQ(result[3].row[1].to_int<i32>(), 41);
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5");
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5");
EXPECT_EQ(result[4].row[1].to_int<i32>(), 44);
}
@ -571,11 +571,11 @@ TEST_CASE(select_with_order_by_column_not_in_result)
result = execute(database, "SELECT TextColumn FROM TestSchema.TestTable ORDER BY IntColumn;");
EXPECT_EQ(result.size(), 5u);
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_3");
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_4");
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2");
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_5");
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_1");
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_3");
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_4");
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2");
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_5");
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_1");
}
TEST_CASE(select_with_limit)
@ -586,7 +586,7 @@ TEST_CASE(select_with_limit)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10;");
@ -602,7 +602,7 @@ TEST_CASE(select_with_limit_and_offset)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 10;");
@ -617,7 +617,7 @@ TEST_CASE(select_with_order_limit_and_offset)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY IntColumn LIMIT 10 OFFSET 10;");
@ -642,7 +642,7 @@ TEST_CASE(select_with_limit_out_of_bounds)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 500;");
@ -657,7 +657,7 @@ TEST_CASE(select_with_offset_out_of_bounds)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 200;");
@ -673,11 +673,11 @@ TEST_CASE(describe_table)
auto result = execute(database, "DESCRIBE TABLE TestSchema.TestTable;");
EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "TEXTCOLUMN");
EXPECT_EQ(result[0].row[1].to_deprecated_string(), "text");
EXPECT_EQ(result[0].row[0].to_byte_string(), "TEXTCOLUMN");
EXPECT_EQ(result[0].row[1].to_byte_string(), "text");
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "INTCOLUMN");
EXPECT_EQ(result[1].row[1].to_deprecated_string(), "int");
EXPECT_EQ(result[1].row[0].to_byte_string(), "INTCOLUMN");
EXPECT_EQ(result[1].row[1].to_byte_string(), "int");
}
TEST_CASE(binary_operator_execution)
@ -688,7 +688,7 @@ TEST_CASE(binary_operator_execution)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -762,7 +762,7 @@ TEST_CASE(binary_operator_failure)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -772,7 +772,7 @@ TEST_CASE(binary_operator_failure)
auto error = result.release_error();
EXPECT_EQ(error.error(), SQL::SQLErrorCode::NumericOperatorTypeMismatch);
auto message = DeprecatedString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
auto message = ByteString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
EXPECT_EQ(error.error_string(), message);
};
@ -832,7 +832,7 @@ TEST_CASE(delete_single_row)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -876,7 +876,7 @@ TEST_CASE(delete_multiple_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -916,7 +916,7 @@ TEST_CASE(delete_all_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -950,7 +950,7 @@ TEST_CASE(update_single_row)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -995,7 +995,7 @@ TEST_CASE(update_multiple_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -1036,7 +1036,7 @@ TEST_CASE(update_all_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}

View file

@ -8,7 +8,7 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Optional.h>
#include <AK/Result.h>
#include <AK/StringView.h>
@ -19,7 +19,7 @@
namespace {
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, DeprecatedString>;
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, ByteString>;
ParseResult parse(StringView sql)
{
@ -27,7 +27,7 @@ ParseResult parse(StringView sql)
auto statement = parser.next_statement();
if (parser.has_errors()) {
return parser.errors()[0].to_deprecated_string();
return parser.errors()[0].to_byte_string();
}
return statement;
@ -393,7 +393,7 @@ TEST_CASE(update)
EXPECT(parse("UPDATE OR table_name SET column_name=4;"sv).is_error());
EXPECT(parse("UPDATE OR foo table_name SET column_name=4;"sv).is_error());
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<DeprecatedString>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<ByteString>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
auto statement = TRY_OR_FAIL(parse(sql));
EXPECT(is<SQL::AST::Update>(*statement));
@ -437,7 +437,7 @@ TEST_CASE(update)
}
};
Vector<Vector<DeprecatedString>> update_columns { { "COLUMN_NAME" } };
Vector<Vector<ByteString>> update_columns { { "COLUMN_NAME" } };
validate("UPDATE OR ABORT table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
validate("UPDATE OR FAIL table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
validate("UPDATE OR IGNORE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
@ -578,7 +578,7 @@ TEST_CASE(select)
};
struct Ordering {
DeprecatedString collation_name;
ByteString collation_name;
SQL::Order order;
SQL::Nulls nulls;
};
@ -752,16 +752,16 @@ TEST_CASE(common_table_expression)
TEST_CASE(nested_subquery_limit)
{
auto subquery = DeprecatedString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
EXPECT(!parse(DeprecatedString::formatted("SELECT * FROM {};"sv, subquery)).is_error());
EXPECT(parse(DeprecatedString::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
auto subquery = ByteString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
EXPECT(!parse(ByteString::formatted("SELECT * FROM {};"sv, subquery)).is_error());
EXPECT(parse(ByteString::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
}
TEST_CASE(bound_parameter_limit)
{
auto subquery = DeprecatedString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters);
EXPECT(!parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error());
EXPECT(parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error());
auto subquery = ByteString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters);
EXPECT(!parse(ByteString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error());
EXPECT(parse(ByteString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error());
}
TEST_CASE(describe_table)

View file

@ -17,7 +17,7 @@ TEST_CASE(null_value)
{
SQL::Value v(SQL::SQLType::Null);
EXPECT_EQ(v.type(), SQL::SQLType::Null);
EXPECT_EQ(v.to_deprecated_string(), "(null)"sv);
EXPECT_EQ(v.to_byte_string(), "(null)"sv);
EXPECT(!v.to_bool().has_value());
EXPECT(!v.to_int<i32>().has_value());
EXPECT(!v.to_int<u32>().has_value());
@ -44,25 +44,25 @@ TEST_CASE(text_value)
v = "Test"sv;
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_deprecated_string(), "Test"sv);
EXPECT_EQ(v.to_byte_string(), "Test"sv);
}
{
SQL::Value v(DeprecatedString("String Test"sv));
SQL::Value v(ByteString("String Test"sv));
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_deprecated_string(), "String Test"sv);
EXPECT_EQ(v.to_byte_string(), "String Test"sv);
v = DeprecatedString("String Test 2"sv);
v = ByteString("String Test 2"sv);
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_deprecated_string(), "String Test 2"sv);
EXPECT_EQ(v.to_byte_string(), "String Test 2"sv);
}
{
SQL::Value v("const char * Test");
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_deprecated_string(), "const char * Test"sv);
EXPECT_EQ(v.to_byte_string(), "const char * Test"sv);
v = "const char * Test 2";
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_deprecated_string(), "const char * Test 2"sv);
EXPECT_EQ(v.to_byte_string(), "const char * Test 2"sv);
}
}
@ -149,7 +149,7 @@ TEST_CASE(integer_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 42);
EXPECT_EQ(v.to_deprecated_string(), "42"sv);
EXPECT_EQ(v.to_byte_string(), "42"sv);
EXPECT(v.to_double().has_value());
EXPECT((v.to_double().value() - 42.0) < NumericLimits<double>().epsilon());
@ -261,7 +261,7 @@ TEST_CASE(float_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 3);
EXPECT_EQ(v.to_deprecated_string(), "3.14");
EXPECT_EQ(v.to_byte_string(), "3.14");
EXPECT(v.to_bool().has_value());
EXPECT(v.to_bool().value());
@ -274,7 +274,7 @@ TEST_CASE(float_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 0);
EXPECT_EQ(v.to_deprecated_string(), "0"sv);
EXPECT_EQ(v.to_byte_string(), "0"sv);
EXPECT(v.to_bool().has_value());
EXPECT(!v.to_bool().value());
@ -420,7 +420,7 @@ TEST_CASE(bool_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 1);
EXPECT_EQ(v.to_deprecated_string(), "true"sv);
EXPECT_EQ(v.to_byte_string(), "true"sv);
EXPECT(v.to_double().has_value());
EXPECT((v.to_double().value() - 1.0) < NumericLimits<double>().epsilon());
@ -434,7 +434,7 @@ TEST_CASE(bool_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 0);
EXPECT_EQ(v.to_deprecated_string(), "false"sv);
EXPECT_EQ(v.to_byte_string(), "false"sv);
EXPECT(v.to_double().has_value());
EXPECT(v.to_double().value() < NumericLimits<double>().epsilon());
@ -448,7 +448,7 @@ TEST_CASE(bool_value)
EXPECT(v.to_int<i32>().has_value());
EXPECT_EQ(v.to_int<i32>().value(), 1);
EXPECT_EQ(v.to_deprecated_string(), "true"sv);
EXPECT_EQ(v.to_byte_string(), "true"sv);
EXPECT(v.to_double().has_value());
EXPECT((v.to_double().value() - 1.0) < NumericLimits<double>().epsilon());