1#include "catch.hpp"
2#include "test_helpers.hpp"
3
4using namespace duckdb;
5using namespace std;
6
7TEST_CASE("Test strip accents function", "[collate]") {
8 unique_ptr<QueryResult> result;
9 DuckDB db(nullptr);
10 Connection con(db);
11
12 result = con.Query("SELECT strip_accents('hello'), strip_accents('héllo')");
13 REQUIRE(CHECK_COLUMN(result, 0, {"hello"}));
14 REQUIRE(CHECK_COLUMN(result, 1, {"hello"}));
15
16 result = con.Query("SELECT strip_accents('mühleisen'), strip_accents('hannes mühleisen')");
17 REQUIRE(CHECK_COLUMN(result, 0, {"muhleisen"}));
18 REQUIRE(CHECK_COLUMN(result, 1, {"hannes muhleisen"}));
19
20 REQUIRE_NO_FAIL(con.Query("CREATE TABLE collate_test(s VARCHAR, str VARCHAR)"));
21 REQUIRE_NO_FAIL(con.Query("INSERT INTO collate_test VALUES ('äää', 'aaa')"));
22 REQUIRE_NO_FAIL(con.Query("INSERT INTO collate_test VALUES ('hännës mühlëïsën', 'hannes muhleisen')"));
23 REQUIRE_NO_FAIL(con.Query("INSERT INTO collate_test VALUES ('olá', 'ola')"));
24 REQUIRE_NO_FAIL(con.Query("INSERT INTO collate_test VALUES ('ôâêóáëòõç', 'oaeoaeooc')"));
25
26 result = con.Query("SELECT strip_accents(s)=strip_accents(str) FROM collate_test");
27 REQUIRE(CHECK_COLUMN(result, 0, {true, true, true, true}));
28}
29