summaryrefslogtreecommitdiffstats
path: root/MobiReader/test/tests
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-06 15:46:52 +0200
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-06 15:46:52 +0200
commit1bdd410a39e7abec4c1691d721af864f2838c796 (patch)
treedb3e95c7ebc195da7d6cbf0d15e39092fef7a807 /MobiReader/test/tests
parentc3df7b0c9778533c6fcbf98e28f215d0f3910ede (diff)
downloadmobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.gz
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.bz2
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.xz
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.zip
Wrum, wrum, wrum. Some silly tests.
Diffstat (limited to 'MobiReader/test/tests')
-rw-r--r--MobiReader/test/tests/HeaderJUnitTest.java64
-rw-r--r--MobiReader/test/tests/UnzippingJUnitTest.java42
2 files changed, 101 insertions, 5 deletions
diff --git a/MobiReader/test/tests/HeaderJUnitTest.java b/MobiReader/test/tests/HeaderJUnitTest.java
new file mode 100644
index 0000000..0ac36a7
--- /dev/null
+++ b/MobiReader/test/tests/HeaderJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tests;
+
+import java.io.File;
+import mobireader.Header;
+import mobireader.Mobi;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author att
+ */
+public class HeaderJUnitTest {
+
+ public HeaderJUnitTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+ // TODO add test methods here.
+ // The methods must be annotated with annotation @Test. For example:
+ //
+ @Test
+ public void testCaluculationOfHeaderSize() {
+ Mobi mobi = new Mobi("test");
+ String header_format = "32shhIIIIII4s4sIIH";
+ int correct_size = 78;
+ int calculated_size = mobi.calcsize(header_format);
+ assertEquals("Calculated size is incorrect", correct_size,
+ calculated_size);
+ }
+
+ @Test
+ public void testCreatingHeaderByPreon() {
+ Mobi mobi = new Mobi("test");
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+ File file = new File(path);
+ Header header = mobi.createHeaderBasedOn(file) ;
+ System.out.println(header.name);
+ assertTrue(header.name.length() != 0);
+
+ }
+} \ No newline at end of file
diff --git a/MobiReader/test/tests/UnzippingJUnitTest.java b/MobiReader/test/tests/UnzippingJUnitTest.java
index f9c18cd..ca817d2 100644
--- a/MobiReader/test/tests/UnzippingJUnitTest.java
+++ b/MobiReader/test/tests/UnzippingJUnitTest.java
@@ -1,12 +1,17 @@
package tests;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Scanner;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
-
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
public class UnzippingJUnitTest {
@@ -30,13 +35,40 @@ public class UnzippingJUnitTest {
}
@Test
- public void testBullshit() {
- assertEquals("10 equals 11", 10, 11);
+ public void testIfCompressionIsShorter() {
+ String text = "aaabbbaaacaccbbaaabbbaaacaccbbaaabbbaaacaccbb";
+ String compressed = unzipping.LZ77.compressStr(text);
+ assertTrue("compressed file is longer than before compression",
+ compressed.length() <= text.length());
+ }
+
+ @Test
+ public void testHowDecompressedMobiLooksLike() throws FileNotFoundException, IOException {
+
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+ byte compressed [] = Files.toByteArray(new File(path));
+ String compressedText = "";
+ for(int i = 0; i < 40000; i++)
+ {
+ compressedText += (char)compressed[i];
+ }
+ }
+
+
+ @Test
+ public void testHowCompressedMobiLooksLike() throws FileNotFoundException, IOException {
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+
+
}
@Test
- public void testTruth() {
- assertEquals("10 does not equal 10", 10, 10);
+ public void testIfDecompressionInvertCompression() {
+ String text = "aaabbbaaacaccbbaaabbbaaacaccbbaaabbbaaacaccbb";
+ String compressed = unzipping.LZ77.compressStr(text);
+ String decompressed = unzipping.LZ77.decompressStr(compressed);
+ assertEquals("Decompression does not invert compression",
+ text, decompressed);
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example: