author | František Kučera <franta-hg@frantovo.cz> |
Tue, 08 Jun 2010 12:56:46 +0200 | |
changeset 132 | 1ca0d7fdbe51 |
child 133 | 2acdbc74bc24 |
permissions | -rw-r--r-- |
franta-hg@132 | 1 |
package cz.frantovo.nekurak.util; |
franta-hg@132 | 2 |
|
franta-hg@132 | 3 |
import cz.frantovo.nekurak.vyjimky.KomentarovaVyjimka; |
franta-hg@132 | 4 |
import org.junit.Test; |
franta-hg@132 | 5 |
import static org.junit.Assert.*; |
franta-hg@132 | 6 |
|
franta-hg@132 | 7 |
public class KomentareTest { |
franta-hg@132 | 8 |
|
franta-hg@132 | 9 |
@Test |
franta-hg@132 | 10 |
public void obal() { |
franta-hg@132 | 11 |
String vystup = Komentare.obal("asdf"); |
franta-hg@132 | 12 |
String pozadovanyVystup = "<div>asdf</div>"; |
franta-hg@132 | 13 |
assertEquals(pozadovanyVystup, vystup); |
franta-hg@132 | 14 |
} |
franta-hg@132 | 15 |
|
franta-hg@132 | 16 |
@Test |
franta-hg@132 | 17 |
public void upravProstýTextObal() { |
franta-hg@132 | 18 |
String vystup = Komentare.upravProstyText("as\ndf"); |
franta-hg@132 | 19 |
vystup = Komentare.obal(vystup); |
franta-hg@132 | 20 |
String pozadovanyVystup = "<div><p>as<br/>df</p></div>"; |
franta-hg@132 | 21 |
assertEquals(pozadovanyVystup, vystup); |
franta-hg@132 | 22 |
} |
franta-hg@132 | 23 |
|
franta-hg@132 | 24 |
@Test |
franta-hg@132 | 25 |
public void zvláštníZnaky() { |
franta-hg@132 | 26 |
String vystup = Komentare.upravProstyText("nbusr123 & | and < … > uvo\"zovky'"); |
franta-hg@132 | 27 |
String pozadovanyVystup = "<p>nbusr123 & | and < … > uvo"zovky'</p>"; |
franta-hg@132 | 28 |
System.out.println(vystup); |
franta-hg@132 | 29 |
assertEquals(pozadovanyVystup, vystup); |
franta-hg@132 | 30 |
} |
franta-hg@132 | 31 |
|
franta-hg@132 | 32 |
@Test |
franta-hg@132 | 33 |
public void xmlJednoduché() throws Exception { |
franta-hg@132 | 34 |
Komentare.zkontroluj("<div><p>xxx</p></div>"); |
franta-hg@132 | 35 |
Komentare.zkontroluj("<div><p>xxx</p><p>xxx</p></div>"); |
franta-hg@132 | 36 |
Komentare.zkontroluj("<div><p>xxx<strong>tučně</strong>xxx</p></div>"); |
franta-hg@132 | 37 |
Komentare.zkontroluj("<div><p>xxx<em>tučně</em>xxx</p></div>"); |
franta-hg@132 | 38 |
} |
franta-hg@132 | 39 |
|
franta-hg@132 | 40 |
@Test(expected = KomentarovaVyjimka.class) |
franta-hg@132 | 41 |
public void xmlChybaÚplněŠpatnéXML() throws Exception { |
franta-hg@132 | 42 |
Komentare.zkontroluj("<div>xxx</p></div>"); |
franta-hg@132 | 43 |
} |
franta-hg@132 | 44 |
|
franta-hg@132 | 45 |
@Test(expected = KomentarovaVyjimka.class) |
franta-hg@132 | 46 |
public void xmlChybaChybíOdstavec() throws Exception { |
franta-hg@132 | 47 |
Komentare.zkontroluj("<div>xxx</div>"); |
franta-hg@132 | 48 |
} |
franta-hg@132 | 49 |
|
franta-hg@132 | 50 |
@Test(expected = KomentarovaVyjimka.class) |
franta-hg@132 | 51 |
public void xmlChybaPřebýváAtribut() throws Exception { |
franta-hg@132 | 52 |
Komentare.zkontroluj("<div omfg='xxx'><p>xxx</p></div>"); |
franta-hg@132 | 53 |
} |
franta-hg@132 | 54 |
} |