[Compbench-devel] CompBenchmarks++/CBM-PI/t 00-XML.pl, NONE, 1.1 Makefile.am, 1.6, 1.7
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-01-17 19:14:43
|
Update of /cvsroot/compbench/CompBenchmarks++/CBM-PI/t In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv17826 Modified Files: Makefile.am Added Files: 00-XML.pl Log Message: XML handling classes tested. Index: Makefile.am =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/CBM-PI/t/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 11 Jan 2007 17:34:27 -0000 1.6 --- Makefile.am 17 Jan 2007 19:14:40 -0000 1.7 *************** *** 1,5 **** SUBDIRS = lib reference ! prog_tests = 00-Glue.pl \ 00-CBMSystem-public.pl 01-CBMSystem-protected.pl \ 02-CBMSystem-benchs.pl \ --- 1,5 ---- SUBDIRS = lib reference ! prog_tests = 00-Glue.pl 00-XML.pl \ 00-CBMSystem-public.pl 01-CBMSystem-protected.pl \ 02-CBMSystem-benchs.pl \ *************** *** 7,10 **** --- 7,11 ---- tests = $(top_srcdir)/CBM-PI/t/00-Glue.pl \ + $(top_srcdir)/CBM-PI/t/00-XML.pl \ $(top_srcdir)/CBM-PI/t/00-CBMSystem-public.pl \ $(top_srcdir)/CBM-PI/t/01-CBMSystem-protected.pl \ --- NEW FILE: 00-XML.pl --- #!/usr/bin/perl -w -I .. use strict; use CBM; use Test::Simple tests => 32; my $sys; sub test_str { my $node = shift; my $expected = shift; my $v = $node->str(); ok($v eq $expected, "$node str is\n$v" . "END ***expected** :\n$expected" . "END"); } sub test_node { my $node = shift; my $name = shift; my $value = shift; my $childs = shift; ok(defined($node)); ok($node->Name() eq $name); my $v=$node->Value(); if (!defined($v)) { ok(!defined($value)); } else { ok($v eq $value); } ok($node->childNumber() == $childs); } sub test_attribute { my $attribute = shift; my $name = shift; my $value = shift; ok(defined($attribute)); ok($attribute->Name() eq $name); my $v=$attribute->Value(); if (!defined($v)) { ok(!defined($value)); } else { ok($v eq $value); } } sub test_node_eq { my $node0 = shift; my $node1 = shift; ok($node0->Name() eq $node1->Name()); ok($node0->childNumber() eq $node1->childNumber()); my $v0=$node0->Value(); my $v1=$node1->Value(); if (!defined($v0)) { ok(!defined($v1)); } else { ok($v0 eq $v1); } } sub test_xml { my $root = CBM::CBMXMLNode->new("root"); my $child = CBM::CBMXMLNode->new("child"); test_node($root, "root", undef, 0); test_str($root, "<root/>\n"); test_node($child, "child", undef, 0); test_str($child, "<child/>\n"); $root->add($child); ok($root->childNumber() == 1); ok($child->childNumber() == 0); test_node_eq($child, $root->getChild(0)); test_str($root, "<root>\n <child/>\n</root>\n"); $root->setValue("root-value"); test_node($root, "root", "root-value", 1); test_node($child, "child", undef, 0); test_str($root, "<root>\n <child/>\n root-value\n</root>\n"); my $att0 = CBM::CBMXMLAttribute->new("att0"); test_attribute($att0, "att0", undef); $root->add($att0); test_attribute($root->getAttribute(0), "att0", undef); } sub test_xml_sample { my $root = CBM::CBMXMLNode->new("point"); $root->addAttribute("x", "0"); $root->addAttribute("y", "1"); $root->addAttribute("z", "-1"); my $color = CBM::CBMXMLNode->new("color"); $color->addAttribute("mode", "plain"); $color->setValue("blue"); $root->setValue("blinking"); $root->add($color); my $x = <<EOF <point x="0" y="1" z="-1"> <color mode="plain"> blue </color> blinking </point> EOF ; ok($root->str() eq $x); } $sys = CBM::Init(); test_xml(); test_xml_sample(); $sys->done(); |