Skip Menu |

This queue is for tickets about the Plucene CPAN distribution.

Report information
The Basics
Id: 17373
Status: new
Priority: 0/
Queue: Plucene

People
Owner: Nobody in particular
Requestors: plucene [...] wormbytes.ca
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.24
Fixed in: (no value)



Subject: Fully tested Plucene::Document
The unit tests now works all the methods (and paths) in the Plucene::Document class. The existing unit-tests covered almost everything except for get() on a non-existent field.
Subject: 20060130-document.patch
# HG changeset patch # User Robert James Kaes <rjk@wormbytes.ca> # Node ID 805c26ae235edd589612244218fea8cb0e31bd93 # Parent 70c89ccd908f6454382110bc7af7666bb678f14a [UnitTest] Fully tested Plucene::Document The unit tests now works all the methods (and paths) in the Plucene::Document class. The existing unit-tests covered almost everything except for get() on a non-existent field. diff -r 70c89ccd908f -r 805c26ae235e t/document.t --- /dev/null Thu Jan 1 00:00:00 1970 +0000 +++ b/t/document.t Thu Jan 26 14:58:30 2006 -0500 @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# +# Unit test the Plucene::Document object +# +# Author: Robert James Kaes <rjk@wormbytes.ca> +# + +use strict; +use warnings; + +use Test::More tests => 7; + +BEGIN { + use_ok('Plucene::Document'); + require_ok('Plucene::Document::Field'); +} + +# Create a new Document object +my $doc = Plucene::Document->new(); +isa_ok($doc, 'Plucene::Document'); + +# Try to retrieve a non-existent field from the document. Make sure it +# returns undef. +my $non_field = $doc->get('non_field'); +ok(!defined($non_field), "Got an undef for non-existent field"); + +# Now add a field and make sure we get it back +my $add_field = Plucene::Document::Field->Text('content', 'here'); +$doc->add($add_field); +my $return_field = $doc->get('content'); +is_deeply($add_field, $return_field, "Got back what we added"); + +# Return a list of all the fields added +my @fields_added = ($add_field); +my @doc_fields = $doc->fields; +cmp_ok( + scalar(@doc_fields), '==', scalar(@fields_added), + "Length of field arrays equal", +); +is_deeply( + $fields_added[0], $doc_fields[0], + "Got back the right field from fields()", +); + +# vim: filetype=perl