[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/String.cs runt...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/String.cs runt... |
Date: |
Sun, 17 May 2009 18:05:43 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnetlib
Changes by: Klaus Treichel <ktreichel> 09/05/17 18:05:42
Modified files:
. : ChangeLog
runtime/System : String.cs
runtime/System/Globalization: CompareInfo.cs
System : Uri.cs
tests/runtime/System: TestString.cs
tests/runtime/System/Globalization: TestCompareInfo.cs
Log message:
Fix handling of string compares with a zero length (bug #26226) and do
some
optimizations in System/Uri.cs.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2585&r2=1.2586
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/String.cs?cvsroot=dotgnu-pnet&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/Globalization/CompareInfo.cs?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System/Uri.cs?cvsroot=dotgnu-pnet&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/runtime/System/TestString.cs?cvsroot=dotgnu-pnet&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/runtime/System/Globalization/TestCompareInfo.cs?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2585
retrieving revision 1.2586
diff -u -b -r1.2585 -r1.2586
--- ChangeLog 21 Apr 2009 06:44:24 -0000 1.2585
+++ ChangeLog 17 May 2009 18:05:41 -0000 1.2586
@@ -1,3 +1,23 @@
+2009-Ã5-17 Klaus Treichel <address@hidden>
+
+ * runtime/System.String.cs (Compare): Let CompareInfo.Compare do the
+ index validation. Use the not ECMA code for ECMA too because ECMA
+ should behave similar according to the specs.
+
+ * runtime/System/Globalization/CompareInfo.cs (DefaultCompare): Allow
+ index == string.Length if the given length is 0 not only for
+ string.Length == 0 but for all lengths.
+
+ * System/Uri.cs (CheckSchemeName, EscapeStringInternal, FromHex,
+ IsBadFileSystemCharacter, IsExcludedCharacter): Replace various
+ conditional statements by switch statements.
+
+ * tests/runtime/System/TestString.cs: Add additional tests for the
+ Compare methods with empty strings.
+
+ * tests/runtime/System/Globalization/TestCompareInfo.cs: Add additional
+ tests for the Compare methods with zero lengths.
+
2009-04-21 Heiko Weiss <address@hidden>
* System/Uri.cs: fixed CheckHostName, failed with IP-Addresses.
Index: runtime/System/String.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/String.cs,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- runtime/System/String.cs 19 Apr 2009 10:25:27 -0000 1.48
+++ runtime/System/String.cs 17 May 2009 18:05:42 -0000 1.49
@@ -222,56 +222,48 @@
String strB, int
indexB,
int length)
{
-#if !ECMA_COMPAT
int lengthA = length;
int lengthB = length;
- if(strA == null)
- {
- if(indexA != 0)
+ // We check only for negative length here.
+ // The more precise checks on the indexes will
be done in
+ // CompareInfo.Compare anyways.
+ if(length < 0)
{
throw new
ArgumentOutOfRangeException
- ("indexA",
_("ArgRange_StringIndex"));
+ ("length",
_("ArgRange_StringRange"));
}
+ if(strA == null)
+ {
lengthA = 0;
}
else
{
- if(indexA < 0 || indexA >= strA.length)
+ // Limit lengthA to the actual
remaining characters in
+ // strA.
+ int remaining = strA.length - indexA;
+ if(remaining < lengthA)
{
- throw new
ArgumentOutOfRangeException
- ("indexA",
_("ArgRange_StringIndex"));
- }
- int adj = strA.length - indexA -
lengthA;
- if(adj < 0)
- {
- lengthA += adj;
- }
+ lengthA = remaining;
if(lengthA < 0)
{
lengthA = 0;
}
}
+ }
if(strB == null)
{
- indexB = 0;
- lengthB = 0;
- }
- else
- {
- if(indexB < 0 || indexB >= strB.length)
- {
- indexB = 0;
lengthB = 0;
}
else
{
- int adj = strB.length - indexB
- lengthB;
- if(adj < 0)
+ // Limit lengthB to the actual
remaining characters in
+ // strB.
+ int remaining = strB.length - indexB;
+ if(remaining < lengthB)
{
- lengthB += adj;
- }
+ lengthB = remaining;
if(lengthB < 0)
{
lengthB = 0;
@@ -282,12 +274,6 @@
.Compare(strA, indexA,
lengthA,
strB,
indexB, lengthB,
CompareOptions.None);
-#else
- return CultureInfo.CurrentCulture.CompareInfo
- .Compare(strA, indexA,
length,
- strB,
indexB, length,
-
CompareOptions.None);
-#endif
}
// Compare two sub-strings while optionally ignoring case.
@@ -295,56 +281,48 @@
String strB, int
indexB,
int length, bool
ignoreCase)
{
-#if !ECMA_COMPAT
int lengthA = length;
int lengthB = length;
- if(strA == null)
- {
- if(indexA != 0)
+ // We check only for negative length here.
+ // The more precise checks on the indexes will
be done in
+ // CompareInfo.Compare anyways.
+ if(length < 0)
{
throw new
ArgumentOutOfRangeException
- ("indexA",
_("ArgRange_StringIndex"));
+ ("length",
_("ArgRange_StringRange"));
}
+ if(strA == null)
+ {
lengthA = 0;
}
else
{
- if(indexA < 0 || indexA >= strA.length)
- {
- throw new
ArgumentOutOfRangeException
- ("indexA",
_("ArgRange_StringIndex"));
- }
- int adj = strA.length - indexA -
lengthA;
- if(adj < 0)
+ // Limit lengthA to the actual
remaining characters in
+ // strA.
+ int remaining = strA.length - indexA;
+ if(remaining < lengthA)
{
- lengthA += adj;
- }
+ lengthA = remaining;
if(lengthA < 0)
{
lengthA = 0;
}
}
+ }
if(strB == null)
{
- indexB = 0;
lengthB = 0;
}
else
{
- if(indexB < 0 || indexB >= strB.length)
- {
- indexB = 0;
- lengthB =0;
- }
- else
+ // Limit lengthB to the actual
remaining characters in
+ // strB.
+ int remaining = strB.length - indexB;
+ if(remaining < lengthB)
{
- int adj = strB.length - indexB
- lengthB;
- if(adj < 0)
- {
- lengthB += adj;
- }
+ lengthB = remaining;
if(lengthB < 0)
{
lengthB = 0;
@@ -356,13 +334,6 @@
strB,
indexB, lengthB,
(ignoreCase ? CompareOptions.IgnoreCase
: CompareOptions.None));
-#else
- return CultureInfo.CurrentCulture.CompareInfo
- .Compare(strA, indexA,
length,
- strB,
indexB, length,
-
(ignoreCase ? CompareOptions.IgnoreCase
-
: CompareOptions.None));
-#endif
}
// Compare two sub-strings with a particular culture's comparison rules.
@@ -376,13 +347,65 @@
int length, bool ignoreCase,
CultureInfo culture)
{
+ int lengthA;
+ int lengthB;
+
if(culture == null)
{
throw new
ArgumentNullException("culture");
}
+ // We check only for negative length here.
+ // The more precise checks on the indexes will
be done in
+ // CompareInfo.Compare anyways.
+ if(length < 0)
+ {
+ throw new ArgumentOutOfRangeException
+ ("length",
_("ArgRange_StringRange"));
+ }
+
+ lengthA = length;
+ lengthB = length;
+ if(strA == null)
+ {
+ lengthA = 0;
+ }
+ else
+ {
+ // Limit lengthA to the actual
remaining characters in
+ // strA.
+ int remaining = strA.length - indexA;
+ if(remaining < lengthA)
+ {
+ lengthA = remaining;
+ if(lengthA < 0)
+ {
+ lengthA = 0;
+ }
+ }
+ }
+
+ if(strB == null)
+ {
+ lengthB = 0;
+ }
+ else
+ {
+ // Limit lengthB to the actual
remaining characters in
+ // strB.
+ int remaining = strB.length - indexB;
+ if(remaining < lengthB)
+ {
+ lengthB = remaining;
+ if(lengthB < 0)
+ {
+ lengthB = 0;
+ }
+ }
+ }
+
return culture.CompareInfo
- .Compare(strA, indexA,
length,
- strB,
indexB, length,
+ .Compare(strA, indexA,
lengthA,
+ strB,
indexB, lengthB,
(ignoreCase ? CompareOptions.IgnoreCase
: CompareOptions.None));
}
Index: runtime/System/Globalization/CompareInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/CompareInfo.cs,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- runtime/System/Globalization/CompareInfo.cs 29 Aug 2003 05:41:38 -0000
1.16
+++ runtime/System/Globalization/CompareInfo.cs 17 May 2009 18:05:42 -0000
1.17
@@ -196,14 +196,15 @@
throw new ArgumentOutOfRangeException
("length2",
_("ArgRange_StringRange"));
}
- if(string1 != null && string1.Length != 0)
+ if(string1 == null)
{
- if(offset1 >= string1.Length)
+ // Index and length must be 0
+ if(offset1 != 0)
{
throw new
ArgumentOutOfRangeException
("offset1",
_("ArgRange_StringIndex"));
}
- if(length1 > (string1.Length - offset1))
+ if(length1 != 0)
{
throw new
ArgumentOutOfRangeException
("length1",
_("ArgRange_StringRange"));
@@ -211,43 +212,68 @@
}
else
{
- if(offset1 > 0)
+ if(length1 == 0)
+ {
+ // Offset must not be greater
than length
+ if(offset1 > string1.Length)
{
throw new
ArgumentOutOfRangeException
("offset1",
_("ArgRange_StringIndex"));
}
- if(length1 > 0)
+ }
+ else
+ {
+ if(offset1 >= string1.Length)
+ {
+ throw new
ArgumentOutOfRangeException
+ ("offset1",
_("ArgRange_StringIndex"));
+ }
+ if(length1 > (string1.Length -
offset1))
{
throw new
ArgumentOutOfRangeException
("length1",
_("ArgRange_StringRange"));
}
}
- if(string2 != null && string2.Length != 0)
+ }
+ if(string2 == null)
{
- if(offset2 >= string2.Length)
+ // Index and length must be 0
+ if(offset2 != 0)
{
throw new
ArgumentOutOfRangeException
- ("offset2",
_("ArgRange_StringIndex"));
+ ("offset1",
_("ArgRange_StringIndex"));
}
- if(length2 > (string2.Length - offset2))
+ if(length2 != 0)
{
throw new
ArgumentOutOfRangeException
- ("length2",
_("ArgRange_StringRange"));
+ ("length1",
_("ArgRange_StringRange"));
}
}
else
{
- if(offset2 > 0)
+ if(length2 == 0)
+ {
+ // Offset must not be greater
than length
+ if(offset2 > string2.Length)
{
throw new
ArgumentOutOfRangeException
("offset2",
_("ArgRange_StringIndex"));
}
- if(length2 > 0)
+ }
+ else
+ {
+ if(offset2 >= string2.Length)
+ {
+ throw new
ArgumentOutOfRangeException
+ ("offset2",
_("ArgRange_StringIndex"));
+ }
+ if(length2 > (string2.Length -
offset2))
{
throw new
ArgumentOutOfRangeException
("length2",
_("ArgRange_StringRange"));
}
}
+ }
#if CONFIG_REFLECTION
if(this is _I18NCompareInfo)
{
Index: System/Uri.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Uri.cs,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- System/Uri.cs 21 Apr 2009 06:44:25 -0000 1.51
+++ System/Uri.cs 17 May 2009 18:05:42 -0000 1.52
@@ -386,12 +386,25 @@
for (int i = 1; i < schemeName.Length ; i++)
{
- if((!Char.IsLetterOrDigit(schemeName[i])) &&
- ("+.-".IndexOf(schemeName[i]) == -1))
+ if(!Char.IsLetterOrDigit(schemeName[i]))
+ {
+ switch(schemeName[i])
+ {
+ case '+':
+ case '.':
+ case '-':
+ {
+ // Nothing to do
+ }
+ break;
+
+ default:
{
return false;
}
}
+ }
+ }
return true;
}
@@ -468,30 +481,110 @@
for(int i=0; i < str.Length; i++)
{
char c = str[i];
- if((c <= 0x20 || c>=0x7f) || /* non-ascii */
- (("<>%\"{}|\\^`").IndexOf(c) != -1) ||
- (escapeHex && c=='#') ||
- (escapeBrackets && (c=='[' || c==']')))
+
+ if(c <= 0x20 || c >= 0x7f)
{
+ /* non-ascii */
sb.Append(HexEscape(c));
}
else
{
+ switch(c)
+ {
+ case '<':
+ case '>':
+ case '%':
+ case '"':
+ case '{':
+ case '}':
+ case '|':
+ case '\\':
+ case '^':
+ case '`':
+ {
+ sb.Append(HexEscape(c));
+ }
+ break;
+
+ case '#':
+ {
+ if(escapeHex)
+ {
+ sb.Append(HexEscape(c));
+ }
+ else
+ {
+ sb.Append(c);
+ }
+ }
+ break;
+
+ case '[':
+ case ']':
+ {
+ if(escapeBrackets)
+ {
+ sb.Append(HexEscape(c));
+ }
+ else
+ {
+ sb.Append(c);
+ }
+ }
+ break;
+
+ default:
+ {
sb.Append(c);
}
+ break;
+ }
+ }
}
return sb.ToString();
}
public static int FromHex(char digit)
{
- if (digit >= '0' && digit <= '9')
+ switch(digit)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
return digit - '0';
- else if (digit >= 'A' && digit <= 'F')
- return digit - 55;
- else if (digit >= 'a' && digit <= 'f')
- return digit - 87;
- else
+ }
+ break;
+
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ {
+ return digit - 'A' + 10;
+ }
+ break;
+
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ {
+ return digit - 'a' + 10;
+ }
+ break;
+ }
throw new ArgumentException(S._("Arg_HexDigit"),
"digit");
}
@@ -570,14 +663,50 @@
protected virtual bool IsBadFileSystemCharacter(char character)
{
- return ("\"<>|\r\n".IndexOf(character) != -1);
+ switch(character)
+ {
+ case '"':
+ case '<':
+ case '>':
+ case '|':
+ case '\r':
+ case '\n':
+ {
+ return true;
+ }
+ break;
+ }
+ return false;
}
protected static bool IsExcludedCharacter(char character)
{
- return
- ((character < 0x20 || character > 0x7F) /* non-ascii */
- || ("<>#%\"{}|\\^[]`".IndexOf(character) != -1)); /* excluded
ascii */
+ if(character < 0x20 || character > 0x7F)
+ {
+ /* non-ascii */
+ return true;
+ }
+ switch(character)
+ {
+ case '<':
+ case '>':
+ case '#':
+ case '%':
+ case '"':
+ case '{':
+ case '}':
+ case '|':
+ case '\\':
+ case '^':
+ case '[':
+ case ']':
+ case '`':
+ {
+ /* excluded ascii */
+ return true;
+ }
+ }
+ return false;
}
public static bool IsHexDigit(char character)
Index: tests/runtime/System/TestString.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/TestString.cs,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- tests/runtime/System/TestString.cs 19 Apr 2009 09:44:19 -0000 1.15
+++ tests/runtime/System/TestString.cs 17 May 2009 18:05:42 -0000 1.16
@@ -178,6 +178,21 @@
*/
}
+ public void TestStringCompare1()
+ {
+ AssertEquals("String.Compare(null, 0, null , 0 , 0)",
+ String.Compare(null, 0, null, 0, 0), 0);
+
+ AssertEquals("String.Compare(null, 0, String.Empty , 0 , 0)",
+ String.Compare(null, 0, String.Empty, 0, 0), -1);
+
+ AssertEquals("String.Compare(String.Empty, 0, null , 0 , 0)",
+ String.Compare(String.Empty, 0, null, 0, 0), 1);
+
+ AssertEquals("String.Compare(String.Empty, 0, String.Empty , 0
, 0)",
+ String.Compare(String.Empty, 0, String.Empty, 0, 0), 0);
+ }
+
public void TestStringCompareTo()
{
/*
Index: tests/runtime/System/Globalization/TestCompareInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Globalization/TestCompareInfo.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/runtime/System/Globalization/TestCompareInfo.cs 25 Nov 2004
07:30:12 -0000 1.1
+++ tests/runtime/System/Globalization/TestCompareInfo.cs 17 May 2009
18:05:42 -0000 1.2
@@ -126,6 +126,12 @@
compareInfo.Compare(string1, string2));
}
+ public void TestStringCompare11()
+ {
+ AssertEquals("Comparing two String.Empty", 0,
+
compareInfo.Compare(String.Empty, String.Empty));
+ }
+
public void TestStringCompareIgnoreCase1()
{
String string1 = "ABCDE";
@@ -265,10 +271,6 @@
string2, offset2);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing Null from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -317,10 +319,6 @@
string2, offset2);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
Null from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -346,10 +344,6 @@
string2, offset2);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -375,10 +369,6 @@
string2, offset2);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -454,6 +444,20 @@
offset2.ToString(), 1, result);
}
+ public void TestStringCompareOffset14()
+ {
+ int offset1 = 0;
+ int offset2 = 0;
+ int result;
+
+ result = compareInfo.Compare(String.Empty,
offset1,
+
String.Empty, offset2);
+ AssertEquals("Comparing String.Empty from " +
+
offset1.ToString() +
+ " with
String.Empty from offset " +
+
offset2.ToString(), 0, result);
+ }
+
public void TestStringCompareOffsetIgnoreCase1()
{
String string1 = "abcde";
@@ -565,10 +569,6 @@
CompareOptions.IgnoreCase);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing Null from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -619,10 +619,6 @@
CompareOptions.IgnoreCase);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
Null from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -649,10 +645,6 @@
CompareOptions.IgnoreCase);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -679,10 +671,6 @@
CompareOptions.IgnoreCase);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing " + string1 + "
from " +
-
offset1.ToString() +
- " with
" + string2 + " from offset " +
-
offset2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -694,6 +682,28 @@
}
}
+ public void TestStringCompareOffsetIgnoreCase10()
+ {
+ int offset1 = 0;
+ int offset2 = 0;
+ int result;
+
+ try
+ {
+ result =
compareInfo.Compare(String.Empty, offset1,
+
String.Empty, offset2,
+
CompareOptions.IgnoreCase);
+ AssertEquals("Comparing String.Empty
from " +
+
offset1.ToString() +
+ " with
String.Empty from offset " +
+
offset2.ToString(), 0, result);
+ }
+ catch(Exception e)
+ {
+ Fail("Test should not throw an " +
e.ToString());
+ }
+ }
+
public void TestStringCompareOffsetLength1()
{
String string1 = "aabcde";
@@ -811,12 +821,6 @@
string2, offset2, length2);
Fail("Test should have thrown an
ArgumentOutOfRangeException" +
" but returned " +
result.ToString());
- AssertEquals("Comparing Null from " +
-
offset1.ToString() + " and length " +
-
length1.ToString() +
- "with "
+ string2 + " from offset " +
-
offset2.ToString() + " and length " +
-
length2.ToString(), -1, result);
}
catch(ArgumentOutOfRangeException)
{
@@ -1285,6 +1289,64 @@
length2.ToString(), 1, result);
}
+ public void TestStringCompareOffsetLength24()
+ {
+ int offset1 = 0;
+ int offset2 = 0;
+ int length1 = 0;
+ int length2 = 0;
+ int result;
+
+ result = compareInfo.Compare(String.Empty,
offset1, length1,
+
String.Empty, offset2, length2);
+ AssertEquals("Comparing String.Empty from " +
+
offset1.ToString() + " and length " +
+
length1.ToString() +
+ "with
String.Empty from offset " +
+
offset2.ToString() + " and length " +
+
length2.ToString(), 0, result);
+ }
+
+ public void TestStringCompareOffsetLength25()
+ {
+ String string1 = "ab";
+ String string2 = "abcd";
+ int offset1 = 1;
+ int offset2 = 4;
+ int length1 = 1;
+ int length2 = 0;
+ int result;
+
+ result = compareInfo.Compare(string1, offset1,
length1,
+
string2, offset2, length2);
+ AssertEquals("Comparing " + string1 + " from " +
+
offset1.ToString() + " and length " +
+
length1.ToString() +
+ "with " +
string2 + " from offset " +
+
offset2.ToString() + " and length " +
+
length2.ToString(), 1, result);
+ }
+
+ public void TestStringCompareOffsetLength26()
+ {
+ String string1 = "abcd";
+ String string2 = "ab";
+ int offset1 = 4;
+ int offset2 = 1;
+ int length1 = 0;
+ int length2 = 1;
+ int result;
+
+ result = compareInfo.Compare(string1, offset1,
length1,
+
string2, offset2, length2);
+ AssertEquals("Comparing " + string1 + " from " +
+
offset1.ToString() + " and length " +
+
length1.ToString() +
+ "with " +
string2 + " from offset " +
+
offset2.ToString() + " and length " +
+
length2.ToString(), -1, result);
+ }
+
public void TestStringCompareOffsetLengthIgnoreCase1()
{
String string1 = "aabcde";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/String.cs runt...,
Klaus Treichel <=