Debian Codegraph @

src/test/modules/test_json_parser/t/001_test_json_parser_incremental.pl

raw
1
2 # Copyright (c) 2024-2025, PostgreSQL Global Development Group
3
4 # Test the incremental (table-driven) json parser.
5
6
7 use strict;
8 use warnings FATAL => 'all';
9
10 use PostgreSQL::Test::Utils;
11 use Test::More;
12 use FindBin;
13
14 my $test_file = "$FindBin::RealBin/../tiny.json";
15
16 my @exes = (
17 [ "test_json_parser_incremental", ],
18 [ "test_json_parser_incremental", "-o", ],
19 [ "test_json_parser_incremental_shlib", ],
20 [ "test_json_parser_incremental_shlib", "-o", ]);
21
22 foreach my $exe (@exes)
23 {
24 note "testing executable @$exe";
25
26 # Test the usage error
27 my ($stdout, $stderr) = run_command([ @$exe, "-c", 10 ]);
28 like($stderr, qr/Usage:/, 'error message if not enough arguments');
29
30 # Test that we get success for small chunk sizes from 64 down to 1.
31 for (my $size = 64; $size > 0; $size--)
32 {
33 ($stdout, $stderr) = run_command([ @$exe, "-c", $size, $test_file ]);
34
35 like($stdout, qr/SUCCESS/, "chunk size $size: test succeeds");
36 is($stderr, "", "chunk size $size: no error output");
37 }
38 }
39
40 done_testing();