1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
package org_daisy;
import static org.junit.Assert.*;
import java.nio.charset.Charset;
import org.daisy.braille.BrailleConstants;
import org.daisy.braille.table.BrailleConverter;
import org.daisy.braille.table.EmbosserBrailleConverter.EightDotFallbackMethod;
import org.junit.Test;
public class EmbosserTableProviderTest {
@Test
public void testFeatureReplacement() {
EmbosserTableProvider bt = new EmbosserTableProvider();
assertEquals('\u2800', bt.getFeature("replacement"));
}
@Test
public void testFeatureFallback() {
EmbosserTableProvider bt = new EmbosserTableProvider();
assertEquals(EightDotFallbackMethod.MASK, bt.getFeature("fallback"));
}
@Test (expected=IllegalArgumentException.class)
public void testGetUnknownFeature() {
EmbosserTableProvider bt = new EmbosserTableProvider();
bt.getFeature("unknown-feature");
}
@Test (expected=IllegalArgumentException.class)
public void testSetUnknownFeature() {
EmbosserTableProvider bt = new EmbosserTableProvider();
bt.setFeature("unknown-feature", null);
}
/*
@Test
public void testListLength() {
EmbosserTableProvider bt = new EmbosserTableProvider();
assertEquals("Assert that all tables have tests by counting the list length", 7, bt.list().size());
}*/
/*
@Test
public void testTableEN_US() {
EmbosserTableProvider bt = new EmbosserTableProvider();
String input = BrailleConstants.BRAILLE_PATTERNS_64;
EmbosserTableProvider.TableType t = EmbosserTableProvider.TableType.EN_US;
BrailleConverter ta = bt.newTable(t);
String text = ta.toText(input);
String braille = ta.toBraille(text);
assertEquals("Assert that conversion is reversible", input, braille);
assertEquals("Assert that text has been transformed", " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)=", text);
assertTrue("Assert that table does not support 8-dot", !ta.supportsEightDot());
assertEquals("Assert that UTF-8 is the preferred charset", Charset.forName("UTF-8"), ta.getPreferredCharset());
}*/
//TODO: more tests
@Test
public void testTableUnicode() {
EmbosserTableProvider bt = new EmbosserTableProvider();
String input = BrailleConstants.BRAILLE_PATTERNS_256;
EmbosserTableProvider.TableType t = EmbosserTableProvider.TableType.UNICODE_BRAILLE;
BrailleConverter ta = bt.newTable(t);
String text = ta.toText(input);
String braille = ta.toBraille(text);
assertEquals("Assert that conversion is reversible", input, braille);
assertEquals("Assert that text has been transformed", BrailleConstants.BRAILLE_PATTERNS_256, text);
assertTrue("Assert that table supports 8-dot", ta.supportsEightDot());
assertEquals("Assert that UTF-8 is the preferred charset", Charset.forName("UTF-8"), ta.getPreferredCharset());
}
@Test
public void testNABCC() {
EmbosserTableProvider bt = new EmbosserTableProvider();
String input = BrailleConstants.BRAILLE_PATTERNS_64;
BrailleConverter nabcc = bt.newTable(EmbosserTableProvider.TableType.NABCC);
BrailleConverter nabcc8dot = bt.newTable(EmbosserTableProvider.TableType.NABCC_8DOT);
assertEquals("Assert that first 64 characters of NABCC and NABCC_8DOT are equal",
nabcc.toText(input), nabcc8dot.toText(input));
}
}
|