Add the test_regexp.c module containing a cross-platform implementation
of the REGEXP operator. FossilOrigin-Name: 46c8c01b751c1ea7fc02cc35e3b5bb99dbe46c4b
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# 2012 December 31
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements test for the REGEXP operator in test_regexp.c.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_test regexp1-1.1 {
|
||||
sqlite3_add_regexp_func db
|
||||
db eval {
|
||||
CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);
|
||||
INSERT INTO t1 VALUES(1, 'For since by man came death,');
|
||||
INSERT INTO t1 VALUES(2, 'by man came also the resurrection of the dead.');
|
||||
INSERT INTO t1 VALUES(3, 'For as in Adam all die,');
|
||||
INSERT INTO t1 VALUES(4, 'even so in Christ shall all be made alive.');
|
||||
|
||||
SELECT x FROM t1 WHERE y REGEXP '^For ' ORDER BY x;
|
||||
}
|
||||
} {1 3}
|
||||
|
||||
do_execsql_test regexp1-1.2 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'by|in' ORDER BY x;
|
||||
} {1 2 3 4}
|
||||
do_execsql_test regexp1-1.3 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'by|Christ' ORDER BY x;
|
||||
} {1 2 4}
|
||||
do_execsql_test regexp1-1.4 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'shal+ al+' ORDER BY x;
|
||||
} {4}
|
||||
do_execsql_test regexp1-1.5 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'shall x*y*z*all' ORDER BY x;
|
||||
} {4}
|
||||
do_execsql_test regexp1-1.6 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'shallx?y? ?z?all' ORDER BY x;
|
||||
} {4}
|
||||
do_execsql_test regexp1-1.7 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'r{2}' ORDER BY x;
|
||||
} {2}
|
||||
do_execsql_test regexp1-1.8 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'r{3}' ORDER BY x;
|
||||
} {}
|
||||
do_execsql_test regexp1-1.9 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'r{1}' ORDER BY x;
|
||||
} {1 2 3 4}
|
||||
do_execsql_test regexp1-1.10 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'ur{2,10}e' ORDER BY x;
|
||||
} {2}
|
||||
do_execsql_test regexp1-1.11 {
|
||||
SELECT x FROM t1 WHERE y REGEXP '[Aa]dam' ORDER BY x;
|
||||
} {3}
|
||||
do_execsql_test regexp1-1.12 {
|
||||
SELECT x FROM t1 WHERE y REGEXP '[^Aa]dam' ORDER BY x;
|
||||
} {}
|
||||
do_execsql_test regexp1-1.13 {
|
||||
SELECT x FROM t1 WHERE y REGEXP '[^b-zB-Z]dam' ORDER BY x;
|
||||
} {3}
|
||||
do_execsql_test regexp1-1.14 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'alive' ORDER BY x;
|
||||
} {4}
|
||||
do_execsql_test regexp1-1.15 {
|
||||
SELECT x FROM t1 WHERE y REGEXP '^alive' ORDER BY x;
|
||||
} {}
|
||||
do_execsql_test regexp1-1.16 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'alive$' ORDER BY x;
|
||||
} {}
|
||||
do_execsql_test regexp1-1.17 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'alive.$' ORDER BY x;
|
||||
} {4}
|
||||
do_execsql_test regexp1-1.18 {
|
||||
SELECT x FROM t1 WHERE y REGEXP 'alive\.$' ORDER BY x;
|
||||
} {4}
|
||||
|
||||
|
||||
finish_test
|
||||
Reference in New Issue
Block a user