Improve conversion tests
authorNiki Roo <niki@nikiroo.be>
Fri, 23 Mar 2018 15:09:10 +0000 (16:09 +0100)
committerNiki Roo <niki@nikiroo.be>
Fri, 23 Mar 2018 15:09:10 +0000 (16:09 +0100)
src/be/nikiroo/fanfix/test/ConversionTest.java
test/expected/cbz.cbz
test/expected/epub.epub
test/expected/html/html.info
test/expected/html/html.txt
test/expected/html/index.html
test/expected/info_text
test/expected/info_text.info
test/expected/latex.tex
test/expected/text.txt
test/test.story

index 92aca369d899eda7858828ce9378271478e654f5..d932782e29756657ab29117fb0427c693267d145 100644 (file)
@@ -6,7 +6,10 @@ import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
@@ -25,6 +28,7 @@ class ConversionTest extends TestLauncher {
        private File expectedDir;
        private File resultDir;
        private List<BasicOutput.OutputType> realTypes;
+       private Map<String, List<String>> skipCompare;
 
        public ConversionTest(String[] args) {
                super("Conversion", args);
@@ -69,6 +73,15 @@ class ConversionTest extends TestLauncher {
                resultDir = new File("test/result/");
 
                tempFiles = new TempFiles("Fanfix-ConversionTest");
+
+               skipCompare = new HashMap<String, List<String>>();
+               skipCompare.put("epb.ncx",
+                               Arrays.asList("         <meta name=\"dtb:uid\" content="));
+               skipCompare.put("epb.opf", Arrays.asList("      <dc:subject>",
+                               "      <dc:identifier id=\"BookId\" opf:scheme=\"URI\">"));
+               skipCompare.put(".info",
+                               Arrays.asList("CREATION_DATE=", "SUBJECT=", "URL=", "UUID="));
+               skipCompare.put("URL", Arrays.asList("file:/"));
        }
 
        @Override
@@ -215,13 +228,14 @@ class ConversionTest extends TestLauncher {
                                        String resultLine = resultLines.get(j);
 
                                        boolean skip = false;
-                                       for (String skipStart : new String[] { "CREATION_DATE=",
-                                                       "SUBJECT=", "URL=", "UUID=" }) {
-                                               if (name.endsWith(".info")
-                                                               && expectedLine.startsWith(skipStart)
-                                                               && resultLine.startsWith(skipStart)) {
-                                                       // TODO: check the format?
-                                                       skip = true;
+                                       for (Entry<String, List<String>> skipThose : skipCompare
+                                                       .entrySet()) {
+                                               for (String skipStart : skipThose.getValue()) {
+                                                       if (name.endsWith(skipThose.getKey())
+                                                                       && expectedLine.startsWith(skipStart)
+                                                                       && resultLine.startsWith(skipStart)) {
+                                                               skip = true;
+                                                       }
                                                }
                                        }
 
index 30c6efc58717aed210708390700501a869b26065..3740e9226cb8b00e597326edc97c7dc516d951a9 100644 (file)
Binary files a/test/expected/cbz.cbz and b/test/expected/cbz.cbz differ
index ea932ba19a632cbc533746fc7f290e75132d4757..1e3dd8cd04d20a61647a49cb92f26046ea73dede 100644 (file)
Binary files a/test/expected/epub.epub and b/test/expected/epub.epub differ
index 6831683253cd3780d952a9b1a76f452e7442c2be..b1d1cdec67c4c6b7abd677919f6483065d4e6a57 100644 (file)
@@ -13,6 +13,6 @@ TYPE="text"
 COVER=""
 EPUBCREATOR="Fanfix (by Niki)"
 PUBLISHER=""
-WORDCOUNT="59"
-CREATION_DATE="2018-03-23 11:27:04"
+WORDCOUNT="57"
+CREATION_DATE="2018-03-23 16:01:39"
 FAKE_COVER="false"
index 4ff9013af0b6b4b2fabaa2cd5c1ca29465744c07..a3a3af31bed24a381b647911935ef687642b541a 100644 (file)
@@ -4,7 +4,7 @@ by UnknownArtist366 (2018)
 Chapter 0: Description
 ——————————————————————
 
-This `story‘ is nothing more than a test file to check
+This ‘story’ is nothing more than a test file to check
 that the program can convert it into different
 formats correctly.
 
@@ -12,8 +12,8 @@ Chapter 1: Quotes
 —————————————————
 
 “Yes, quotes!”, I said.
-`Thos can start with a single- or double quote sign‘, I continued.
-“ They also supports other characters, and an optionnal leading dash. 
+‘Those can start with a single- or double quote sign’, I continued.
+“They also supports other characters, and an optionnal leading dash.
 “The optionnal leading dash is enough to signify “quote”.”
 
 Chapter 2: “Quote” test
index 22b6eb0fbfd0a06ff52d18d5dbcc36279c6b0ef0..aade9c3fadd6e163d648198369f40a5d547416f1 100644 (file)
@@ -17,7 +17,7 @@
                <div class="author">UnknownArtist366</div>
        </div>
        <hr/><br/>              <div class='normals'>
-               <span class='normal'>This `story‘ is nothing more than a test file to check</span>
+               <span class='normal'>This ‘story’ is nothing more than a test file to check</span>
                <span class='normal'>that the program can convert it into different</span>
                <span class='normal'>formats correctly.</span>
                </div>
@@ -31,8 +31,8 @@
        <div class='chapter_content'>
                <div class='dialogues'>
                        <div class='dialogue'>&mdash; “Yes, quotes!”, I said.</div>
-                       <div class='dialogue'>&mdash; `Thos can start with a single- or double quote sign‘, I continued.</div>
-                       <div class='dialogue'>&mdash; “ They also supports other characters, and an optionnal leading dash. ”</div>
+                       <div class='dialogue'>&mdash; ‘Those can start with a single- or double quote sign’, I continued.</div>
+                       <div class='dialogue'>&mdash; “They also supports other characters, and an optionnal leading dash.”</div>
                        <div class='dialogue'>&mdash; “The optionnal leading dash is enough to signify “quote”.”</div>
                </div>
 
index e6c90d288492a7b6d5dd22b162e4084d77c30b78..768b3ccbc7af8fb8f6902ab0e366d01344433255 100644 (file)
@@ -10,8 +10,8 @@ formats correctly.
 Chapter 1: Quotes
 
 "Yes, quotes!", I said.
-'Thos can start with a single- or double quote sign', I continued.
-" They also supports other characters, and an optionnal leading dash. "
+'Those can start with a single- or double quote sign', I continued.
+"They also supports other characters, and an optionnal leading dash."
 "The optionnal leading dash is enough to signify "quote"."
 
 Chapter 2: “Quote” test
index 5e97cced977e594ba8de41be49744107a1be2626..38ae4b5e2e3c3d9a8731c84430cdd6d45171de7f 100644 (file)
@@ -13,6 +13,6 @@ TYPE="info_text"
 COVER=""
 EPUBCREATOR="Fanfix (by Niki)"
 PUBLISHER=""
-WORDCOUNT="59"
-CREATION_DATE="2018-03-23 11:27:04"
+WORDCOUNT="57"
+CREATION_DATE="2018-03-23 16:01:39"
 FAKE_COVER="false"
index 81909dd108086b924faccac95411d888c5e381ee..d4dd68f109e31a7e66c7a8f0ec8370e0a1d73d44 100644 (file)
 
 \say{``Yes, quotes!'', I said.}
 
-\say{`Thos can start with a single- or double quote sign', I continued.}
+\say{`Those can start with a single- or double quote sign', I continued.}
 
 \noindent{}
-\say{`` They also supports other characters, and an optionnal leading dash. ''}
+\say{``They also supports other characters, and an optionnal leading dash.''}
 
 \noindent{}
 \say{``The optionnal leading dash is enough to signify ``quote''.''}
index 4ff9013af0b6b4b2fabaa2cd5c1ca29465744c07..a3a3af31bed24a381b647911935ef687642b541a 100644 (file)
@@ -4,7 +4,7 @@ by UnknownArtist366 (2018)
 Chapter 0: Description
 ——————————————————————
 
-This `story‘ is nothing more than a test file to check
+This ‘story’ is nothing more than a test file to check
 that the program can convert it into different
 formats correctly.
 
@@ -12,8 +12,8 @@ Chapter 1: Quotes
 —————————————————
 
 “Yes, quotes!”, I said.
-`Thos can start with a single- or double quote sign‘, I continued.
-“ They also supports other characters, and an optionnal leading dash. 
+‘Those can start with a single- or double quote sign’, I continued.
+“They also supports other characters, and an optionnal leading dash.
 “The optionnal leading dash is enough to signify “quote”.”
 
 Chapter 2: “Quote” test
index c3136a35566f93b2ab2508f7cc7364176d4da0ca..7365b6077b1320ba6094539fff73e606f8e867ad 100644 (file)
@@ -9,8 +9,8 @@ formats correctly.
 
 Chapter 1: Quotes
 - "Yes, quotes!", I said.
-'Thos can start with a single- or double quote sign', I continued.
-- « They also supports other characters, and an optionnal leading dash. »
+'Those can start with a single- or double quote sign', I continued.
+- «They also supports other characters, and an optionnal leading dash.»
 - The optionnal leading dash is enough to signify "quote".
 
 Chapter 2: "Quote" test