Skip to content

Commit

Permalink
Converted sql/matching.sql to use check_test().
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Sep 23, 2008
1 parent ac93cc6 commit 7dcc419
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 47 deletions.
40 changes: 22 additions & 18 deletions expected/matching.out
@@ -1,22 +1,26 @@
\unset ECHO
1..20
1..24
ok 1 - matches() should work
ok 2 - matches() should work with a regex
ok 3 - imatches() should work with a regex
ok 4 - matches() failure
ok 5 - Check matches diagnostics
ok 6 - doesnt_match() should work
ok 7 - doesnt_match() should work with a regex
ok 8 - doesnt_imatch() should work with a regex
ok 9 - doesnt_match() failure
ok 10 - doesnt_match() should work
ok 11 - alike() should work
ok 12 - alike() should work with a regex
ok 13 - ialike() should work with a regex
ok 14 - alike() failure
ok 15 - Check alike diagnostics
ok 16 - unalike() should work
ok 17 - unalike() should work with a regex
ok 18 - iunalike() should work with a regex
ok 19 - unalike() failure
ok 20 - Check unalike diagnostics
ok 4 - matches() fail should fail
ok 5 - matches() fail should have the proper description
ok 6 - matches() fail should have the proper diagnostics
ok 7 - doesnt_match() should work
ok 8 - doesnt_match() should work with a regex
ok 9 - doesnt_imatch() should work with a regex
ok 10 - doesnt_match() fail should fail
ok 11 - doesnt_match() fail should have the proper description
ok 12 - doesnt_match() fail should have the proper diagnostics
ok 13 - alike() should work
ok 14 - alike() should work with a regex
ok 15 - ialike() should work with a regex
ok 16 - alike() fail should fail
ok 17 - alike() fail should have the proper description
ok 18 - alike() fail should have the proper diagnostics
ok 19 - unalike() should work
ok 20 - unalike() should work with a regex
ok 21 - iunalike() should work with a regex
ok 22 - unalike() fail should fail
ok 23 - unalike() fail should have the proper description
ok 24 - unalike() fail should have the proper diagnostics
60 changes: 31 additions & 29 deletions sql/matching.sql
Expand Up @@ -3,7 +3,7 @@

-- $Id$

SELECT plan(20);
SELECT plan(24);

/****************************************************************************/
-- Test matches().
Expand All @@ -12,58 +12,60 @@ SELECT matches( 'foo'::text, '^fo', 'matches() should work with a regex' );
SELECT imatches( 'FOO'::text, '^fo', 'imatches() should work with a regex' );

-- Check matches() diagnostics.
\echo ok 4 - matches() failure
SELECT is( matches( 'foo'::text, '^a' ), 'not ok 4
# Failed test 4
# ''foo''
# doesn''t match: ''^a''', 'Check matches diagnostics' );
SELECT * FROM check_test(
matches( 'foo'::text, '^a' ),
false,
'matches() fail',
'',
' ''foo''
doesn''t match: ''^a'''
);

-- Check doesnt_match.
SELECT doesnt_match( 'foo'::text, 'a', 'doesnt_match() should work' );
SELECT doesnt_match( 'foo'::text, '^o', 'doesnt_match() should work with a regex' );
SELECT doesnt_imatch( 'foo'::text, '^o', 'doesnt_imatch() should work with a regex' );

-- Check doesnt_match diagnostics.
\echo ok 9 - doesnt_match() failure
SELECT is(
SELECT * FROM check_test(
doesnt_match( 'foo'::text, 'o' ),
'not ok 9
# Failed test 9
# ''foo''
# matches: ''o''',
'doesnt_match() should work'
false,
'doesnt_match() fail',
'',
' ''foo''
matches: ''o'''
);

-- Clean up the failed test results.
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 4, 9 );

/****************************************************************************/
-- Test alike().
SELECT alike( 'foo'::text, 'foo', 'alike() should work' );
SELECT alike( 'foo'::text, 'fo%', 'alike() should work with a regex' );
SELECT ialike( 'FOO'::text, 'fo%', 'ialike() should work with a regex' );

-- Check alike() diagnostics.
\echo ok 14 - alike() failure
SELECT is( alike( 'foo'::text, 'a%'::text ), 'not ok 14
# Failed test 14
# ''foo''
# doesn''t match: ''a%''', 'Check alike diagnostics' );
SELECT * FROM check_test(
alike( 'foo'::text, 'a%'::text ),
false,
'alike() fail',
'',
' ''foo''
doesn''t match: ''a%'''
);

-- Test unalike().
SELECT unalike( 'foo'::text, 'f', 'unalike() should work' );
SELECT unalike( 'foo'::text, 'f%i', 'unalike() should work with a regex' );
SELECT unialike( 'FOO'::text, 'f%i', 'iunalike() should work with a regex' );

-- Check unalike() diagnostics.
\echo ok 19 - unalike() failure
SELECT is( unalike( 'foo'::text, 'f%'::text ), 'not ok 19
# Failed test 19
# ''foo''
# matches: ''f%''', 'Check unalike diagnostics' );

-- Clean up the failed test results.
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 14, 19 );
SELECT * FROM check_test(
unalike( 'foo'::text, 'f%'::text ),
false,
'unalike() fail',
'',
' ''foo''
matches: ''f%'''
);

/****************************************************************************/
-- Finish the tests and clean up.
Expand Down

0 comments on commit 7dcc419

Please sign in to comment.