File: prefix.t

package info (click to toggle)
libcql-parser-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 324 kB
  • sloc: perl: 2,388; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;
use Test::More qw( no_plan );

use_ok( 'CQL::PrefixNode' );
use_ok( 'CQL::TermNode' );
use_ok( 'CQL::AndNode' );

my $subtree = CQL::AndNode->new( 
    left    => CQL::TermNode->new( term => 'foo' ),
    right   => CQL::TermNode->new( term => 'bar' )
);

my $prefixNode = CQL::PrefixNode->new(
    name        => 'dc',
    identifier  => 'http://zthes.z3950.org/cql/1.0',
    subtree     => $subtree
);

isa_ok( $prefixNode, 'CQL::PrefixNode' );

my $prefix = $prefixNode->getPrefix();
isa_ok( $prefix, 'CQL::Prefix' );

is( $prefixNode->toCQL(), 
    '>dc="http://zthes.z3950.org/cql/1.0" ((foo) and (bar))', 
    'toCQL()' );

my $xml = $prefixNode->toXCQL();
$xml =~ s/[\r\n]//g;
$xml =~ s/> +/>/g;
is( $xml,
    '<triple xmlns="http://www.loc.gov/zing/cql/xcql/"><prefixes><prefix><name>dc</name><identifier>http://zthes.z3950.org/cql/1.0</identifier></prefix></prefixes><boolean><value>and</value></boolean><leftOperand><searchClause><index></index><term>foo</term></searchClause></leftOperand><rightOperand><searchClause><index></index><term>bar</term></searchClause></rightOperand></triple>', 
    'toXCQL()'
);