Add more substring with enums tests

This commit is contained in:
slvrtrn 2023-11-28 00:43:29 +01:00
parent 497e5abc47
commit ff6bdfe857
2 changed files with 15 additions and 0 deletions

View File

@ -144,5 +144,12 @@ Offset: -6 Length: 3 world eagle wo ea
Offset: -6 Length: 4 world eagle wor eag
Offset: -6 Length: 5 world eagle worl eagl
Offset: -6 Length: 6 world eagle world eagle
-- Zero offset/length
Offset: 0 Length: 0
Offset: 0 Length: 1
Offset: 1 Length: 0 hello shark
Offset: 0 Length: 0
Offset: 0 Length: 1
Offset: 1 Length: 0 world eagle
-- Constant enums
f fo

View File

@ -18,6 +18,14 @@ SELECT 'Offset: ', p.offset, 'Length: ', p.length,
substring(e8, p.offset, p.length) AS s3, substring(e16, p.offset, p.length) AS s4
FROM substring_enums_test LEFT JOIN permutations AS p ON true;
SELECT '-- Zero offset/length';
WITH cte AS (SELECT number AS n FROM system.numbers LIMIT 2),
permutations AS (SELECT c1.n AS offset, c2.n AS length FROM cte AS c1 CROSS JOIN cte AS c2 LIMIT 3)
SELECT 'Offset: ', p.offset, 'Length: ', p.length,
substring(e8, p.offset) AS s1, substring(e16, p.offset) AS s2,
substring(e8, p.offset, p.length) AS s3, substring(e16, p.offset, p.length) AS s4
FROM substring_enums_test LEFT JOIN permutations AS p ON true;
SELECT '-- Constant enums';
SELECT substring(CAST('foo', 'Enum8(\'foo\' = 1)'), 1, 1), substring(CAST('foo', 'Enum16(\'foo\' = 1111)'), 1, 2);