android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-ibc-forum.git
Log | Files | Refs

BBCodeTest.java (1645B)


      1 import de.mtbnews.android.adapter.BBCodeConverter;
      2 import junit.framework.TestCase;
      3 
      4 public class BBCodeTest extends TestCase
      5 {
      6 	public void testQuote() throws Exception
      7 	{
      8 
      9 		String in = "[quotE=Schrott]Hallo[/Quote]Hallo [B]Du[/b].";
     10 		String out = "<blockquote>Hallo</blockquote>Hallo <b>Du</b>.";
     11 		testInOut(in, out);
     12 	}
     13 
     14 	public void testQuoteSimple() throws Exception
     15 	{
     16 
     17 		String in = "[quotE]Hallo[/Quote]Hallo [B]Du[/b].";
     18 		String out = "<blockquote>Hallo</blockquote>Hallo <b>Du</b>.";
     19 		testInOut(in, out);
     20 	}
     21 
     22 	public void testQuoteDouble() throws Exception
     23 	{
     24 
     25 		String in = "[quotE=Schrott]Hallo[/Quote]Hallo [B]Du[/b] [B]da[/b].[quotE=Schrott]Hallo[/Quote]Hallo [B]Sie[/b] [B]da[/b].";
     26 		String out = "<blockquote>Hallo</blockquote>Hallo <b>Du</b> <b>da</b>.<blockquote>Hallo</blockquote>Hallo <b>Sie</b> <b>da</b>.";
     27 		testInOut(in, out);
     28 	}
     29 
     30 	public void testLink() throws Exception
     31 	{
     32 
     33 		String in = "[url]http://example.com/image.png[/url].";
     34 		String out = "<a href=\"http://example.com/image.png\">http://example.com/image.png</a>.";
     35 		testInOut(in, out);
     36 
     37 		in = "[url=http://example.com/image.png]haha[/url].";
     38 		out = "<a href=\"http://example.com/image.png\">haha</a>.";
     39 		testInOut(in, out);
     40 	}
     41 
     42 	public void testImage() throws Exception
     43 	{
     44 
     45 		String in = "[img]http://example.com/image.png[/imG].";
     46 		String out = "<a href=\"http://example.com/image.png\">Bild anzeigen</a>.";
     47 		testInOut(in, out);
     48 	}
     49 
     50 	private void testInOut(String in, String out) throws Exception
     51 	{
     52 		BBCodeConverter bbCodeConverter = new BBCodeConverter();
     53 		String processed = bbCodeConverter.process(in);
     54 		assertEquals(out, processed);
     55 	}
     56 }