File: 10-types.t

package info (click to toggle)
libtransmission-client-perl 0.0806-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 3,004; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 1,167 bytes parent folder | download | duplicates (4)
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
26
27
# ex:ts=4:sw=4:sts=4:et
# Tests for helper functions in Transmission::Types
use warnings;
use strict;
use Test::More tests => 11;
use Transmission::Types;

ok  Transmission::Types::_is_num(10), '_is_num(10)';
ok  Transmission::Types::_is_num(10.0), '_is_num(10.0)';
ok !Transmission::Types::_is_num("foo"), 'not _is_num("foo")';
ok !Transmission::Types::_is_num("10.0"), 'not _is_num("10.0")';

is Transmission::Types::_coerce_num("10"), 10,
   'coerced numeric str "10" should become 10';
is Transmission::Types::_coerce_num("10.1"), 10.1,
   'coerced numeric str "10.1" should become 10.1';
is Transmission::Types::_coerce_num("foo"), -1,
   'coerced non-numeric str "foo" should become -1';

ok Transmission::Types::_is_num(Transmission::Types::_coerce_num("10")),
   'coerced numeric str should become num';
ok Transmission::Types::_is_num(Transmission::Types::_coerce_num(10)),
   'coerced integer should still be num';
ok Transmission::Types::_is_num(Transmission::Types::_coerce_num(10.0)),
   'coerced double should still be num';
ok Transmission::Types::_is_num(Transmission::Types::_coerce_num("foo")),
   'coerced non-numeric str "foo" should become num';