gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/tkt-8454a207b9.test (about)

     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  
    18  set testdir [file dirname $argv0]
    19  source $testdir/tester.tcl
    20  
    21  # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
    22  ifcapable !altertable {
    23    finish_test
    24    return
    25  }
    26  
    27  do_test tkt-8454a207b9.1 {
    28    db eval {
    29      CREATE TABLE t1(a);
    30      INSERT INTO t1 VALUES(1);
    31      ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;
    32      SELECT b, typeof(b) FROM t1;
    33    }
    34  } {-123.0 text}
    35  do_test tkt-8454a207b9.2 {
    36    db eval {
    37      ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;
    38      SELECT c, typeof(c) FROM t1;
    39    }
    40  } {-123.5 text}
    41  do_test tkt-8454a207b9.3 {
    42    db eval {
    43      ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';
    44      SELECT d, typeof(d) FROM t1;
    45    }
    46  } {0 text}
    47  do_test tkt-8454a207b9.4 {
    48    db eval {
    49      ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
    50      SELECT e, typeof(e) FROM t1;
    51    }
    52  } {-123 integer}
    53  do_test tkt-8454a207b9.5 {
    54    db eval {
    55      ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;
    56      SELECT f, typeof(f) FROM t1;
    57    }
    58  } {-123.5 real}
    59  do_test tkt-8454a207b9.6 {
    60    db eval {
    61      ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;
    62      SELECT g, typeof(g) FROM t1;
    63    }
    64  } {-9223372036854775808 integer}
    65  do_test tkt-8454a207b9.7 {
    66    db eval {
    67      ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;
    68      SELECT h, typeof(h) FROM t1;
    69    }
    70  } {9223372036854775807 integer}
    71  
    72  
    73  finish_test