XML-LibXML

 view release on metacpan or  search on metacpan

t/05text.t  view on Meta::CPAN


    # 6. XML::LibXML features
    $textnode->setData( $test_str );

    my $new_str = "n\x{1D522}w";
    $textnode->replaceDataString( "e\xDF", $new_str );
    # TEST
    is( $textnode->nodeValue(), "t".$new_str."t",
        'UTF-8 replaceDataString() 1');

    $textnode->replaceDataRegEx( 'n(.)w', '$1s' );
    # TEST
    is( $textnode->nodeValue(), "t\x{1D522}st", 'UTF-8 replaceDataRegEx() 2');

    $textnode->setData( "blue $phish_str, white $phish_str, no $phish_str" );
    $textnode->replaceDataRegEx( $phish_str, $test_str );
    # TEST
    is( $textnode->nodeValue(),
        "blue $test_str, white $phish_str, no $phish_str",
        'UTF-8 replaceDataRegEx 3',);

    # replace them all!
    $textnode->replaceDataRegEx( $phish_str, $test_str, 'g' );
    # TEST
    is( $textnode->nodeValue(),
        "blue $test_str, white $test_str, no $test_str",
        'UTF-8 replaceDataRegEx g',);

    # check if deleteDataString works
    my $hit_str = "hi\x{1D54B}";
    my $pit_str = "\x{2119}it";
    $textnode->setData( "$hit_str$pit_str$hit_str" );
    $textnode->deleteDataString( $hit_str );
    # TEST
    is( $textnode->nodeValue(), "$pit_str$hit_str", 'UTF-8 deleteDataString 1' );

    # check if deleteDataString all works
    $textnode->setData( "$hit_str$pit_str$hit_str" );
    $textnode->deleteDataString( $hit_str, 1 );
    # TEST
    is( $textnode->nodeValue(), $pit_str, 'UTF-8 deleteDataString 2' );
}

{
    # standalone test
    my $node = XML::LibXML::Text->new("foo");
    # TEST
    ok($node, ' TODO : Add test name');
    # TEST
    is($node->nodeValue, "foo", ' TODO : Add test name' );
}

{
    # CDATA node name test

    my $node = XML::LibXML::CDATASection->new("test");

    # TEST
    is( $node->string_value(), "test", ' TODO : Add test name' );
    # TEST
    is( $node->nodeName(), "#cdata-section", ' TODO : Add test name' );
}

{
    # Comment node name test

    my $node = XML::LibXML::Comment->new("test");

    # TEST
    is( $node->string_value(), "test", ' TODO : Add test name' );
    # TEST
    is( $node->nodeName(), "#comment", ' TODO : Add test name' );
}

{
    # Document node name test

    my $node = XML::LibXML::Document->new();

    # TEST
    is( $node->nodeName(), "#document", ' TODO : Add test name' );
}
{
    # Document fragment node name test

    my $node = XML::LibXML::DocumentFragment->new();

    # TEST
    is( $node->nodeName(), "#document-fragment", ' TODO : Add test name' );
}



( run in 0.876 second using v1.01-cache-2.11-cpan-39bf76dae61 )