mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 01:39:18 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@20 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
26b33e8a42
commit
c73c05c7a3
6 changed files with 147 additions and 0 deletions
16
test/zlibrary/model/TestAll.java
Normal file
16
test/zlibrary/model/TestAll.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
public class TestAll {
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite = new TestSuite();
|
||||||
|
suite.addTestSuite(TestTextControlEntry.class);
|
||||||
|
suite.addTestSuite(TestTextControlEntryPool.class);
|
||||||
|
suite.addTestSuite(TestTextEntry.class);
|
||||||
|
suite.addTestSuite(TestTextParagraph.class);
|
||||||
|
suite.addTestSuite(TestZLTextModel.class);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
}
|
15
test/zlibrary/model/TestTextControlEntry.java
Normal file
15
test/zlibrary/model/TestTextControlEntry.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntry;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextControlEntryImpl;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class TestTextControlEntry extends TestCase {
|
||||||
|
public void test() {
|
||||||
|
boolean start = true;
|
||||||
|
byte kind = (byte)0;
|
||||||
|
ZLTextControlEntry entry = new ZLTextControlEntryImpl(kind, start);
|
||||||
|
assertEquals(entry.getKind(), kind);
|
||||||
|
assertEquals(entry.isStart(), start);
|
||||||
|
}
|
||||||
|
}
|
17
test/zlibrary/model/TestTextControlEntryPool.java
Normal file
17
test/zlibrary/model/TestTextControlEntryPool.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntryPool;
|
||||||
|
import org.zlibrary.model.entry.ZLTextControlEntry;
|
||||||
|
import org.zlibrary.model.entry.ZLTextParagraphEntry;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextControlEntryPoolImpl;
|
||||||
|
|
||||||
|
public class TestTextControlEntryPool extends TestCase {
|
||||||
|
public void test() {
|
||||||
|
ZLTextControlEntryPool zpool = new ZLTextControlEntryPoolImpl();
|
||||||
|
byte kind = 0;
|
||||||
|
boolean start = true;
|
||||||
|
ZLTextParagraphEntry entry = zpool.getControlEntry(kind, start);
|
||||||
|
assertEquals(entry, zpool.getControlEntry(kind, start));
|
||||||
|
}
|
||||||
|
}
|
15
test/zlibrary/model/TestTextEntry.java
Normal file
15
test/zlibrary/model/TestTextEntry.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.zlibrary.model.entry.ZLTextEntry;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextEntryImpl;
|
||||||
|
|
||||||
|
public class TestTextEntry extends TestCase {
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
String str = "marina";
|
||||||
|
ZLTextEntry entry = new ZLTextEntryImpl(str);
|
||||||
|
assertEquals(entry.getData(), str);
|
||||||
|
assertEquals(entry.getDataLength(), str.length());
|
||||||
|
}
|
||||||
|
}
|
16
test/zlibrary/model/TestTextParagraph.java
Normal file
16
test/zlibrary/model/TestTextParagraph.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import org.zlibrary.model.ZLTextParagraph;
|
||||||
|
import org.zlibrary.model.impl.ZLTextParagraphImpl;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextEntryImpl;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class TestTextParagraph extends TestCase {
|
||||||
|
public void test() {
|
||||||
|
ZLTextParagraph paragraph = new ZLTextParagraphImpl();
|
||||||
|
paragraph.addEntry(new ZLTextEntryImpl("marina1"));
|
||||||
|
paragraph.addEntry(new ZLTextEntryImpl("marina2"));
|
||||||
|
assertEquals(paragraph.getEntryNumber(), 2);
|
||||||
|
assertEquals(paragraph.getTextLength(),14);
|
||||||
|
}
|
||||||
|
}
|
68
test/zlibrary/model/TestZLTextModel.java
Normal file
68
test/zlibrary/model/TestZLTextModel.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.zlibrary.model.ZLTextModel;
|
||||||
|
import org.zlibrary.model.ZLTextParagraph;
|
||||||
|
import org.zlibrary.model.entry.ZLTextEntry;
|
||||||
|
import org.zlibrary.model.impl.ZLTextModelImpl;
|
||||||
|
import org.zlibrary.model.impl.ZLTextParagraphImpl;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextEntryImpl;
|
||||||
|
import org.zlibrary.model.impl.entry.ZLTextControlEntryImpl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by IntelliJ IDEA.
|
||||||
|
* User: 465
|
||||||
|
* Date: 08.10.2007
|
||||||
|
* Time: 14:15:57
|
||||||
|
* To change this template use File | Settings | File Templates.
|
||||||
|
*/
|
||||||
|
public class TestZLTextModel extends TestCase {
|
||||||
|
|
||||||
|
public void testAddParagraph() {
|
||||||
|
ZLTextModel model = new ZLTextModelImpl();
|
||||||
|
ZLTextParagraph paragraph = new ZLTextParagraphImpl();
|
||||||
|
paragraph.addEntry(new ZLTextEntryImpl("marina"));
|
||||||
|
model.addParagraphInternal(paragraph);
|
||||||
|
model.addParagraphInternal(new ZLTextParagraphImpl());
|
||||||
|
assertEquals(model.getParagraphsNumber(), 2);
|
||||||
|
assertEquals(model.getParagraph(0), paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddEntry() {
|
||||||
|
ZLTextModel model = new ZLTextModelImpl();
|
||||||
|
ZLTextParagraph paragraph = new ZLTextParagraphImpl();
|
||||||
|
paragraph.addEntry(new ZLTextEntryImpl("marina"));
|
||||||
|
model.addParagraphInternal(paragraph);
|
||||||
|
model.addParagraphInternal(new ZLTextParagraphImpl());
|
||||||
|
assertEquals(model.getParagraphsNumber(), 2);
|
||||||
|
assertEquals(model.getParagraph(0), paragraph);
|
||||||
|
model.addText("addText");
|
||||||
|
assertEquals(((ZLTextEntry)model.getParagraph(1).getEntries().get(0)).getData(), "addText");
|
||||||
|
List<String> list = new LinkedList<String>();
|
||||||
|
list.add("1");
|
||||||
|
list.add("2");
|
||||||
|
model.addText(list);
|
||||||
|
assertEquals(((ZLTextEntry)model.getParagraph(1).getEntries().get(1)).getData(), "12");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddControl() {
|
||||||
|
ZLTextModel model = new ZLTextModelImpl();
|
||||||
|
ZLTextParagraph paragraph = new ZLTextParagraphImpl();
|
||||||
|
paragraph.addEntry(new ZLTextEntryImpl("marina"));
|
||||||
|
model.addParagraphInternal(paragraph);
|
||||||
|
model.addParagraphInternal(new ZLTextParagraphImpl());
|
||||||
|
assertEquals(model.getParagraphsNumber(), 2);
|
||||||
|
assertEquals(model.getParagraph(0), paragraph);
|
||||||
|
model.addControl((byte)0, true);
|
||||||
|
model.addControl((byte)0, false);
|
||||||
|
model.addControl((byte)1, true);
|
||||||
|
model.addControl((byte)1, false);
|
||||||
|
model.addControl((byte)0, true);
|
||||||
|
model.addControl((byte)0, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue