Commits

Shlomi Fish committed 689441b

Convert t/19encoding.t to Test::More and modernised it.

  • Participants
  • Parent commits 578c693

Comments (0)

Files changed (1)

File t/19encoding.t

 # $Id$
 #
 # This should test the XML::LibXML internal encoding/ decoding.
-# Since most of the internal encoding code is depentend to 
-# the perl version the module is build for. only the encodeToUTF8() and 
+# Since most of the internal encoding code is dependent on 
+# the perl version the module is built for. only the encodeToUTF8() and 
 # decodeFromUTF8() functions are supposed to be general, while all the 
 # magic code is only available for more recent perl version (5.6+)
 #
+# Added note by Shlomi Fish: we are now perl-5.8.x and above so I removed
+# the 5.6.x+ test.
+
 use strict;
 use warnings;
 
-use Test;
+use Test::More;
 
-BEGIN {
+{
     my $tests        = 1;
     my $basics       = 0;
     my $magic        = 6;
+    my $step = $basics + $magic;
 
-    $tests += $basics;
-    $tests += $magic if $] >= 5.006;
+    $tests += $step;
 
     if ( defined $ENV{TEST_LANGUAGES} ) {
       if ( $ENV{TEST_LANGUAGES} eq "all" ) {
-	$tests += 2*$basics;
-	$tests += 2*$magic if $] >= 5.006;
+          $tests += 2 * $step;
       } elsif ( $ENV{TEST_LANGUAGES} eq "EUC-JP"
 		or $ENV{TEST_LANGUAGES} eq "KOI8-R" ) {
-	$tests += $basics;
-	$tests += $magic if $] >= 5.006;
+        $tests += $step;
       }
     }
     plan tests => $tests;
 
 use XML::LibXML::Common;
 use XML::LibXML;
-ok(1);
 
+# TEST
+ok(1, 'Loading');
 
 my $p = XML::LibXML->new();
 
 <t�st>t�st</t�st>
 };
 
-if ( $] < 5.006 ) {
-    warn "\nskip magic encoding tests on this platform\n";
-    exit(0);
-}
-else {
-    print "# magic encoding tests\n";
+{
+    # magic encoding tests
 
     my $dom_latin1 = XML::LibXML::Document->new('1.0', 'iso-8859-1');
     my $elemlat1   = $dom_latin1->createElement( $tstr_iso_latin1 );
 
     $dom_latin1->setDocumentElement( $elemlat1 );
 
-    ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->toString()),
-        "<$tstr_iso_latin1/>");
-    ok( $elemlat1->toString(0,1), "<$tstr_iso_latin1/>");
+    # TEST
+    is( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->toString()),
+        "<$tstr_iso_latin1/>", ' TODO : Add test name');
+    # TEST
+    is( $elemlat1->toString(0,1), "<$tstr_iso_latin1/>", ' TODO : Add test name');
 
     my $elemlat2   = $dom_latin1->createElement( "�l" );
-    ok( $elemlat2->toString(0,1), "<�l/>");
+    # TEST
+    is( $elemlat2->toString(0,1), "<�l/>", ' TODO : Add test name');
 
     $elemlat1->appendText( $tstr_iso_latin1 );
 
-    ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->string_value()),
-        $tstr_iso_latin1);
-    ok( $elemlat1->string_value(1), $tstr_iso_latin1);
+    # TEST
+    is( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->string_value()),
+        $tstr_iso_latin1, ' TODO : Add test name');
+    # TEST
+    is( $elemlat1->string_value(1), $tstr_iso_latin1, ' TODO : Add test name');
 
