require 'test_helper' require 'review/compiler' require 'review/book' require 'review/idgxmlbuilder' require 'review/i18n' class IDGXMLBuidlerTest < Test::Unit::TestCase include ReVIEW def setup @builder = IDGXMLBuilder.new @config = ReVIEW::Configure.values @config['secnolevel'] = 2 @config['tableopt'] = '10' @book = Book::Base.new @book.config = @config @compiler = ReVIEW::Compiler.new(@builder) @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new) location = Location.new(nil, nil) @builder.bind(@compiler, @chapter, location) I18n.setup('ja') end def test_headline_level1 actual = compile_block("={test} this is test.\n") assert_equal %Q(第1章 this is test.), actual end def test_headline_level1_without_secno @config['secnolevel'] = 0 actual = compile_block("={test} this is test.\n") assert_equal %Q(this is test.), actual end def test_headline_level2 actual = compile_block("=={test} this is test.\n") assert_equal %Q(1.1 this is test.), actual end def test_headline_level3 actual = compile_block("==={test} this is test.\n") assert_equal %Q(this is test.), actual end def test_headline_level3_with_secno @config['secnolevel'] = 3 actual = compile_block("==={test} this is test.\n") assert_equal %Q(1.0.1 this is test.), actual end def test_headline_secttags @config['structuredxml'] = true actual = compile_block("= HEAD1\n== HEAD1-1\n\n=== HEAD1-1-1\n\n== HEAD1-2\n\n==== HEAD1-2-0-1\n\n===== HEAD1-2-0-1-1\n\n== HEAD1-3\n") expected = '第1章 HEAD1' + '1.1 HEAD1-1' + 'HEAD1-1-1' + '1.2 HEAD1-2' + 'HEAD1-2-0-1' + 'HEAD1-2-0-1-1' + '1.3 HEAD1-3' assert_equal expected, actual end def test_label actual = compile_block("//label[label_test]\n") assert_equal %Q(