Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/stmtrand.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / stmtrand.test` 48 lines ยท 1742 bytes Raw Blame History 1 # 2024-05-24 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 # Verify that the stmtrand() extension function works. 13 # 14 # Stmtrand() is a pseudo-random number generator designed for testing. 15 # it has the property that it returns the same sequence of pseudo-random 16 # numbers for each SQL statement invocation. This makes it suitable for 17 # testing because the results are reproducible. 18 # 19 # The optional argument is the seed for the PRNG. The seed is only used 20 # on the first invocation. If the argument is omitted, a seed of 0 is 21 # used. 22 # 23 24 set testdir [file dirname $argv0] 25 source $testdir/tester.tcl 26 set testprefix stmtrand 27 28 load_static_extension db stmtrand 29 30 do_execsql_test 1.1 { 31 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) 32 SELECT stmtrand()%10 FROM c 33 } {4 1 8 3 6 1 4 9 2 1 2 1 0 1 8 1 4 7 6 1 8 7 0 3 0 9 4 5 9 9} 34 do_execsql_test 1.2 { 35 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) 36 SELECT stmtrand(0)%10 FROM c 37 } {4 1 8 3 6 1 4 9 2 1 2 1 0 1 8 1 4 7 6 1 8 7 0 3 0 9 4 5 9 9} 38 do_execsql_test 1.3 { 39 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) 40 SELECT stmtrand(1)%10 FROM c 41 } {3 8 9 4 7 2 3 8 5 2 7 0 3 0 7 2 5 6 1 8 5 6 7 8 7 2 9 6 8 0} 42 do_execsql_test 1.4 { 43 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<30) 44 SELECT stmtrand(x)%10 FROM c 45 } {3 8 9 4 7 2 3 8 5 2 7 0 3 0 7 2 5 6 1 8 5 6 7 8 7 2 9 6 8 0} 46 47 48 finish_test