test/test_index.rb in review-1.4.0 vs test/test_index.rb in review-1.5.0
- old
+ new
@@ -40,12 +40,120 @@
===[column] column2
=== sec1-2-2
== sec1-3
==== sec1-3-0-1
EOB
- chap = Book::Chapter.new(nil, 1, '-', nil) # dummy
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
index = Book::HeadlineIndex.parse(src, chap)
assert_equal [2,2], index['sec1-2|sec1-2-2'].number
assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
end
+
+ def test_HeadelineIndex2
+ src = <<-EOB
+= chap1
+== sec1-1
+== sec1-2
+=== sec1-2-1
+===[column] column1
+== sec1-3
+=== sec1-3-1
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+ assert_equal [3,1], index['sec1-3|sec1-3-1'].number
+ assert_equal "1.3.1", index.number('sec1-3|sec1-3-1')
+ end
+
+ def test_HeadelineIndex3
+ src = <<-EOB
+= chap1
+== sec1-1
+== sec1-2
+=== sec1-2-1
+===[column] column1
+=== sec1-2-2
+== sec1-3
+=== sec1-3-1
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
+
+ assert_equal [3,1], index['sec1-3|sec1-3-1'].number
+ assert_equal "1.3.1", index.number('sec1-3|sec1-3-1')
+ end
+
+ def test_HeadelineIndex4
+ src = <<-EOB
+= chap1
+====[column] c1
+== sec1-1
+== sec1-2
+=== sec1-2-1
+=== sec1-2-2
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
+ end
+
+ def test_HeadelineIndex5
+ src = <<-EOB
+= chap1
+====[column] c1
+== sec1-1
+== sec1-2
+=== sec1-2-1
+=== sec1-2-2
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+ assert_equal [2,2], index['sec1-2-2'].number
+ assert_equal "1.2.2", index.number('sec1-2-2')
+ end
+
+ def test_HeadelineIndex6
+ src = <<-EOB
+= chap1
+== sec1
+=== target
+== sec2
+
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+ assert_equal [1,1], index['target'].number
+ assert_equal "1.1.1", index.number('target')
+ end
+
+
+ def test_HeadelineIndex7
+ src = <<-EOB
+= chap1
+== sec1
+=== target
+ ^-- dummy target
+== sec2
+=== target
+ ^-- real target but it cannot be detected, because there is another one.
+
+ EOB
+ book = Book::Base.load
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
+ index = Book::HeadlineIndex.parse(src, chap)
+
+ assert_raise ReVIEW::KeyError do
+ assert_equal [1,1], index['target'].number
+ end
+ end
+
end