Sha256: bfcb537a51307eb3bb4e33cab21eb1546ffe5c17878db66df59bf93d752f9cb7

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

require 'test/unit'
require 'marc'

class ReaderTest < Test::Unit::TestCase

    def test_batch
        reader = MARC::Reader.new('test/batch.dat')
        count = 0
        reader.each { count += 1 }
        assert_equal(count, 10)
    end

    def test_search
        reader = MARC::Reader.new('test/batch.dat')
        records = reader.find_all { |r| r =~ /Perl/ }
        assert_equal(records.length,10)

        reader = MARC::Reader.new('test/batch.dat')
        records = reader.find_all { |r| r['245'] =~ /Perl/ }
        assert_equal(records.length,10)

        reader = MARC::Reader.new('test/batch.dat')
        records = reader.find_all { |r| r['245']['a'] =~ /Perl/ }
        assert_equal(records.length,10)

        reader = MARC::Reader.new('test/batch.dat')
        records = reader.find_all { |r| r =~ /Foo/ }
        assert_equal(records.length,0)
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marc-0.0.2 test/tc_reader.rb