test/test_latexbuilder.rb in review-1.7.2 vs test/test_latexbuilder.rb in review-2.0.0.beta1

- old
+ new

@@ -1,22 +1,24 @@ # -*- coding: utf-8 -*- require 'test_helper' -require 'review/compiler' require 'review/book' +require 'review/compiler' require 'review/latexbuilder' require 'review/i18n' class LATEXBuidlerTest < Test::Unit::TestCase include ReVIEW def setup @builder = LATEXBuilder.new() @config = ReVIEW::Configure.values @config.merge!( { - "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder + "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder "toclevel" => 2, - "stylesheet" => nil, # for EPUBBuilder + "inencoding" => "UTF-8", + "outencoding" => "UTF-8", + "stylesheet" => nil, # for EPUBBuilder }) @book = Book::Base.new(nil) @book.config = @config @compiler = ReVIEW::Compiler.new(@builder) @chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new) @@ -275,38 +277,13 @@ @config["tabwidth"] = 4 actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n") assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual end - def test_emlistnum_caption - actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n") - assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n|, actual - end - - def test_list - actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n") - assert_equal %Q|\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n|, actual - end - - def test_list_lst - @book.config["highlight"] = {} - @book.config["highlight"]["latex"] = "listings" - actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n") - assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual - end - - def test_list_lst_with_lang - @book.config["highlight"] = {} - @book.config["highlight"]["latex"] = "listings" - @book.config["highlight"]["lang"] = "sql" - actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n") - assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual - end - def test_listnum actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n") - assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual + assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\reviewlistcaption{ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual end def test_listnum_lst @book.config["highlight"] = {} @book.config["highlight"]["latex"] = "listings" @@ -334,11 +311,11 @@ assert_equal %Q|\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n|, actual end def test_noindent actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n") - assert_equal %Q|\\noindent\nfoo\nbar\n\nfoo2\nbar2\n|, actual + assert_equal %Q|\\noindent\nfoobar\n\nfoo2bar2\n|, actual end def test_image def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) @@ -381,10 +358,21 @@ actual = compile_block("//indepimage[sampleimg][sample photo]\n") assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual end + def test_indepimage_esc + def @chapter.image(id) + item = Book::ImageIndex::Item.new("sampleimg",1) + item.instance_eval{@path="./images/chap1-sampleimg.png"} + item + end + + actual = compile_block("//indepimage[sean_2_10][sample photo][]\n") + assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual + end + def test_indepimage_without_caption def @chapter.image(id) item = Book::ImageIndex::Item.new("sampleimg",1) item.instance_eval{@path="./images/chap1-sampleimg.png"} item @@ -477,20 +465,18 @@ \\hypertarget{column:chap1:1}{} \\reviewcolumnhead{}{prev column} \\addcontentsline{toc}{subsection}{prev column} inside prev column - \\end{reviewcolumn} \\begin{reviewcolumn} \\hypertarget{column:chap1:2}{} \\reviewcolumnhead{}{test} \\addcontentsline{toc}{subsection}{test} inside column - \\end{reviewcolumn} EOS @config["toclevel"] = 3 assert_equal expected, column_helper(review) end @@ -508,13 +494,11 @@ \\begin{reviewcolumn} \\hypertarget{column:chap1:1}{} \\reviewcolumnhead{}{test} inside column - \\end{reviewcolumn} - \\subsection*{next level} \\label{sec:1-0-1} EOS @config["toclevel"] = 1 @@ -596,11 +580,10 @@ \\item AAA \\begin{itemize} \\item AA \\end{itemize} - \\end{itemize} EOS actual = compile_block(src) assert_equal expected, actual end @@ -619,16 +602,14 @@ \\item AAA \\begin{itemize} \\item AA \\end{itemize} - \\item BBB \\begin{itemize} \\item BB \\end{itemize} - \\end{itemize} EOS actual = compile_block(src) assert_equal expected, actual end