File: 005_is_array_numeric_index.t

package info (click to toggle)
libjson-pointer-perl 0.07-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 578; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 655 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!perl -w
use strict;
use Test::More;
use JSON::Pointer::Syntax qw(is_array_numeric_index);

sub test_is_array_numeric_index {
    my ($token, $expect, $desc) = @_;
    my $actual = is_array_numeric_index($token);
    is($actual, $expect, $desc);
}

subtest "valid numeric index" => sub {
    test_is_array_numeric_index("0", 1, q{"0"});
    test_is_array_numeric_index("23", 1, q{"23"});
};

subtest "invalid numeric index" => sub {
    test_is_array_numeric_index("-23", 0, q{"-23"});
    test_is_array_numeric_index("foo", 0, q{"foo"});
    test_is_array_numeric_index("-", 0, q{"-"});
    test_is_array_numeric_index("", 0, q{""});
};

done_testing;