Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B845C200B6E for ; Sun, 7 Aug 2016 00:02:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B6E23160AAA; Sat, 6 Aug 2016 22:02:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D8016160A89 for ; Sun, 7 Aug 2016 00:02:43 +0200 (CEST) Received: (qmail 9884 invoked by uid 500); 6 Aug 2016 22:02:42 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 9875 invoked by uid 99); 6 Aug 2016 22:02:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Aug 2016 22:02:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A34CEE78B2; Sat, 6 Aug 2016 22:02:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: synhershko@apache.org To: commits@lucenenet.apache.org Message-Id: <596d49d5f5214c899b173eaa79034b65@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: lucenenet git commit: Trying to fix tests Date: Sat, 6 Aug 2016 22:02:42 +0000 (UTC) archived-at: Sat, 06 Aug 2016 22:02:44 -0000 Repository: lucenenet Updated Branches: refs/heads/analysis-work 0c794a36c -> 76c4a537d Trying to fix tests Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/76c4a537 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/76c4a537 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/76c4a537 Branch: refs/heads/analysis-work Commit: 76c4a537df45fe52aca8f305927ef368a895308f Parents: 0c794a3 Author: Itamar Syn-Hershko Authored: Sun Aug 7 01:02:23 2016 +0300 Committer: Itamar Syn-Hershko Committed: Sun Aug 7 01:02:23 2016 +0300 ---------------------------------------------------------------------- .../Analysis/Util/CharArrayMap.cs | 61 +++++++++++++++++--- .../Analysis/Util/CharArraySet.cs | 7 ++- .../Analysis/Util/TestCharArrayMap.cs | 2 +- .../Analysis/Util/TestCharArraySet.cs | 10 ++-- 4 files changed, 63 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/76c4a537/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs index 25a8d35..f454fef 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs @@ -116,6 +116,7 @@ namespace Lucene.Net.Analysis.Util { this.keys = keys; this.count = count; + this.values = new V[count]; } /// @@ -533,6 +534,38 @@ namespace Lucene.Net.Analysis.Util private class LightWrapperSet : ISet { + private class CustomEnumerator:IEnumerator + { + private readonly EntryIterator _enumerator; + + public CustomEnumerator(EntryIterator enumerator) + { + _enumerator = enumerator; + } + + public void Dispose() + { + _enumerator.Dispose(); + } + + public bool MoveNext() + { + return _enumerator.MoveNext(); + } + + public void Reset() + { + _enumerator.Reset(); + } + + public object Current { get { return _enumerator.Current.Key; } } + + object IEnumerator.Current + { + get { return _enumerator.Current.Key; } + } + } + private readonly CharArrayMap map; public LightWrapperSet(CharArrayMap map) @@ -542,7 +575,7 @@ namespace Lucene.Net.Analysis.Util public IEnumerator GetEnumerator() { - return map.Keys.GetEnumerator(); + return new CustomEnumerator((EntryIterator)map.entrySet.GetEnumerator()); } IEnumerator IEnumerable.GetEnumerator() @@ -550,6 +583,7 @@ namespace Lucene.Net.Analysis.Util return GetEnumerator(); } + #region NotImplemented parts public void Add(object item) { throw new NotImplementedException(); @@ -609,10 +643,11 @@ namespace Lucene.Net.Analysis.Util { throw new NotImplementedException(); } + #endregion public void Clear() { - map.Clear(); + throw new NotImplementedException(); } public bool Contains(object item) @@ -638,7 +673,7 @@ namespace Lucene.Net.Analysis.Util /// Returns an view on the map's keys. /// The set will use the same {@code matchVersion} as this map. /// - private CharArraySet KeySet() + public CharArraySet KeySet() { if (keySet == null) { @@ -648,6 +683,9 @@ namespace Lucene.Net.Analysis.Util return keySet; } + /// + /// Lucene.NET specific + /// private sealed class UnmodifiableCharArraySet : CharArraySet { internal UnmodifiableCharArraySet(CharArrayMap map) : base(map) @@ -670,6 +708,10 @@ namespace Lucene.Net.Analysis.Util { throw new NotSupportedException(); } + public override void Clear() + { + throw new NotSupportedException(); + } } /// @@ -690,7 +732,7 @@ namespace Lucene.Net.Analysis.Util GoNext(); } - internal void GoNext() + internal bool GoNext() { lastPos = pos; pos++; @@ -698,6 +740,11 @@ namespace Lucene.Net.Analysis.Util { pos++; } + + if (pos == outerInstance.keys.Length) + return false; + + return true; } public bool HasNext() @@ -762,9 +809,7 @@ namespace Lucene.Net.Analysis.Util public bool MoveNext() { - if (!HasNext()) return false; - GoNext(); - return true; + return GoNext(); } public void Reset() @@ -817,7 +862,7 @@ namespace Lucene.Net.Analysis.Util public void CopyTo(KeyValuePair[] array, int arrayIndex) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public bool Remove(KeyValuePair item) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/76c4a537/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs index be85546..ae94288 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs @@ -106,7 +106,7 @@ namespace Lucene.Net.Analysis.Util /// /// Clears all entries in this set. This method is supported for reusing, but not . /// - public void Clear() + public virtual void Clear() { map.Clear(); } @@ -148,7 +148,8 @@ namespace Lucene.Net.Analysis.Util } /// - /// Add this String into the set + /// Add this String into the set + /// public virtual bool Add(string text) { return map.Put(text, PLACEHOLDER) == null; @@ -256,7 +257,7 @@ namespace Lucene.Net.Analysis.Util public override string ToString() { var sb = new StringBuilder("["); - foreach (object item in this) + foreach (var item in this) { if (sb.Length > 1) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/76c4a537/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayMap.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayMap.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayMap.cs index 80f094a..8b75b00 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayMap.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayMap.cs @@ -230,7 +230,7 @@ namespace Lucene.Net.Tests.Analysis.Common.Analysis.Util try { - map.Keys.Clear(); + map.KeySet().Clear(); fail("Modified unmodifiable map"); } catch (System.NotSupportedException) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/76c4a537/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArraySet.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArraySet.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArraySet.cs index 8f9b461..a221b25 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArraySet.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArraySet.cs @@ -51,7 +51,7 @@ namespace Lucene.Net.Tests.Analysis.Common.Analysis.Util [Test] public virtual void TestNonZeroOffset() { - string[] words = new string[] { "Hello", "World", "this", "is", "a", "test" }; + string[] words = { "Hello", "World", "this", "is", "a", "test" }; char[] findme = "xthisy".ToCharArray(); CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10, true); set.AddAll(words); @@ -245,8 +245,8 @@ namespace Lucene.Net.Tests.Analysis.Common.Analysis.Util [Test] public virtual void TestSupplementaryChars() { - string missing = "Term %s is missing in the set"; - string falsePos = "Term %s is in the set but shouldn't"; + string missing = "Term {0} is missing in the set"; + string falsePos = "Term {0} is in the set but shouldn't"; // for reference see // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[[%3ACase_Sensitive%3DTrue%3A]%26[^[\u0000-\uFFFF]]]&esc=on string[] upperArr = new string[] { "Abc\ud801\udc1c", "\ud801\udc1c\ud801\udc1cCDE", "A\ud801\udc1cB" }; @@ -276,8 +276,8 @@ namespace Lucene.Net.Tests.Analysis.Common.Analysis.Util [Test] public virtual void TestSingleHighSurrogate() { - string missing = "Term %s is missing in the set"; - string falsePos = "Term %s is in the set but shouldn't"; + string missing = "Term {0} is missing in the set"; + string falsePos = "Term {0} is in the set but shouldn't"; string[] upperArr = { "ABC\uD800", "ABC\uD800EfG", "\uD800EfG", "\uD800\ud801\udc1cB" }; string[] lowerArr = { "abc\uD800", "abc\uD800efg", "\uD800efg", "\uD800\ud801\udc44b" };