1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

First cut at an implementation of the REPLACE() function. We might yet

make this a compile-time option or move it into a separate source file. (CVS 3697)

FossilOrigin-Name: c2fe746ea782f84e850aaf3af7f5536b027a19a1
This commit is contained in:
drh
2007-03-17 13:27:54 +00:00
parent 06f52cb936
commit 26b6d90d74
4 changed files with 118 additions and 13 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.57 2007/01/29 17:58:28 drh Exp $
# $Id: func.test,v 1.58 2007/03/17 13:27:56 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -729,4 +729,49 @@ if {![catch {db eval {SELECT soundex('hello')}}]} {
}
}
# Tests of the REPLACE function.
#
do_test func-21.1 {
catchsql {
SELECT replace(1,2);
}
} {1 {wrong number of arguments to function replace()}}
do_test func-21.2 {
catchsql {
SELECT replace(1,2,3,4);
}
} {1 {wrong number of arguments to function replace()}}
do_test func-21.3 {
execsql {
SELECT typeof(replace("This is the main test string", NULL, "ALT"));
}
} {null}
do_test func-21.4 {
execsql {
SELECT typeof(replace(NULL, "main", "ALT"));
}
} {null}
do_test func-21.5 {
execsql {
SELECT typeof(replace("This is the main test string", "main", NULL));
}
} {null}
do_test func-21.6 {
execsql {
SELECT replace("This is the main test string", "main", "ALT");
}
} {{This is the ALT test string}}
do_test func-21.7 {
execsql {
SELECT replace("This is the main test string", "main", "larger-main");
}
} {{This is the larger-main test string}}
do_test func-21.8 {
execsql {
SELECT replace("aaaaaaa", "a", "0123456789");
}
} {0123456789012345678901234567890123456789012345678901234567890123456789}
finish_test