Debian Codegraph @

test/func9.test

raw
1 # 2023-08-29
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #*************************************************************************
11 #
12 # Test cases for some newer SQL functions
13 #
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16
17 do_execsql_test func9-100 {
18 SELECT concat('abc',123,null,'xyz');
19 } {abc123xyz}
20 do_execsql_test func9-110 {
21 SELECT typeof(concat(null));
22 } {text}
23 do_catchsql_test func9-120 {
24 SELECT concat();
25 } {1 {wrong number of arguments to function concat()}}
26 do_execsql_test func9-130 {
27 SELECT concat_ws(',',1,2,3,4,5,6,7,8,NULL,9,10,11,12);
28 } {1,2,3,4,5,6,7,8,9,10,11,12}
29 do_execsql_test func9-131 {
30 SELECT concat_ws(',',1,2,3,4,'',6,7,8,NULL,9,10,11,12);
31 } {1,2,3,4,,6,7,8,9,10,11,12}
32 do_execsql_test func9-132 {
33 SELECT concat_ws(',','',2,3,4,'',6,7,8,NULL,9,10,11,12);
34 } {,2,3,4,,6,7,8,9,10,11,12}
35 do_execsql_test func9-133 {
36 SELECT concat_ws(',',NULL,'',3,4,'',6,7,8,NULL,9,10,11,12);
37 } {,3,4,,6,7,8,9,10,11,12}
38 do_execsql_test func9-134 {
39 SELECT concat_ws(',',NULL,NULL,NULL,'',3,4,'',6,7,8,NULL,9,10,11,12);
40 } {,3,4,,6,7,8,9,10,11,12}
41 do_execsql_test func9-140 {
42 SELECT concat_ws(NULL,1,2,3,4,5,6,7,8,NULL,9,10,11,12);
43 } {{}}
44 do_catchsql_test func9-150 {
45 SELECT concat_ws();
46 } {1 {wrong number of arguments to function concat_ws()}}
47 do_catchsql_test func9-160 {
48 SELECT concat_ws(',');
49 } {1 {wrong number of arguments to function concat_ws()}}
50
51 # https://sqlite.org/forum/forumpost/4c344ca61f (2025-03-02)
52 do_execsql_test func9-200 {
53 SELECT unistr('G\u00e4ste');
54 } {Gäste}
55 do_execsql_test func9-210 {
56 SELECT unistr_quote(unistr('G\u00e4ste'));
57 } {'Gäste'}
58 do_execsql_test func9-220 {
59 SELECT format('%#Q',unistr('G\u00e4ste'));
60 } {'Gäste'}
61
62 do_execsql_test func9-300 {
63 SELECT hex( unistr('\UFFFFFFFF') )
64 } {F7BFBFBF}
65
66 finish_test