Skip to content

Commit

Permalink
Add a test for the write to string function in GedWriter
Browse files Browse the repository at this point in the history
Fixes #740

Compares the write to string result from a data set with reading
the existing file from disk.
  • Loading branch information
dickschoeller committed Aug 14, 2018
1 parent ffd1571 commit 88682d8
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.schoellerfamily.gedbrowser.writer.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -80,6 +82,17 @@ public void test() throws IOException {
assertSuccess();
}

/**
* @throws IOException if file IO fails
*/
@Test
public void testString() throws IOException {
final GedWriter writer = new GedWriter(root);
final String writeString = writer.writeString();
final String readString = FileUtils.readFileToString(new File(inputFilename), StandardCharsets.UTF_8);
assertEquals("Input and output should match", readString, writeString);
}

/**
* @throws IOException if there are problems reading or writing files
*/
Expand Down

0 comments on commit 88682d8

Please sign in to comment.