File: | t/convert_case.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | time | code |
---|---|---|---|---|---|---|
1 | 2 2 2 | 10696 4 5 | use Test::Most; | |||
2 | 2 2 2 | 1300 2 8 | use Data::Printer { deparse => 1 }; | |||
3 | 2 2 2 | 409 2 6 | use String::CamelSnakeKebab qw/:all/; | |||
4 | ||||||
5 | my %tests = ( | |||||
6 | 2 | 6 | 'FluxCapacitor' => sub { upper_camel_case 'flux-capacitor' }, | |||
7 | 2 | 6 | 'fluxCapacitor' => sub { lower_camel_case 'flux-capacitor' }, | |||
8 | 2 | 5 | 'a_snake_slithers_slyly' => sub { lower_snake_case 'ASnakeSlithersSlyly' }, | |||
9 | 2 | 8 | 'address1' => sub { lower_snake_case 'address1' }, | |||
10 | 2 | 8 | 'A_Snake_Slithers_Slyly' => sub { upper_snake_case 'ASnakeSlithersSlyly' }, | |||
11 | 2 | 7 | 'I_AM_CONSTANT' => sub { constant_case 'I am constant' }, | |||
12 | 2 | 6 | 'peppers-meat-pineapple' => sub { kebab_case 'Peppers_Meat_Pineapple' }, | |||
13 | 2 | 7 | 'X-SSL-Cipher' => sub { http_header_case 'x-ssl-cipher' }, | |||
14 | 2 | 82712 | ); | |||
15 | ||||||
16 | 2 | 9 | while ( my ($expected_answer, $test_this) = each %tests ) { | |||
17 | ||||||
18 | 16 | 27 | cmp_deeply | |||
19 | $test_this->(), | |||||
20 | $expected_answer, | |||||
21 | "got <$expected_answer> from \n" . p($test_this); | |||||
22 | ||||||
23 | } | |||||
24 | ||||||
25 | 2 | 8 | done_testing; |