assertEquals(doc1.getNumberOfTokens(), 0);
}
@Test
public void testSerialize1() throws IOException {
HMapII hmap1 = new HMapII();
hmap1.put(1, 22);
hmap1.put(2, 5);
hmap1.put(3, 10);
double[] array1 = new double[2];
array1[0] = 0.238573f;
array1[1] = 1.59382f;
Document doc1 = new Document(hmap1, array1);
assertEquals(doc1.getNumberOfTopics(), 2);
assertEquals(doc1.getNumberOfTokens(), 37);
assertEquals(doc1.getNumberOfTypes(), 3);
Document doc2 = Document.create(doc1.serialize());
HMapII hmap2 = doc2.getContent();
double[] array2 = doc2.getGamma();
assertEquals(doc2.getNumberOfTokens(), doc1.getNumberOfTokens());
assertEquals(doc2.getNumberOfTypes(), doc1.getNumberOfTypes());
assertEquals(doc2.getNumberOfTopics(), doc1.getNumberOfTopics());
assertEquals(hmap2.size(), hmap1.size());
assertEquals(array2.length, array1.length);
Iterator<Integer> itr = hmap2.keySet().iterator();
while (itr.hasNext()) {
int key = itr.next();
assertEquals(hmap2.get(key), hmap1.get(key));
}
for (int i = 0; i < array2.length; i++) {
assertEquals(array2[i], array1[i], PRECISION);
}