- Maintainability increased by using symbolic names for constants.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2004-06-09 17:50:06 +00:00
parent b36bf84550
commit 8d18b0cd4b

View File

@ -360,6 +360,13 @@ public class TestWrite extends TestCase
private static final int CODEPAGE_DEFAULT = -1;
private static final int CODEPAGE_UTF8 = 65001;
private static final int CODEPAGE_UTF16 = 1200;
private static final int CODEPAGE_1252 = 1252;
/** /**
* <p>Writes and reads back various variant types and checks whether the * <p>Writes and reads back various variant types and checks whether the
* stuff that has been read back equals the stuff that was written.</p> * stuff that has been read back equals the stuff that was written.</p>
@ -367,7 +374,7 @@ public class TestWrite extends TestCase
public void testVariantTypes() public void testVariantTypes()
{ {
Throwable t = null; Throwable t = null;
final int codepage = -1; final int codepage = CODEPAGE_DEFAULT;
try try
{ {
check(Variant.VT_EMPTY, null, codepage); check(Variant.VT_EMPTY, null, codepage);
@ -423,7 +430,8 @@ public class TestWrite extends TestCase
public void testCodepages() public void testCodepages()
{ {
Throwable t = null; Throwable t = null;
final int[] validCodepages = new int[] {-1, 1252, 1200, 65001}; final int[] validCodepages = new int[]
{CODEPAGE_DEFAULT, CODEPAGE_UTF8, CODEPAGE_UTF16, CODEPAGE_1252};
for (int i = 0; i < validCodepages.length; i++) for (int i = 0; i < validCodepages.length; i++)
{ {
int codepage = validCodepages[i]; int codepage = validCodepages[i];
@ -516,6 +524,10 @@ public class TestWrite extends TestCase
fail("Byte arrays are different. First different byte is at " + fail("Byte arrays are different. First different byte is at " +
"index " + diff + "."); "index " + diff + ".");
} }
else
if (value != null && !value.equals(objRead))
fail("Expected: \"" + value + "\" but was: \"" + objRead +
"\". Codepage: " + codepage + ".");
else else
assertEquals(value, objRead); assertEquals(value, objRead);
} }