Initial commit

This commit is contained in:
Fredrik Fornwall
2015-10-25 15:27:32 +01:00
commit a18ee58f7a
87 changed files with 13851 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
package com.termux.terminal;
import junit.framework.TestCase;
public class WcWidthTest extends TestCase {
private static void assertWidthIs(int expectedWidth, int codePoint) {
int wcWidth = WcWidth.width(codePoint);
assertEquals(expectedWidth, wcWidth);
}
public void testPrintableAscii() {
for (int i = 0x20; i <= 0x7E; i++) {
assertWidthIs(1, i);
}
}
public void testSomeWide() {
assertWidthIs(2, '');
assertWidthIs(2, '');
assertWidthIs(2, '');
assertWidthIs(2, '中');
assertWidthIs(2, '文');
assertWidthIs(2, 0x679C);
assertWidthIs(2, 0x679D);
assertWidthIs(2, 0x2070E);
assertWidthIs(2, 0x20731);
assertWidthIs(1, 0x1F781);
}
public void testSomeNonWide() {
assertWidthIs(1, 0x1D11E);
assertWidthIs(1, 0x1D11F);
}
public void testCombining() {
assertWidthIs(0, 0x0302);
assertWidthIs(0, 0x0308);
}
public void testWatch() {
assertWidthIs(1, 0x231a);
}
public void testSofthyphen() {
// http://osdir.com/ml/internationalization.linux/2003-05/msg00006.html:
// "Existing implementation practice in terminals is that the SOFT HYPHEN is
// a spacing graphical character, and the purpose of my wcwidth() was to
// predict the advancement of the cursor position after a string is sent to
// a terminal. Hence, I have no choice but to keep wcwidth(SOFT HYPHEN) = 1.
// VT100-style terminals do not hyphenate."
assertWidthIs(1, 0x00AD);
}
public void testHangul() {
assertWidthIs(2, 0x11A3);
}
}