File: BrailloTableProviderTest.java

package info (click to toggle)
brailleutils 1.2.3-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,088 kB
  • sloc: java: 13,138; xml: 659; makefile: 29; sh: 1
file content (103 lines) | stat: -rw-r--r-- 4,517 bytes parent folder | download | duplicates (6)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com_braillo;

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;

import com_braillo.BrailloTableProvider;

public class BrailloTableProviderTest {
	private static BrailloTableProvider bt = new BrailloTableProvider(); 
	
	@Test
	public void testFeatureReplacement() {
		//bt = new BrailloTableProvider();
		assertEquals('\u2800', bt.getFeature("replacement"));
	}
	
	@Test
	public void testFeatureFallback() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		assertEquals(EightDotFallbackMethod.MASK, bt.getFeature("fallback"));
	}
	
	@Test (expected=IllegalArgumentException.class)
	public void testGetUnknownFeature() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		bt.getFeature("unknown-feature");
	}
	
	@Test (expected=IllegalArgumentException.class)
	public void testSetUnknownFeature() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		bt.setFeature("unknown-feature", null);
	}
	
	@Test
	public void testListLength() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		assertEquals("Assert that all tables have tests by counting the list length", 4, bt.list().size());
	}
	
	@Test
	public void testTable6Dot_001_00() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		String input = BrailleConstants.BRAILLE_PATTERNS_64;
		BrailloTableProvider.TableType t = BrailloTableProvider.TableType.BRAILLO_6DOT_001_00;
		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());
	}
	
	@Test
	public void testTable6Dot_044_00() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		String input = BrailleConstants.BRAILLE_PATTERNS_64;
		BrailloTableProvider.TableType t = BrailloTableProvider.TableType.BRAILLO_6DOT_044_00;
		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());
	}

	@Test
	public void testTable6Dot_046_01() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		String input = BrailleConstants.BRAILLE_PATTERNS_64;
		BrailloTableProvider.TableType t = BrailloTableProvider.TableType.BRAILLO_6DOT_046_01;
		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", " a,b'k;l^cif/msp!e:h*o+r\"djg[ntq_1?2-u<v%396]x\\&#5.8>z=($4w70y)@", 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());
	}
	
	@Test
	public void testTable6Dot_047_01() {
		//BrailloTableProvider bt = new BrailloTableProvider();
		String input = BrailleConstants.BRAILLE_PATTERNS_64;
		BrailloTableProvider.TableType t = BrailloTableProvider.TableType.BRAILLO_6DOT_047_01;
		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", " A,B.K;L`CIF/MSP'E:H@O!RaDJG[NTQ*]?r-U\"Vqm\\h&Xli_e%u$Z=k|dWg#Ynj", 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());
	}

}