xref: /sqlite-3.40.0/ext/rbu/rbucollate.test (revision 6ab91a7a)
1# 2018 March 22
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
13source [file join [file dirname [info script]] rbu_common.tcl]
14set ::testprefix rbucollate
15
16ifcapable !icu_collations {
17  finish_test
18  return
19}
20
21db close
22sqlite3_shutdown
23sqlite3_config_uri 1
24reset_db
25
26# Create a simple RBU database. That expects to write to a table:
27#
28#   CREATE TABLE t1(a PRIMARY KEY, b, c);
29#
30proc create_rbu1 {filename} {
31  forcedelete $filename
32  sqlite3 rbu1 $filename
33  rbu1 eval {
34    CREATE TABLE data_t1(a, b, c, rbu_control);
35    INSERT INTO data_t1 VALUES('a', 'one', 1, 0);
36    INSERT INTO data_t1 VALUES('b', 'two', 2, 0);
37    INSERT INTO data_t1 VALUES('c', 'three', 3, 0);
38  }
39  rbu1 close
40  return $filename
41}
42
43do_execsql_test 1.0 {
44  SELECT icu_load_collation('en_US', 'my-collate');
45  CREATE TABLE t1(a COLLATE "my-collate" PRIMARY KEY, b, c);
46} {{}}
47
48do_test 1.2 {
49  create_rbu1 testrbu.db
50  sqlite3rbu rbu test.db testrbu.db
51  rbu dbMain_eval { SELECT icu_load_collation('en_US', 'my-collate') }
52  rbu dbRbu_eval { SELECT icu_load_collation('en_US', 'my-collate') }
53  while 1 {
54    set rc [rbu step]
55    if {$rc!="SQLITE_OK"} break
56  }
57  rbu close
58  db eval { SELECT * FROM t1 }
59} {a one 1 b two 2 c three 3}
60
61#forcedelete testrbu.db
62finish_test
63