~ubuntu-branches/ubuntu/vivid/mkgmap/vivid

« back to all changes in this revision

Viewing changes to test/uk/me/parabola/mkgmap/srt/SrtTextReaderTest.java

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2014-08-13 22:13:41 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140813221341-i9dzzjuto2o7hfh6
Tags: 0.0.0+svn3333-1
* New upstream version
  Closes: #745097
* add debian/classpath (thanks for the patch to Manfred Stock
  <manfred.stock+debian@gmail.com>)
  Closes: #741596
* d/copyright: DEP5

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import java.io.IOException;
18
18
import java.io.Reader;
19
19
import java.io.StringReader;
 
20
import java.nio.charset.Charset;
20
21
 
21
22
import uk.me.parabola.imgfmt.app.srt.Sort;
22
23
 
31
32
                        "codepage 1252\n" +
32
33
                        "code 01, 02, 03\n";
33
34
 
 
35
        private static final Charset charset = Charset.forName("cp1252");
 
36
 
34
37
        /**
35
38
         * Test for a simple case of two letters that have the same major and minor
36
39
         * sort codes.
99
102
        }
100
103
 
101
104
        /**
102
 
         * Check that 88 is not a letter in 1252.
 
105
         * We can have any unicode character in the file.
 
106
         */
 
107
        @Test
 
108
        public void testUnicodeChars() throws IOException {
 
109
                char[] sortcodes = getSortcodes("< :\n< ›\n");
 
110
                assertEquals(1, major(sortcodes[':']));
 
111
                int b = getByteInCodePage("›");
 
112
                assertEquals(2, major(sortcodes[b & 0xff]));
 
113
        }
 
114
 
 
115
        /**
 
116
         * Check character that is not a letter in 1252.
103
117
         * @throws Exception
104
118
         */
105
119
        @Test
106
120
        public void testNotLetter() throws Exception {
107
 
                Sort sort = getSort("code 88");
108
 
                byte flags = sort.getFlags(0x88);
 
121
                Sort sort = getSort("code 00a8");
 
122
                byte flags = sort.getFlags(0xa8);
109
123
 
110
124
                assertEquals(0, flags);
 
125
 
 
126
                sort = getSort("code 0041");
 
127
                flags = sort.getFlags(0x41);
 
128
                assertNotSame(0, flags);
111
129
        }
112
130
 
113
131
        @Test
123
141
                return sort.getSortPositions();
124
142
        }
125
143
 
 
144
        private byte getByteInCodePage(String ch) {
 
145
                return ch.getBytes(charset)[0];
 
146
        }
 
147
 
126
148
        private Sort getSort(String text) throws IOException {
127
149
                String s = BASE + text + "\n";
128
150