lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject lucenenet git commit: Trying to fix tests
Date Sat, 06 Aug 2016 22:02:42 GMT
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 <itamar@code972.com>
Authored: Sun Aug 7 01:02:23 2016 +0300
Committer: Itamar Syn-Hershko <itamar@code972.com>
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];
         }
 
         /// <summary>
@@ -533,6 +534,38 @@ namespace Lucene.Net.Analysis.Util
 
         private class LightWrapperSet : ISet<object>
         {
+            private class CustomEnumerator:IEnumerator<object>
+            {
+                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<V> map;
 
             public LightWrapperSet(CharArrayMap<V> map)
@@ -542,7 +575,7 @@ namespace Lucene.Net.Analysis.Util
 
             public IEnumerator<object> 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 <seealso cref="CharArraySet"/> view on the map's keys.
         /// The set will use the same {@code matchVersion} as this map. 
         /// </summary>
-        private CharArraySet KeySet()
+        public CharArraySet KeySet()
         {
             if (keySet == null)
             {
@@ -648,6 +683,9 @@ namespace Lucene.Net.Analysis.Util
             return keySet;
         }
 
+        /// <summary>
+        /// Lucene.NET specific
+        /// </summary>
         private sealed class UnmodifiableCharArraySet : CharArraySet
         {
             internal UnmodifiableCharArraySet(CharArrayMap<object> map) : base(map)
@@ -670,6 +708,10 @@ namespace Lucene.Net.Analysis.Util
             {
                 throw new NotSupportedException();
             }
+            public override void Clear()
+            {
+                throw new NotSupportedException();
+            }
         }
 
         /// <summary>
@@ -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<object, V>[] array, int arrayIndex)
             {
-                throw new NotImplementedException();
+                throw new NotSupportedException();
             }
 
             public bool Remove(KeyValuePair<object, V> 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
         /// <summary>
         /// Clears all entries in this set. This method is supported for reusing, but not
<seealso cref="Set#Remove"/>.
         /// </summary>
-        public void Clear()
+        public virtual void Clear()
         {
             map.Clear();
         }
@@ -148,7 +148,8 @@ namespace Lucene.Net.Analysis.Util
         }
 
         /// <summary>
-        /// Add this String into the set </summary>
+        /// Add this String into the set
+        /// </summary>
         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"
};


Mime
View raw message