Team Ai
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
stmtrand.test49 linesDownload Raw Back to test
1# 2024-05-242#3# The author disclaims copyright to this source code.  In place of4# 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-random16# numbers for each SQL statement invocation.  This makes it suitable for17# testing because the results are reproducible.18#19# The optional argument is the seed for the PRNG.  The seed is only used20# on the first invocation.  If the argument is omitted, a seed of 0 is21# used.22#23 24set testdir [file dirname $argv0]25source $testdir/tester.tcl26set testprefix stmtrand27 28load_static_extension db stmtrand29 30do_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 c33} {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}34do_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 c37} {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}38do_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 c41} {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}42do_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 c45} {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 48finish_test49