Class: ODDB::FiPDF::TestSubstanceIndex

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/fipdf/test/substance_index_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



12
13
14
# File 'ext/fipdf/test/substance_index_test.rb', line 12

def setup
	@index = SubstanceIndex.new
end

#test_sortObject



36
37
38
39
40
41
42
43
44
45
46
# File 'ext/fipdf/test/substance_index_test.rb', line 36

def test_sort
	element1 = ["aaa", "bbb", 1, :foo]
	element2 = ["bbb", "aaa", 2, :bar]
	element3 = ["ccc", "ddd", 0, :ook]
	@index['foo'] = [element2, element3, element1]
	result = @index.sort
	expected = [
		["foo", [element1, element2, element3]]
	]
	assert_equal(expected, result)
end

#test_storeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'ext/fipdf/test/substance_index_test.rb', line 15

def test_store
	assert_equal({}, @index)
	element1 = ["baar", "buur", 34, :symbol]
	@index.store("foo", element1)
	expected = {"foo" => [element1]}
	assert_equal(expected, @index)
	element2 = ["froh", "frah", 99, :generic]
	@index.store("baz", element2)
	expected = {
		"foo" => [element1],
		"baz" => [element2]
	}
	assert_equal(expected, @index)
	element3 = ["test", "void", 99, :original]
	@index.store("foo", element3)
	expected = {
		"foo" => [element1, element3],
		"baz" => [element2]
	}
	assert_equal(expected, @index)
end