File: cmpok.sql

package info (click to toggle)
pgtap 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,792 kB
  • sloc: sql: 25,795; sh: 790; makefile: 287; perl: 175
file content (122 lines) | stat: -rw-r--r-- 2,393 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
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
\unset ECHO
\i test/setup.sql

SELECT plan(38);

/****************************************************************************/
-- Test cmp_ok().
SELECT * FROM check_test(
    cmp_ok( 1, '=', 1, '1 should = 1' ),
    true,
    'cmp_ok( int, =, int )',
    '1 should = 1',
    ''
);

SELECT * FROM check_test(
    cmp_ok( 1, '<>', 2, '1 should <> 2' ),
    true,
    'cmp_ok( int, <>, int )',
    '1 should <> 2',
    ''
);

SELECT * FROM check_test(
    cmp_ok( '((0,0),(1,1))'::polygon, '~=', '((1,1),(0,0))'::polygon ),
    true,
    'cmp_ok( polygon, ~=, polygon )'
    '',
    ''
);

SELECT * FROM check_test(
    cmp_ok( ARRAY[1, 2], '=', ARRAY[1, 2]),
    true,
    'cmp_ok( int[], =, int[] )',
    '',
    ''
);

SELECT * FROM check_test(
    cmp_ok( ARRAY['192.168.1.2'::inet], '=', ARRAY['192.168.1.2'::inet] ),
    true,
    'cmp_ok( inet[], =, inet[] )',
    '',
    ''
);

SELECT * FROM check_test(
    cmp_ok( 1, '=', 2, '1 should = 2' ),
    false,
    'cmp_ok() fail',
    '1 should = 2',
    '    ''1''
        =
    ''2'''
);

SELECT * FROM check_test(
    cmp_ok( 1, '=', NULL, '1 should = NULL' ),
    false,
    'cmp_ok() NULL fail',
    '1 should = NULL',
    '    ''1''
        =
    NULL'
);


/****************************************************************************/
-- Test isa_ok().
SELECT * FROM check_test(
    isa_ok( ''::text, 'text', 'an empty string' ),
    true,
    'isa_ok("", text, desc)',
    'an empty string isa text',
    ''
);

SELECT * FROM check_test(
    isa_ok( ''::text, 'text', 'an empty string' ),
    true,
    'isa_ok("", text, desc)',
    'an empty string isa text',
    ''
);

SELECT * FROM check_test(
    isa_ok( false, 'bool' ),
    true,
    'isa_ok(false, boolean)',
    'the value isa boolean',
    ''
);

SELECT * FROM check_test(
    isa_ok( NULL::boolean, 'bool' ),
    true,
    'isa_ok(NULL, boolean)',
    'the value isa boolean',
    ''
);

SELECT * FROM check_test(
    isa_ok( ARRAY[false], 'bool[]' ),
    true,
    'isa_ok(ARRAY, boolean[])',
    'the value isa boolean[]',
    ''
);

SELECT * FROM check_test(
    isa_ok( true, 'int[]' ),
    false,
    'isa_ok(bool, int[])',
    'the value isa integer[]',
    '    the value isn''t a "integer[]" it''s a "boolean"'
);

/****************************************************************************/
-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;