Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[RT 124214] add tests for returned NULL pointers
  • Loading branch information
FROGGS committed Mar 31, 2015
1 parent c5c2702 commit 76ba0a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions t/04-nativecall/04-pointers.c
Expand Up @@ -18,3 +18,8 @@ DLLEXPORT int CompareSomePointer(void *ptr)
int x = strcmp("Got passed back the pointer I returned", ptr) == 0;
return x;
}

DLLEXPORT void * ReturnNullPointer()
{
return NULL;
}
6 changes: 5 additions & 1 deletion t/04-nativecall/04-pointers.t
Expand Up @@ -4,12 +4,13 @@ use lib 'lib';
use NativeCall;
use Test;

plan 10;
plan 13;

compile_test_lib('04-pointers');

sub ReturnSomePointer() returns Pointer is native("./04-pointers") { * }
sub CompareSomePointer(Pointer) returns int32 is native("./04-pointers") { * }
sub ReturnNullPointer() returns Pointer is native("./04-pointers") { * }

my $x = ReturnSomePointer();
my int $a = 4321;
Expand All @@ -24,3 +25,6 @@ is Pointer.new(0).gist, 'Pointer<NULL>', 'Pointer.new(0) gistifies to "Poin
is Pointer.new(1234).gist, 'Pointer<0x4d2>', 'Pointer.new(1234) gistifies to "Pointer<0x4d2>"';
is Pointer.new($a).gist, 'Pointer<0x10e1>', 'Pointer.new accepts a native int too';
is Pointer.gist, '(Pointer)', 'The Pointer type object gistifies ot "Pointer"';
is ReturnNullPointer().gist, '(Pointer)', 'A returned NULL pointer is the Pointer type object itself';
ok ReturnNullPointer().defined == False, 'A returned NULL pointer is the Pointer type object itself';
ok ReturnNullPointer().Bool == False, 'A returned NULL pointer is the Pointer type object itself';

0 comments on commit 76ba0a2

Please sign in to comment.