several testcases for perl
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10403 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ef7c0cbbd2
commit
8b713d759d
53 changed files with 2037 additions and 486 deletions
|
|
@ -1,171 +1,111 @@
|
|||
use template_default_arg;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 34;
|
||||
BEGIN { use_ok('template_default_arg') }
|
||||
require_ok('template_default_arg');
|
||||
|
||||
{
|
||||
$helloInt = new template_default_arg::Hello_int();
|
||||
my $helloInt = new template_default_arg::Hello_int();
|
||||
$helloInt->foo(0);
|
||||
}
|
||||
{
|
||||
$x = new template_default_arg::X_int();
|
||||
if ($x->meth(20.0, 200) != 200) {
|
||||
die "X_int test 1 failed";
|
||||
}
|
||||
if ($x->meth(20) != 20) {
|
||||
die "X_int test 2 failed";
|
||||
}
|
||||
if ($x->meth() != 0) {
|
||||
die "X_int test 3 failed";
|
||||
}
|
||||
my $x = new template_default_arg::X_int();
|
||||
is($x->meth(20.0, 200), 200, "X_int test 1");
|
||||
is($x->meth(20), 20, "X_int test 2");
|
||||
is($x->meth(), 0, "X_int test 3");
|
||||
}
|
||||
|
||||
{
|
||||
$y = new template_default_arg::Y_unsigned();
|
||||
if ($y->meth(20.0, 200) != 200) {
|
||||
die "Y_unsigned test 1 failed";
|
||||
}
|
||||
if ($y->meth(20) != 20) {
|
||||
die "Y_unsigned test 2 failed";
|
||||
}
|
||||
if ($y->meth() != 0) {
|
||||
die "Y_unsigned test 3 failed";
|
||||
}
|
||||
my $y = new template_default_arg::Y_unsigned();
|
||||
is($y->meth(20.0, 200), 200, "Y_unsigned test 1");
|
||||
is($y->meth(20), 20, "Y_unsigned test 2");
|
||||
is($y->meth(), 0, "Y_unsigned test 3");
|
||||
}
|
||||
|
||||
{
|
||||
$x = new template_default_arg::X_longlong();
|
||||
my $x = new template_default_arg::X_longlong();
|
||||
$x = new template_default_arg::X_longlong(20.0);
|
||||
$x = new template_default_arg::X_longlong(20.0, 200);
|
||||
}
|
||||
{
|
||||
$x = new template_default_arg::X_int();
|
||||
my $x = new template_default_arg::X_int();
|
||||
$x = new template_default_arg::X_int(20.0);
|
||||
$x = new template_default_arg::X_int(20.0, 200);
|
||||
}
|
||||
{
|
||||
$x = new template_default_arg::X_hello_unsigned();
|
||||
my $x = new template_default_arg::X_hello_unsigned();
|
||||
$x = new template_default_arg::X_hello_unsigned(20.0);
|
||||
$x = new template_default_arg::X_hello_unsigned(20.0, new template_default_arg::Hello_int());
|
||||
}
|
||||
{
|
||||
$y = new template_default_arg::Y_hello_unsigned();
|
||||
my $y = new template_default_arg::Y_hello_unsigned();
|
||||
$y->meth(20.0, new template_default_arg::Hello_int());
|
||||
$y->meth(new template_default_arg::Hello_int());
|
||||
$y->meth();
|
||||
}
|
||||
|
||||
{
|
||||
$fz = new template_default_arg::Foo_Z_8();
|
||||
$x = new template_default_arg::X_Foo_Z_8();
|
||||
$fzc = $x->meth($fz);
|
||||
my $fz = new template_default_arg::Foo_Z_8();
|
||||
my $x = new template_default_arg::X_Foo_Z_8();
|
||||
my $fzc = $x->meth($fz);
|
||||
}
|
||||
|
||||
# Templated functions
|
||||
{
|
||||
# plain function: int ott(Foo<int>)
|
||||
if (template_default_arg::ott(new template_default_arg::Foo_int()) != 30) {
|
||||
die "ott test 1 failed";
|
||||
}
|
||||
is(template_default_arg::ott(new template_default_arg::Foo_int()), 30, "ott test 1");
|
||||
|
||||
# %template(ott) ott<int, int>;
|
||||
if (template_default_arg::ott() != 10) {
|
||||
die "ott test 2 failed";
|
||||
}
|
||||
if (template_default_arg::ott(1) != 10) {
|
||||
die "ott test 3 failed";
|
||||
}
|
||||
if (template_default_arg::ott(1, 1) != 10) {
|
||||
die "ott test 4 failed";
|
||||
}
|
||||
is(template_default_arg::ott(), 10, "ott test 2");
|
||||
is(template_default_arg::ott(1), 10, "ott test 3");
|
||||
is(template_default_arg::ott(1, 1), 10, "ott test 4");
|
||||
|
||||
if (template_default_arg::ott("hi") != 20) {
|
||||
die "ott test 5 failed";
|
||||
}
|
||||
if (template_default_arg::ott("hi", 1) != 20) {
|
||||
die "ott test 6 failed";
|
||||
}
|
||||
if (template_default_arg::ott("hi", 1, 1) != 20) {
|
||||
die "ott test 7 failed";
|
||||
}
|
||||
is(template_default_arg::ott("hi"), 20, "ott test 5");
|
||||
is(template_default_arg::ott("hi", 1), 20, "ott test 6");
|
||||
is(template_default_arg::ott("hi", 1, 1), 20,"ott test 7");
|
||||
|
||||
# %template(ott) ott<const char *>;
|
||||
if (template_default_arg::ottstring(new template_default_arg::Hello_int(), "hi") != 40) {
|
||||
die "ott test 8 failed";
|
||||
}
|
||||
is(template_default_arg::ottstring(new template_default_arg::Hello_int(), "hi"), 40, "ott test 8");
|
||||
|
||||
if (template_default_arg::ottstring(new template_default_arg::Hello_int()) != 40) {
|
||||
die "ott test 9 failed";
|
||||
}
|
||||
is(template_default_arg::ottstring(new template_default_arg::Hello_int()), 40, "ott test 9");
|
||||
|
||||
# %template(ott) ott<int>;
|
||||
if (template_default_arg::ottint(new template_default_arg::Hello_int(), 1) != 50) {
|
||||
die "ott test 10 failed";
|
||||
}
|
||||
is(template_default_arg::ottint(new template_default_arg::Hello_int(), 1), 50, "ott test 10");
|
||||
|
||||
if (template_default_arg::ottint(new template_default_arg::Hello_int()) != 50) {
|
||||
die "ott test 11 failed";
|
||||
}
|
||||
is(template_default_arg::ottint(new template_default_arg::Hello_int()), 50, "ott test 11");
|
||||
|
||||
# %template(ott) ott<double>;
|
||||
if (template_default_arg::ott(new template_default_arg::Hello_int(), 1.0) != 60) {
|
||||
die "ott test 12 failed";
|
||||
}
|
||||
is(template_default_arg::ott(new template_default_arg::Hello_int(), 1.0), 60, "ott test 12");
|
||||
|
||||
if (template_default_arg::ott(new template_default_arg::Hello_int()) != 60) {
|
||||
die "ott test 13 failed";
|
||||
}
|
||||
is(template_default_arg::ott(new template_default_arg::Hello_int()), 60, "ott test 13");
|
||||
}
|
||||
|
||||
# Above test in namespaces
|
||||
{
|
||||
# plain function: int nsott(Foo<int>)
|
||||
if (template_default_arg::nsott(new template_default_arg::Foo_int()) != 130) {
|
||||
die "nsott test 1 failed";
|
||||
}
|
||||
is(template_default_arg::nsott(new template_default_arg::Foo_int()), 130, "nsott test 1");
|
||||
|
||||
# %template(nsott) nsott<int, int>;
|
||||
if (template_default_arg::nsott() != 110) {
|
||||
die "nsott test 2 failed";
|
||||
}
|
||||
if (template_default_arg::nsott(1) != 110) {
|
||||
die "nsott test 3 failed";
|
||||
}
|
||||
if (template_default_arg::nsott(1, 1) != 110) {
|
||||
die "nsott test 4 failed";
|
||||
}
|
||||
is(template_default_arg::nsott(), 110, "nsott test 2");
|
||||
is(template_default_arg::nsott(1), 110, "nsott test 3");
|
||||
is(template_default_arg::nsott(1, 1), 110, "nsott test 4");
|
||||
|
||||
if (template_default_arg::nsott("hi") != 120) {
|
||||
die "nsott test 5 failed";
|
||||
}
|
||||
if (template_default_arg::nsott("hi", 1) != 120) {
|
||||
die "nsott test 6 failed";
|
||||
}
|
||||
if (template_default_arg::nsott("hi", 1, 1) != 120) {
|
||||
die "nsott test 7 failed";
|
||||
}
|
||||
is(template_default_arg::nsott("hi"), 120, "nsott test 5");
|
||||
is(template_default_arg::nsott("hi", 1), 120, "nsott test 6");
|
||||
is(template_default_arg::nsott("hi", 1, 1), 120, "nsott test 7");
|
||||
|
||||
# %template(nsott) nsott<const char *>;
|
||||
if (template_default_arg::nsottstring(new template_default_arg::Hello_int(), "hi") != 140) {
|
||||
die "nsott test 8 failed";
|
||||
}
|
||||
is(template_default_arg::nsottstring(new template_default_arg::Hello_int(), "hi"), 140, "nsott test 8");
|
||||
|
||||
if (template_default_arg::nsottstring(new template_default_arg::Hello_int()) != 140) {
|
||||
die "nsott test 9 failed";
|
||||
}
|
||||
is(template_default_arg::nsottstring(new template_default_arg::Hello_int()), 140, "nsott test 9");
|
||||
|
||||
# %template(nsott) nsott<int>;
|
||||
if (template_default_arg::nsottint(new template_default_arg::Hello_int(), 1) != 150) {
|
||||
die "nsott test 10 failed";
|
||||
}
|
||||
is(template_default_arg::nsottint(new template_default_arg::Hello_int(), 1), 150, "nsott test 10");
|
||||
|
||||
if (template_default_arg::nsottint(new template_default_arg::Hello_int()) != 150) {
|
||||
die "nsott test 11 failed";
|
||||
}
|
||||
is(template_default_arg::nsottint(new template_default_arg::Hello_int()), 150, "nsott test 11");
|
||||
|
||||
# %template(nsott) nsott<double>;
|
||||
if (template_default_arg::nsott(new template_default_arg::Hello_int(), 1.0) != 160) {
|
||||
die "nsott test 12 failed";
|
||||
}
|
||||
is(template_default_arg::nsott(new template_default_arg::Hello_int(), 1.0), 160, "nsott test 12");
|
||||
|
||||
if (template_default_arg::nsott(new template_default_arg::Hello_int()) != 160) {
|
||||
die "nsott test 13 failed";
|
||||
}
|
||||
is(template_default_arg::nsott(new template_default_arg::Hello_int()), 160, "nsott test 13");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue