Skip to content

Commit

Permalink
Add test function with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreis42 committed Dec 27, 2024
1 parent 548f66e commit 9dea335
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions testing/tester.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ proc do_execsql_test {test_name sql_statements expected_outputs} {
}
}

proc do_execsql_test_regex {test_name sql_statements expected_regex} {
foreach db $::test_dbs {
puts [format "(%s) %s Running test: %s" $db [string repeat " " [expr {40 - [string length $db]}]] $test_name]
set combined_sql [string trim $sql_statements]
set actual_output [evaluate_sql $::sqlite_exec $db $combined_sql]

# Validate the actual output against the regular expression
if {![regexp $expected_regex $actual_output]} {
puts "Test FAILED: '$sql_statements'"
puts "returned '$actual_output'"
puts "expected to match regex '$expected_regex'"
exit 1
}
}
}


proc do_execsql_test_on_specific_db {db_name test_name sql_statements expected_outputs} {
puts [format "(%s) %s Running test: %s" $db_name [string repeat " " [expr {40 - [string length $db_name]}]] $test_name]
set combined_sql [string trim $sql_statements]
Expand Down

0 comments on commit 9dea335

Please sign in to comment.