I can't use Test::Simple, I have to use Test.pm for this module for
backwards compatibility reasons.

I'm trying to replace this function call with an ok() call:

$ctx = Net::SSLeay::SSL_CTX_new() or die ("Unable to create SSL context");

Hard to tell what $ctx is if SSL_CTX_new() fails; I know it returns NULL in c.

> On 4/12/05, Steve Peters <[EMAIL PROTECTED]> wrote:
> > On Tue, Apr 12, 2005 at 12:49:30PM -0500, Walter Goulet wrote:
> > > Hi,
> > >
> > > I was wondering if there is a way to use the ok() function in Test.pm
> > > to check for a null return value. It looks like the 3 arg form of ok()
> > > I'm using only tests the first 2 args to see if they're equal.
> > >
> > > I'm considering this approach:
> > >
> > > $val = some_func(); # returns NULL on failure
> > >
> > > if($val != 0 && $val ne "0")
> > > {
> > >    $isnull = 0;
> > > }
> > > else
> > > {
> > >    $isnull = 1;
> > > }
> > >
> > > ok($isnull,0,"NULL returned");
> > >
> >
> > First, there is no NULL in Perl.  There is undef, so I'll assume that's what
> > you mean.  The test above does not test for undef at all.  It just checks
> > to see that the return is not equal to zero.  If you used Test::Simple, it
> > would be as simple as
> >
> > use strict;
> > use warnings;
> >
> > use Test::Simple tests => 1;
> >
> > my $val = some_func();
> >
> > ok(! defined $val, "undef returned");
> >
> > This should work just fine for what you are testing.
> >
> > Steve Peters
> > [EMAIL PROTECTED]
> >
>

Reply via email to