You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/12/29 11:16:39 UTC
[1/2] lucenenet git commit: different approach to recasing test
strings
Repository: lucenenet
Updated Branches:
refs/heads/master 11917175d -> febdd0ff3
different approach to recasing test strings
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/6cfc4fe8
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/6cfc4fe8
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/6cfc4fe8
Branch: refs/heads/master
Commit: 6cfc4fe83ef1a1958e311b34fb86a159782ef2e5
Parents: 1191717
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sun Dec 28 21:24:12 2014 -0500
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sun Dec 28 21:24:12 2014 -0500
----------------------------------------------------------------------
src/Lucene.Net.TestFramework/Util/TestUtil.cs | 36 ++++++++++++++--------
1 file changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6cfc4fe8/src/Lucene.Net.TestFramework/Util/TestUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestUtil.cs b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
index 5dadc39..7250cdb 100644
--- a/src/Lucene.Net.TestFramework/Util/TestUtil.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
@@ -678,15 +678,15 @@ namespace Lucene.Net.Util
switch (NextInt(random, 0, 3))
{
case 0:
- sb.Append(RandomlyRecaseCodePoints(random, "script"));
+ sb.Append(RandomlyRecaseString(random, "script"));
break;
case 1:
- sb.Append(RandomlyRecaseCodePoints(random, "style"));
+ sb.Append(RandomlyRecaseString(random, "style"));
break;
case 2:
- sb.Append(RandomlyRecaseCodePoints(random, "br"));
+ sb.Append(RandomlyRecaseString(random, "br"));
break;
// default: append nothing
}
@@ -704,26 +704,36 @@ namespace Lucene.Net.Util
/// <summary>
/// Randomly upcases, downcases, or leaves intact each code point in the given string
/// </summary>
- public static string RandomlyRecaseCodePoints(Random random, string str)
+ public static string RandomlyRecaseString(Random random, string str)
{
var builder = new StringBuilder();
int pos = 0;
while (pos < str.Length)
{
- int codePoint = Character.CodePointAt(str, pos);
- pos += Character.CharCount(codePoint);
+ string toRecase;
+
+ // check if the next char sequence is a surrogate pair
+ if (pos + 1 < str.Length && char.IsSurrogatePair(str[pos], str[pos+1]))
+ {
+ toRecase = str.Substring(pos, 2);
+ }
+ else
+ {
+ toRecase = str.Substring(pos, 1);
+ }
+
+ pos += toRecase.Length;
+
switch (NextInt(random, 0, 2))
{
case 0:
- builder.Append(char.ToUpper((char)codePoint));
+ builder.Append(toRecase.ToUpper());
break;
-
case 1:
- builder.Append(char.ToLower((char)codePoint));
+ builder.Append(toRecase.ToLower());
break;
-
- case 2: // leave intact
- builder.Append((char)codePoint);
+ case 2:
+ builder.Append(toRecase);
break;
}
}
@@ -1415,7 +1425,7 @@ namespace Lucene.Net.Util
if (random.Next(17) == 0)
{
// mix up case
- string mixedUp = TestUtil.RandomlyRecaseCodePoints(random, sb.ToString());
+ string mixedUp = TestUtil.RandomlyRecaseString(random, sb.ToString());
Assert.True(mixedUp.Length == sb.Length, "Lengths are not the same: mixedUp = " + mixedUp + ", length = " + mixedUp.Length + ", sb = " + sb + ", length = " + sb.Length);
return mixedUp;
}
[2/2] lucenenet git commit: Fixing possible NRE
Posted by sy...@apache.org.
Fixing possible NRE
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/febdd0ff
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/febdd0ff
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/febdd0ff
Branch: refs/heads/master
Commit: febdd0ff3a2ef0d60ed48fe47ea828d7f923a74c
Parents: 6cfc4fe
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Mon Dec 29 12:11:43 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Mon Dec 29 12:11:43 2014 +0200
----------------------------------------------------------------------
.../Util/TestRuleSetupAndRestoreClassEnv.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/febdd0ff/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
index 9ee5c68..8acaee8 100644
--- a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
@@ -251,7 +251,7 @@ namespace Lucene.Net.Util
return; // ignore test points!
}
string name;
- if (Thread.CurrentThread.Name.StartsWith("TEST-"))
+ if (Thread.CurrentThread.Name != null && Thread.CurrentThread.Name.StartsWith("TEST-"))
{
// The name of the main thread is way too
// long when looking at IW verbose output...