require 'test/unit' require 'coderay' class TC_Latex_Encoder < Test::Unit::TestCase def setup CodeRay::Encoders.plugin_path 'lib/coderay/encoders' @enc = CodeRay::Encoders[:latex].new end def test_escape_latex tests = {"I have $30, and new\\\nline" => "I have \\$30, and new\\synbs{}\nline", 'I like "clean & simple" things just best than {obscure,complicated}' => 'I like "{}clean \& simple"{} things just best than \{obscure,complicated\}', "The string '\\'' is valid... in C" => "The string '\\synbs{}'' is valid... in C", "Escape dollars as \\$, and continue line, backslash at the end, like so: \\\n" => "Escape dollars as \\synbs{}\\$, and continue line, backslash at the end, like so: \\synbs{}\n", "Perl: $foo{some_key} =~ /^#.*$/" => "Perl: \\$foo\\{some\\_key\\} =\\~{} /\\^{}\\#.*\\$/", "Double backslash escaping: \\\\" => "Double backslash escaping: \\synbs{}\\synbs{}", "\"Some\nmultiline\nstring\"" => "\"{}Some\nmultiline\nstring\"{}", "printf(\"Hello, World\\n\");" => "printf(\"{}Hello, World\\synbs{}n\"{});"} tests.each_pair do |k,v| assert_equal(v, @enc.send(:escape_latex, k)) end end def test_simple source_text = < false)) assert_equal(expected_latex2, symbols.latex) assert_equal(expected_latex2, symbols.latex(:wrap => true)) assert_equal(expected_latex2, symbols.latex(:wrap => :semiverbatim)) end def teardown @enc = nil end end