-    ok( $dom_latin1->toString(), $domstrlat1 );
+    # TEST
+    is( $dom_latin1->toString(), $domstrlat1, ' TODO : Add test name' );
 
 }
 
 exit(0) unless defined $ENV{TEST_LANGUAGES};
 
 if ( $ENV{TEST_LANGUAGES} eq 'all' or $ENV{TEST_LANGUAGES} eq "EUC-JP" ) {
-    print "# japanese encoding (EUC-JP)\n";
+    # japanese encoding (EUC-JP)
 
     my $tstr_euc_jp     = '������������';
     my $domstrjp = q{<?xml version="1.0" encoding="EUC-JP"?>
 };
     
 
-    if ( $] >= 5.006 ) {
+    {
         my $dom_euc_jp = XML::LibXML::Document->new('1.0', 'EUC-JP');
         my $elemjp = $dom_euc_jp->createElement( $tstr_euc_jp );
 
 
-        ok( decodeFromUTF8( 'EUC-JP' , $elemjp->nodeName()),
-            $tstr_euc_jp );
-        ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->toString()),
-            "<$tstr_euc_jp/>");
-        ok( $elemjp->toString(0,1), "<$tstr_euc_jp/>");
+        # TEST
+
+        is( decodeFromUTF8( 'EUC-JP' , $elemjp->nodeName()),
+            $tstr_euc_jp, ' TODO : Add test name' );
+        # TEST
+        is( decodeFromUTF8( 'EUC-JP' ,$elemjp->toString()),
+            "<$tstr_euc_jp/>", ' TODO : Add test name');
+        # TEST
+        is( $elemjp->toString(0,1), "<$tstr_euc_jp/>", ' TODO : Add test name');
 
         $dom_euc_jp->setDocumentElement( $elemjp );
         $elemjp->appendText( $tstr_euc_jp );
 
-        ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->string_value()),
-            $tstr_euc_jp);
-        ok( $elemjp->string_value(1), $tstr_euc_jp);
+        # TEST
 
-        ok( $dom_euc_jp->toString(), $domstrjp );
+        is( decodeFromUTF8( 'EUC-JP' ,$elemjp->string_value()),
+            $tstr_euc_jp, ' TODO : Add test name');
+        # TEST
+        is( $elemjp->string_value(1), $tstr_euc_jp, ' TODO : Add test name');
+
+        # TEST
+
+        is( $dom_euc_jp->toString(), $domstrjp, ' TODO : Add test name' );
     }   
 
 }
 
 if ( $ENV{TEST_LANGUAGES} eq 'all' or $ENV{TEST_LANGUAGES} eq "KOI8-R" ) {
-    print "# cyrillic encoding (KOI8-R)\n";
+    # cyrillic encoding (KOI8-R)
 
     my $tstr_koi8r       = '�����';
     my $domstrkoi = q{<?xml version="1.0" encoding="KOI8-R"?>
 };
     
 
-    if ( $] >= 5.006 ) {
+    {
         my ($dom_koi8, $elemkoi8);
 
         $dom_koi8 = XML::LibXML::Document->new('1.0', 'KOI8-R');
         $elemkoi8 = $dom_koi8->createElement( $tstr_koi8r );
 
-        ok( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->nodeName()), 
-            $tstr_koi8r );
+        # TEST
 
-        ok( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->toString()), 
-            "<$tstr_koi8r/>");
-        ok( $elemkoi8->toString(0,1), "<$tstr_koi8r/>");
+        is( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->nodeName()), 
+            $tstr_koi8r, ' TODO : Add test name' );
+
+        # TEST
+
+        is( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->toString()), 
+            "<$tstr_koi8r/>", ' TODO : Add test name');
+        # TEST
+        is( $elemkoi8->toString(0,1), "<$tstr_koi8r/>", ' TODO : Add test name');
 
         $elemkoi8->appendText( $tstr_koi8r );
 
-        ok( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->string_value()),
-            $tstr_koi8r);
-        ok( $elemkoi8->string_value(1),
-            $tstr_koi8r);
+        # TEST
+
+        is( decodeFromUTF8( 'KOI8-R' ,$elemkoi8->string_value()),
+            $tstr_koi8r, ' TODO : Add test name');
+        # TEST
+        is( $elemkoi8->string_value(1),
+            $tstr_koi8r, ' TODO : Add test name');
         $dom_koi8->setDocumentElement( $elemkoi8 );
 
-        ok( $dom_koi8->toString(),
-            $domstrkoi );
+        # TEST
+
+        is( $dom_koi8->toString(),
+            $domstrkoi, ' TODO : Add test name' );
         
     }
 }