directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r358995 - /directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java
Date Sun, 25 Dec 2005 17:45:07 GMT
Author: elecharny
Date: Sun Dec 25 09:45:04 2005
New Revision: 358995

URL: http://svn.apache.org/viewcvs?rev=358995&view=rev
Log:
Added tests for the new methods added in StringUtils

Modified:
    directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java

Modified: directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java?rev=358995&r1=358994&r2=358995&view=diff
==============================================================================
--- directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java (original)
+++ directory/asn1/trunk/codec/src/test/org/apache/asn1/codec/util/StringUtilsTest.java Sun
Dec 25 09:45:04 2005
@@ -49,14 +49,28 @@
 		Assert.assertEquals(0x2262, res);
 	}
 
-	/*
-	public void testSixBytesChar()
+	public void testcharToBytesOne()
 	{
-		char res = StringUtils.bytesToChar(new byte[]{(byte)0xFD, (byte)0x93, (byte)0x91, (byte)0xBA,
(byte)0x95, (byte)0xA3});
-		
-		Assert.assertEquals(0x7347A563, res);
+		Assert.assertEquals( "0x00 ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x0000
) ) );
+		Assert.assertEquals( "0x61 ", StringUtils.dumpBytes( StringUtils.charToBytes( 'a' ) ) );
+		Assert.assertEquals( "0x7F ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x007F
) ) );
+	}
+	
+	public void testcharToBytesTwo()
+	{
+		Assert.assertEquals( "0xC2 0x80 ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x0080
) ) );
+		Assert.assertEquals( "0xC3 0xBF ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x00FF
) ) );
+		Assert.assertEquals( "0xC4 0x80 ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x0100
) ) );
+		Assert.assertEquals( "0xDF 0xBF ", StringUtils.dumpBytes( StringUtils.charToBytes( (char)0x07FF
) ) );
+	}
+	
+	public void testcharToBytesThree()
+	{
+		Assert.assertEquals( "0xE0 0xA0 0x80 ", StringUtils.dumpBytes( StringUtils.charToBytes(
(char)0x0800 ) ) );
+		Assert.assertEquals( "0xE0 0xBF 0xBF ", StringUtils.dumpBytes( StringUtils.charToBytes(
(char)0x0FFF ) ) );
+		Assert.assertEquals( "0xE1 0x80 0x80 ", StringUtils.dumpBytes( StringUtils.charToBytes(
(char)0x1000 ) ) );
+		Assert.assertEquals( "0xEF 0xBF 0xBF ", StringUtils.dumpBytes( StringUtils.charToBytes(
(char)0xFFFF ) ) );
 	}
-	*/
 	
 	public void testListToString()
 	{



Mime
View raw message