Better test

This commit is contained in:
Alexey Milovidov 2020-07-13 01:30:27 +03:00
parent 8f0ec09372
commit f6f8421c2f
2 changed files with 18 additions and 0 deletions

View File

@ -254,3 +254,4 @@
15 13 0 0 0 0 0 0
15 14 0 0 0 0 0 0
15 15 0 0 0 0 0 0
0 0 0

View File

@ -16,3 +16,20 @@ for OFFSET in {0..15}; do
"
done
done | $CLICKHOUSE_CLIENT -n --max_block_size 5
# Randomized test
ITERATIONS=1000
for i in $(seq $ITERATIONS); do
SIZE=$(($RANDOM % 100))
OFFSET=$(($RANDOM % 111))
LIMIT=$(($RANDOM % 111))
echo "WITH count() AS c, min(number) AS first, max(number) AS last
SELECT
throwIf(first != ($OFFSET < $SIZE AND $LIMIT > 0 ? $OFFSET : 0)),
throwIf(last != ($OFFSET < $SIZE AND $LIMIT > 0 ? least($SIZE - 1, $OFFSET + $LIMIT - 1) : 0)),
throwIf((c != 0 OR first != 0 OR last != 0) AND (c != last - first + 1))
FROM (SELECT * FROM numbers($SIZE) LIMIT $OFFSET, $LIMIT);
"
done | $CLICKHOUSE_CLIENT -n --max_block_size $(($RANDOM % 20)) | uniq