You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/29 08:56:57 UTC
svn commit: r789235 - in /commons/sandbox/runtime/trunk/src:
main/java/org/apache/commons/runtime/util/Ascii.java
test/org/apache/commons/runtime/TestStrings.java
Author: mturk
Date: Mon Jun 29 06:56:57 2009
New Revision: 789235
URL: http://svn.apache.org/viewvc?rev=789235&view=rev
Log:
Add Ascii to array methods
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStrings.java
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java?rev=789235&r1=789234&r2=789235&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Ascii.java Mon Jun 29 06:56:57 2009
@@ -247,5 +247,17 @@
return ccs_cupper[c & 0xff];
}
+ public static void tolower(byte[] arr, int srcPos, int len)
+ {
+ for (int i = srcPos; i < len; i++)
+ arr[i] = (byte)ccs_clower[(int)arr[i] & 0xff];
+ }
+
+ public static void toupper(byte[] arr, int srcPos, int len)
+ {
+ for (int i = srcPos; i < len; i++)
+ arr[i] = (byte)ccs_cupper[(int)arr[i] & 0xff];
+ }
+
}
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStrings.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStrings.java?rev=789235&r1=789234&r2=789235&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStrings.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStrings.java Mon Jun 29 06:56:57 2009
@@ -135,19 +135,29 @@
public void testAscii()
throws Exception
{
- byte b = (byte)0xF4;
- assertTrue("Lower Ascii", Ascii.islower('a'));
- assertTrue("Upper Ascii", Ascii.isupper('A'));
+ byte b = (byte)0xF4;
+ assertTrue("Lower Ascii", Ascii.islower('a'));
+ assertTrue("Upper Ascii", Ascii.isupper('A'));
assertFalse("Lower Char", Ascii.islower(b));
- }
+ }
public void testAsciiCase()
throws Exception
{
- byte b = (byte)0xF4;
- assertEquals("Lower Ascii", 'a', Ascii.tolower('A'));
- assertEquals("Lower Ascii", 0xF4, Ascii.tolower(b));
- }
+ byte b = (byte)0xF4;
+ assertEquals("Lower Ascii", 'a', Ascii.tolower('A'));
+ assertEquals("Lower Ascii", 0xF4, Ascii.tolower(b));
+ }
+
+ public void testAsciiArrayCase()
+ throws Exception
+ {
+ byte [] b = { (byte)0xF4, 'A', 'B', 'C' };
+ Ascii.tolower(b, 0, b.length);
+ assertEquals("Lower Ascii", 'a', b[1]);
+ Ascii.toupper(b, 0, b.length);
+ assertEquals("Lower Ascii", (byte)0xF4, b[0]);
+ }
}