test/test_anvl.rb in anvl-0.1.3 vs test/test_anvl.rb in anvl-0.2.0
- old
+ new
@@ -36,25 +36,26 @@
assert_equal([], h[:a])
h[:a] = 'a'
assert_equal({:a => 'a' }, h.to_h)
h[:a] = ['a', 'b']
assert_equal({:a => ['a', 'b'] }, h.to_h)
- h[:a] << 'c'
+ h[:a].inspect
+ h.store :a, 'c', true
assert_equal({:a => ['a', 'b', 'c'] }, h.to_h)
assert_equal(['a', 'b', 'c'], h[:a])
h[:b]
assert_equal({:a => ['a', 'b', 'c'] }, h.to_h)
h << { :a => 'd' }
assert_equal({:a => ['a', 'b', 'c', 'd'] }, h.to_h)
h << { :c => 1 }
- assert_equal(1, h[:c])
+ assert_equal("1", h[:c])
h << { :c => 2 }
- assert_equal([1, 2], h[:c])
+ assert_equal(["1", "2"], h[:c])
str = h.to_s
assert_match(/^a: a$/, str)
assert_match(/^a: b$/, str)
assert_match(/^a: c$/, str)
@@ -74,11 +75,35 @@
assert_equal('', str)
end
def test_fmt_first_draft
str = ANVL.to_anvl({:entry => [""], :who => ['Gilbert, W.S. | Sullivan, Arthur'], :what => ["The Yeomen of the Guard"], :"when/created" => [1888]})
+ h = ANVL.parse({:entry => [""], :who => ['Gilbert, W.S. | Sullivan, Arthur'], :what => ["The Yeomen of the Guard"], :"when/created" => [1888]})
assert_match(/entry:/, str)
assert_match(/who: Gilbert, W.S. | Sullivan, Arthur/, str)
assert_match(/what: The Yeomen of the Guard/, str)
assert_match(/when\/created: 1888/, str)
end
+
+ def test_display_label
+ h = ANVL::Document.new
+ h['a'] = {:display_label => 'A', :value => '123' }
+ assert_equal("123", h['a'])
+
+ assert_match(/A:/, h.to_s)
+ end
+
+ def test_str_vs_sym
+ str = 'erc:
+who: Lederberg, Joshua
+what: Studies of Human Families for Genetic Linkage
+when: 1974
+where: http://profiles.nlm.nih.gov/BB/AA/TT/tt.pdf
+note: This is an arbitrary note inside a
+ small descriptive record.'
+ h = ANVL::Document.parse str
+
+ assert_equal("Lederberg, Joshua", h['who'])
+ assert_equal("Lederberg, Joshua", h[:who])
+ end
+
end