X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=inline;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Ftest%2FBasicSupportTest.java;h=a3f5221df5c62db03b1e1e970074e036dbdec59a;hb=dddfac1d036f22b694a00c029744ac0e92168a8f;hp=ed585d983fb2512f3494f3871c0ee4740f4c5132;hpb=68e370a441d8e6b10bfaa904ecacb29e7d6160d8;p=fanfix.git
diff --git a/src/be/nikiroo/fanfix/test/BasicSupportTest.java b/src/be/nikiroo/fanfix/test/BasicSupportTest.java
index ed585d9..a3f5221 100644
--- a/src/be/nikiroo/fanfix/test/BasicSupportTest.java
+++ b/src/be/nikiroo/fanfix/test/BasicSupportTest.java
@@ -1,5 +1,6 @@
package be.nikiroo.fanfix.test;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -7,14 +8,30 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.bundles.StringId;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Paragraph;
import be.nikiroo.fanfix.data.Paragraph.ParagraphType;
+import be.nikiroo.fanfix.data.Story;
import be.nikiroo.fanfix.supported.BasicSupport;
+import be.nikiroo.fanfix.supported.BasicSupport_Deprecated;
+import be.nikiroo.fanfix.supported.SupportType;
+import be.nikiroo.utils.IOUtils;
+import be.nikiroo.utils.Progress;
import be.nikiroo.utils.test.TestCase;
import be.nikiroo.utils.test.TestLauncher;
-public class BasicSupportTest extends TestLauncher {
+class BasicSupportTest extends TestLauncher {
+ // quote chars
+ private char openQuote = Instance.getTrans().getCharacter(
+ StringId.OPEN_SINGLE_QUOTE);
+ private char closeQuote = Instance.getTrans().getCharacter(
+ StringId.CLOSE_SINGLE_QUOTE);
+ private char openDoubleQuote = Instance.getTrans().getCharacter(
+ StringId.OPEN_DOUBLE_QUOTE);
+ private char closeDoubleQuote = Instance.getTrans().getCharacter(
+ StringId.CLOSE_DOUBLE_QUOTE);
public BasicSupportTest(String[] args) {
super("BasicSupport", args);
@@ -35,7 +52,7 @@ public class BasicSupportTest extends TestLauncher {
}
@Override
- protected List
Line 2
Line 3
"); + "Line 1Line 2
Line 3
", null); assertEquals(5, paras.size()); assertEquals("Line 1", paras.get(0).getContent()); assertEquals(ParagraphType.BLANK, paras.get(1) @@ -62,7 +79,7 @@ public class BasicSupportTest extends TestLauncher { assertEquals("Line 3", paras.get(4).getContent()); paras = support.makeParagraphs(null, - "Line1
Line2
Line3
"); + "Line1
Line2
Line3
", null); assertEquals(6, paras.size()); } }); @@ -80,44 +97,303 @@ public class BasicSupportTest extends TestLauncher { ListLine1
Line2
Line3
Line1
Line2
Line3
Line1
Line2
Line3
Line1
Line2
Line3
* * *
2"); + paras = support.makeParagraphs(null, "1
* * *
2", + null); assertEquals(3, paras.size()); assertEquals(ParagraphType.BREAK, paras.get(1) .getType()); paras = support.makeParagraphs(null, - "1
* * *
2"); + "1
* * *
2", null); assertEquals(3, paras.size()); assertEquals(ParagraphType.BREAK, paras.get(1) .getType()); paras = support.makeParagraphs(null, - "1
* * *
2"); + "1
* * *
2", null); assertEquals(3, paras.size()); assertEquals(ParagraphType.BREAK, paras.get(1) .getType()); paras = support.makeParagraphs(null, - "1
* * *
2"); + "1
* * *
2", null);
assertEquals(3, paras.size());
assertEquals(ParagraphType.BREAK, paras.get(1)
.getType());
}
});
+
+ addTest(new TestCase("BasicSupport.processPara() quotes") {
+ @Override
+ public void test() throws Exception {
+ BasicSupportEmpty support = new BasicSupportEmpty() {
+ @Override
+ protected boolean isHtml() {
+ return true;
+ }
+ };
+
+ Paragraph para;
+
+ // sanity check
+ para = support.processPara("");
+ assertEquals(ParagraphType.BLANK, para.getType());
+ //
+
+ para = support.processPara("\"Yes, my Lord!\"");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openDoubleQuote + "Yes, my Lord!"
+ + closeDoubleQuote, para.getContent());
+
+ para = support.processPara("«Yes, my Lord!»");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openDoubleQuote + "Yes, my Lord!"
+ + closeDoubleQuote, para.getContent());
+
+ para = support.processPara("'Yes, my Lord!'");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openQuote + "Yes, my Lord!" + closeQuote,
+ para.getContent());
+
+ para = support.processPara("â¹Yes, my Lord!âº");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openQuote + "Yes, my Lord!" + closeQuote,
+ para.getContent());
+ }
+ });
+
+ addTest(new TestCase(
+ "BasicSupport.processPara() double-simple quotes") {
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+
+ super.tearDown();
+ }
+
+ @Override
+ public void test() throws Exception {
+ BasicSupportEmpty support = new BasicSupportEmpty() {
+ @Override
+ protected boolean isHtml() {
+ return true;
+ }
+ };
+
+ Paragraph para;
+
+ para = support.processPara("''Yes, my Lord!''");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openDoubleQuote + "Yes, my Lord!"
+ + closeDoubleQuote, para.getContent());
+
+ para = support.processPara("â¹â¹Yes, my Lord!âºâº");
+ assertEquals(ParagraphType.QUOTE, para.getType());
+ assertEquals(openDoubleQuote + "Yes, my Lord!"
+ + closeDoubleQuote, para.getContent());
+ }
+ });
+
+ addTest(new TestCase("BasicSupport.processPara() apostrophe") {
+ @Override
+ public void test() throws Exception {
+ BasicSupportEmpty support = new BasicSupportEmpty() {
+ @Override
+ protected boolean isHtml() {
+ return true;
+ }
+ };
+
+ Paragraph para;
+
+ String text = "Nous étions en été, mais cela aurait être l'hiver quand nous n'étions encore qu'à Aubeuge";
+ para = support.processPara(text);
+ assertEquals(ParagraphType.NORMAL, para.getType());
+ assertEquals(text, para.getContent());
+ }
+ });
+
+ addTest(new TestCase("BasicSupport.processPara() words count") {
+ @Override
+ public void test() throws Exception {
+ BasicSupportEmpty support = new BasicSupportEmpty() {
+ @Override
+ protected boolean isHtml() {
+ return true;
+ }
+ };
+
+ Paragraph para;
+
+ para = support.processPara("«Yes, my Lord!»");
+ assertEquals(3, para.getWords());
+
+ para = support.processPara("One, twee, trois.");
+ assertEquals(3, para.getWords());
+ }
+ });
+
+ addTest(new TestCase("BasicSupport.requotify() words count") {
+ @Override
+ public void test() throws Exception {
+ BasicSupportEmpty support = new BasicSupportEmpty();
+
+ char openDoubleQuote = Instance.getTrans()
+ .getCharacter(StringId.OPEN_DOUBLE_QUOTE);
+ char closeDoubleQuote = Instance.getTrans()
+ .getCharacter(StringId.CLOSE_DOUBLE_QUOTE);
+
+ String content = null;
+ Paragraph para = null;
+ List