File: 64bit.t

package info (click to toggle)
libglib-perl 1%3A1.140-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 980 kB
  • ctags: 312
  • sloc: perl: 2,481; ansic: 564; makefile: 53
file content (53 lines) | stat: -rw-r--r-- 1,441 bytes parent folder | download | duplicates (10)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl

#
# Test the various things that deal with 64 bit integers.
#

use strict;
use warnings;
use Glib;
use Test::More tests => 12;

use constant {
  MIN_INT64 => "-9223372036854775807",
  MAX_INT64 => "9223372036854775807",

  MIN_UINT64 => "0",
  MAX_UINT64 => "18446744073709551615"
};

my $spec_int64 =
  Glib::ParamSpec -> int64("int64", "Int", "Blurb",
                           MIN_INT64, MAX_INT64, 0,
                           [qw/readable writable/]);
isa_ok($spec_int64, "Glib::Param::Int64");
is($spec_int64 -> get_minimum(), MIN_INT64);
is($spec_int64 -> get_maximum(), MAX_INT64);
is($spec_int64 -> get_default_value(), 0);

my $spec_uint64 =
  Glib::ParamSpec -> uint64("uint64", "UInt", "Blurb",
                            MIN_UINT64, MAX_UINT64, 0,
                            [qw/readable writable/]);
isa_ok($spec_uint64, "Glib::Param::UInt64");
is($spec_uint64 -> get_minimum(), MIN_UINT64);
is($spec_uint64 -> get_maximum(), MAX_UINT64);
is($spec_uint64 -> get_default_value(), 0);

Glib::Type -> register_object(
  'Glib::Object' => 'Foo',
  properties => [ $spec_int64, $spec_uint64 ]
);

my $foo = Foo -> new();

$foo -> set(int64 => MIN_INT64);
is($foo -> get("int64"), MIN_INT64);
$foo -> set(int64 => MAX_INT64);
is($foo -> get("int64"), MAX_INT64);

$foo -> set(uint64 => MIN_UINT64);
is($foo -> get("uint64"), MIN_UINT64);
$foo -> set(uint64 => MAX_UINT64);
is($foo -> get("uint64"), MAX_UINT64);