⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 substr.test

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 TEST
字号:
# 2007 May 14## 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 regression tests for SQLite library.  The# focus of this file is testing the built-in SUBSTR() functions.## $Id: substr.test,v 1.1 2007/05/15 01:13:47 drh Exp $set testdir [file dirname $argv0]source $testdir/tester.tcl# Create a table to work with.#execsql {   CREATE TABLE t1(t text, b blob)}proc substr-test {id string i1 i2 result} {  db eval {    DELETE FROM t1;    INSERT INTO t1(t) VALUES($string)  }  do_test substr-$id.1 [subst {    execsql {      SELECT substr(t, $i1, $i2) FROM t1    }  }] [list $result]  set qstr '[string map {' ''} $string]'  do_test substr-$id.2 [subst {    execsql {      SELECT substr($qstr, $i1, $i2)    }  }] [list $result]}proc subblob-test {id hex i1 i2 hexresult} {  db eval "    DELETE FROM t1;    INSERT INTO t1(b) VALUES(x'$hex')  "  do_test substr-$id.1 [subst {    execsql {      SELECT hex(substr(b, $i1, $i2)) FROM t1    }  }] [list $hexresult]  do_test substr-$id.2 [subst {    execsql {      SELECT hex(substr(x'$hex', $i1, $i2))    }  }] [list $hexresult]}# Basic SUBSTR functionality#substr-test 1.1 abcdefg 1 1 asubstr-test 1.2 abcdefg 2 1 bsubstr-test 1.3 abcdefg 1 2 absubstr-test 1.4 abcdefg 1 100 abcdefgsubstr-test 1.5 abcdefg 0 1 asubstr-test 1.6 abcdefg -1 1 gsubstr-test 1.7 abcdefg -1 10 gsubstr-test 1.8 abcdefg -5 3 cdesubstr-test 1.9 abcdefg -7 3 abcsubstr-test 1.10 abcdefg -100 98 abcde# Make sure everything works with long unicode characters#substr-test 2.1 \u1234\u2345\u3456 1 1 \u1234substr-test 2.2 \u1234\u2345\u3456 2 1 \u2345substr-test 2.3 \u1234\u2345\u3456 1 2 \u1234\u2345substr-test 2.4 \u1234\u2345\u3456 -1 1 \u3456substr-test 2.5 a\u1234b\u2345c\u3456c -5 3 b\u2345c# Basic functionality for BLOBs#subblob-test 3.1 61626364656667 1 1 61subblob-test 3.2 61626364656667 2 1 62subblob-test 3.3 61626364656667 1 2 6162subblob-test 3.4 61626364656667 1 100 61626364656667subblob-test 3.5 61626364656667 0 1 61subblob-test 3.6 61626364656667 -1 1 67subblob-test 3.7 61626364656667 -1 10 67subblob-test 3.8 61626364656667 -5 3 636465subblob-test 3.9 61626364656667 -7 3 616263subblob-test 3.10 61626364656667 -100 98 6162636465# If these blobs were strings, then they would contain multi-byte# characters.  But since they are blobs, the substr indices refer# to bytes.#subblob-test 4.1 61E188B462E28D8563E3919663 1 1 61subblob-test 4.2 61E188B462E28D8563E3919663 2 1 E1subblob-test 4.3 61E188B462E28D8563E3919663 1 2 61E1subblob-test 4.4 61E188B462E28D8563E3919663 -2 1 96subblob-test 4.5 61E188B462E28D8563E3919663 -5 4 63E39196subblob-test 4.6 61E188B462E28D8563E3919663 -100 98 61E188B462E28D8563E391 finish_test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -