Skip to content

Commit

Permalink
Simplify added tests with foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
jussisaurio committed Jan 20, 2025
1 parent 2cd9118 commit ce15ad7
Showing 1 changed file with 22 additions and 77 deletions.
99 changes: 22 additions & 77 deletions testing/where.test
Original file line number Diff line number Diff line change
Expand Up @@ -385,80 +385,25 @@ do_execsql_test nested-parens-and-inside-or-regression-test {
} {1}

# Regression tests for binary conditional jump comparisons where one operand is null
do_execsql_test where-binary-one-operand-null-1 {
select * from users where first_name = NULL;
} {}

do_execsql_test where-binary-one-operand-null-2 {
select first_name from users where first_name = NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-3 {
select first_name from users where first_name = NULL AND id = 1;
} {}

do_execsql_test where-binary-one-operand-null-4 {
select * from users where first_name > NULL;
} {}

do_execsql_test where-binary-one-operand-null-5 {
select first_name from users where first_name > NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-6 {
select first_name from users where first_name > NULL AND id = 1;
} {}

do_execsql_test where-binary-one-operand-null-7 {
select * from users where first_name < NULL;
} {}

do_execsql_test where-binary-one-operand-null-8 {
select first_name from users where first_name < NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-9 {
select first_name from users where first_name < NULL AND id = 1;
} {}

do_execsql_test where-binary-one-operand-null-10 {
select * from users where first_name >= NULL;
} {}

do_execsql_test where-binary-one-operand-null-11 {
select first_name from users where first_name >= NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-12 {
select first_name from users where first_name >= NULL AND id = 1;
} {}

do_execsql_test where-binary-one-operand-null-13 {
select * from users where first_name <= NULL;
} {}

do_execsql_test where-binary-one-operand-null-14 {
select first_name from users where first_name <= NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-15 {
select first_name from users where first_name <= NULL AND id = 1;
} {}

do_execsql_test where-binary-one-operand-null-16 {
select * from users where first_name != NULL;
} {}

do_execsql_test where-binary-one-operand-null-17 {
select first_name from users where first_name != NULL OR id = 1;
} {Jamie}

do_execsql_test where-binary-one-operand-null-18 {
select first_name from users where first_name != NULL AND id = 1;
} {}






# Test behavior of binary comparisons (=,>,<,>=,<=,!=) when one operand is NULL
# Each test has 3 variants:
# 1. Simple comparison with NULL (should return empty)
# 2. Comparison with NULL OR id=1 (should return Jamie)
# 3. Comparison with NULL AND id=1 (should return empty)
foreach {operator} {
=
>
<
>=
<=
!=
} {
# Simple NULL comparison
do_execsql_test where-binary-one-operand-null-$operator "select * from users where first_name $operator NULL" {}

# NULL comparison OR id=1
do_execsql_test where-binary-one-operand-null-or-$operator "select first_name from users where first_name $operator NULL OR id = 1" {Jamie}

# NULL comparison AND id=1
do_execsql_test where-binary-one-operand-null-and-$operator "select first_name from users where first_name $operator NULL AND id = 1" {}
}

0 comments on commit ce15ad7

Please sign in to comment.