package br.com.caelum.tubaina.parser.latex;

import org.junit.Assert;
import org.junit.Test;

import br.com.caelum.tubaina.parser.SimpleIndentator;


public class CodeTagTest {

	@Test
	public void testPropertiesCodeTag() throws Exception {
		String options = "properties";
		String string = "blablah blah\n" +
				"#algum comentario\n" +
				"texto=valor\n" +
				"texto:valor\n" +
				"texto valor";
		String output = new CodeTag(new SimpleIndentator()).parse(string, options);
		Assert.assertEquals(CodeTag.BEGIN + "{properties}\n" +
				"blablah blah\n" +
				"#algum comentario\n" +
				"texto=valor\n" +
				"texto:valor\n" +
				"texto valor" + CodeTag.END, output);
	}
	@Test
	public void testPropertiesCodeTagWithEscapes() throws Exception {
		String options = "properties abc";
		String string = "blablah blah\n" +
				"#algum comentario\n" +
				"texto\\=valor=valor\n" +
				"texto\\:valor:valor\n" +
				"texto\\ valor valor\n" +
				"a b\\#fake comentario";
		String output = new CodeTag(new SimpleIndentator()).parse(string, options);
		Assert.assertEquals(CodeTag.BEGIN + "{properties}\n" +
				"blablah blah\n" +
				"#algum comentario\n" +
				"texto\\=valor=valor\n" +
				"texto\\:valor:valor\n" +
				"texto\\ valor valor\n" +
				"a b\\#fake comentario" + CodeTag.END, output);
		
	}
	
	@Test
	public void languageCodeTagIsReturnedInsideMintedEnvironment() throws Exception {
		String string = "public static void main(String[] args) {";
		String options = "java";
		String output = new CodeTag(new SimpleIndentator()).parse(string , options );
		Assert.assertEquals(CodeTag.BEGIN + "{java}\n" +
							string + 
							CodeTag.END, output);
	}
	
	@Test
	public void languageCodeTagShouldInsertLineNumbersWhenOptionContainsSharp(){
		String string = "public static void main(String[] args) {";
		String options = "java #";
		String output = new CodeTag(new SimpleIndentator()).parse(string , options );
		Assert.assertEquals(CodeTag.BEGIN + "[linenos, numbersep=5pt]{java}\n" +
							string + 
							CodeTag.END, output);
	}
	
}

@@ -2044,10 +2044,378 @@
 );%0A%09%7D%0A%09%0A
+%09@Test%0A%09public void codeWithoutDefinedLanguageWillBeTextInsideMintedEnvironment() throws Exception %7B%0A%09%09String string = %22public static void main(String%5B%5D args) %7B%22;%0A%09%09String options = %22%22;%0A%09%09String output = new CodeTag(new SimpleIndentator()).parse(string , options );%0A%09%09Assert.assertEquals(CodeTag.BEGIN + %22%7Btext%7D%5Cn%22 +%0A%09%09%09%09%09%09%09string + %0A%09%09%09%09%09%09%09CodeTag.END, output);%0A%09%7D%0A%09%0A
 %7D%0A

testing code without any given language