Sha256: 052a0cf39ef8d596b778fbd49bbc2a00aef0438ddcc04ef0168e5c48c6d1dad9
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'test/unit' require 'marc' class TestRecord < Test::Unit::TestCase def test_constructor r = MARC::Record.new() assert_equal(r.class, MARC::Record) end def test_append_field r = get_record() assert_equal(r.fields.length(), 2) end def test_iterator r = get_record() count = 0 r.each {|f| count += 1} assert_equal(count,2) end def test_decode raw = IO.read('test/one.dat') r = MARC::Record::new_from_marc(raw) assert_equal(r.class, MARC::Record) assert_equal(r.leader,'00755cam 22002414a 45000') assert_equal(r.fields.length(), 18) assert_equal(r.find {|f| f.tag == '245'}.to_s, '245 10 $aActivePerl with ASP and ADO /$cTobias Martinsson.') end def test_encode r1 = MARC::Record.new() r1.append(MARC::Field.new('100','2','0', ['a','Thomas, Dave'])) r1.append(MARC::Field.new('245','0','0', ['a','Pragmatic Programmer'])) raw = r1.to_marc() r2 = MARC::Record::new_from_marc(raw) assert_equal(r1, r2) end def test_lookup_shorthand r = get_record assert_equal(r['100']['a'], 'Thomas, Dave') end def get_record r = MARC::Record.new() r.append(MARC::Field.new('100', '2', '0', ['a', 'Thomas, Dave'])) r.append(MARC::Field.new('245', '0', '4', ['The Pragmatic Programmer'])) return r end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
marc-0.0.2 | test/tc_record.rb |