File: term.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 (41 lines) | stat: -rw-r--r-- 1,462 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
36
37
38
39
40
41
use strict;
use warnings;
use Test::More qw( no_plan );

use_ok( "CQL::TermNode" );
use_ok( "CQL::Relation" );

NO_RELATION: {
    my $node = CQL::TermNode->new( term => 'george' );
    isa_ok( $node, 'CQL::TermNode' );
    is( $node->getTerm(), 'george', 'term()' );
    is( $node->toCQL(), 'george', 'toCQL()' );
}

QUALIFIER_AND_RELATION: {
    my $node = CQL::TermNode->new(
        qualifier   => 'dc.creator',
        relation    => CQL::Relation->new( '=' ),
        term        => 'george' );
    is( $node->getQualifier(), 'dc.creator', 'getQualifier()' );
    is( $node->getRelation()->getBase(), '=', 'getRelation()' );
    is( $node->getTerm(), 'george', 'getTerm()' );
    is( $node->toCQL(), 'dc.creator = george', 'toCQL()' );
    my $xcql = $node->toXCQL(0);
    $xcql =~ s/[\r\n]//g;
    $xcql =~ s/> +</></g;
    is( $xcql, qq(<searchClause xmlns="http://www.loc.gov/zing/cql/xcql/"><index>dc.creator</index><relation><value>=</value></relation><term>george</term></searchClause>), 'toXCQL()' )
}

SPACES_IN_TERM: {
    my $node = CQL::TermNode->new(
        qualifier   => 'dc.creator',
        relation    => CQL::Relation->new( '>' ),
        term        => 'george clinton' );
    is( $node->getQualifier(), 'dc.creator', 'getQualifier()' );
    is( $node->getRelation()->getBase(), '>', 'getRelation()' );
    is( $node->getTerm(), 'george clinton', 'getTerm()' );
    is( $node->toCQL(), 'dc.creator > "george clinton"', 'toCQL()' );
}