tkt-8454a207b9.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2010 September 30
  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. # This file implements regression tests for SQLite library. Specifically,
  13. # it tests that ticket [8454a207b9fd2243c4c6b7a73f67ea0315717c1a]. Verify
  14. # that a negative default value on an added text column actually comes
  15. # out negative.
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. do_test tkt-8454a207b9.1 {
  20. db eval {
  21. CREATE TABLE t1(a);
  22. INSERT INTO t1 VALUES(1);
  23. ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;
  24. SELECT b, typeof(b) FROM t1;
  25. }
  26. } {-123.0 text}
  27. do_test tkt-8454a207b9.2 {
  28. db eval {
  29. ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;
  30. SELECT c, typeof(c) FROM t1;
  31. }
  32. } {-123.5 text}
  33. do_test tkt-8454a207b9.3 {
  34. db eval {
  35. ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';
  36. SELECT d, typeof(d) FROM t1;
  37. }
  38. } {0 text}
  39. do_test tkt-8454a207b9.4 {
  40. db eval {
  41. ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
  42. SELECT e, typeof(e) FROM t1;
  43. }
  44. } {-123 integer}
  45. do_test tkt-8454a207b9.5 {
  46. db eval {
  47. ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;
  48. SELECT f, typeof(f) FROM t1;
  49. }
  50. } {-123.5 real}
  51. do_test tkt-8454a207b9.6 {
  52. db eval {
  53. ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;
  54. SELECT g, typeof(g) FROM t1;
  55. }
  56. } {-9223372036854775808 integer}
  57. do_test tkt-8454a207b9.7 {
  58. db eval {
  59. ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;
  60. SELECT h, typeof(h) FROM t1;
  61. }
  62. } {9223372036854775807 integer}
  63. finish_test