rbucollate.test 1.5 KB

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