lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1104370 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/core/Lucene.Net.csproj test/core/Lucene.Net.Test.csproj test/core/Support/TestWeakDictionary.cs
Date Tue, 17 May 2011 16:08:12 GMT
Author: digy
Date: Tue May 17 16:08:12 2011
New Revision: 1104370

URL: http://svn.apache.org/viewvc?rev=1104370&view=rev
Log:
[LUCENENET-412] WeakDictionary<K, V> implementation as a wrapper for WeakHashtable.
Not used anywhere yet.

Added:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Support/TestWeakDictionary.cs
Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj?rev=1104370&r1=1104369&r2=1104370&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj Tue May 17
16:08:12 2011
@@ -887,6 +887,7 @@
     </Compile>
     <Compile Include="Support\TextSupport.cs" />
     <Compile Include="Support\ThreadClass.cs" />
+    <Compile Include="Support\WeakDictionary.cs" />
     <Compile Include="Support\WeakHashTable.cs" />
     <Compile Include="Util\ArrayUtil.cs" />
     <Compile Include="Util\Attribute.cs" />

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj?rev=1104370&r1=1104369&r2=1104370&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj Tue May
17 16:08:12 2011
@@ -441,6 +441,7 @@
     <Compile Include="Support\TestOSClass.cs" />
     <Compile Include="Support\TestSerialization.cs" />
     <Compile Include="Support\TestThreadClass.cs" />
+    <Compile Include="Support\TestWeakDictionary.cs" />
     <Compile Include="Support\TestWeakHashTable.cs" />
     <Compile Include="Support\TestWeakHashTableBehavior.cs" />
     <Compile Include="Support\TestWeakHashTableMultiThreadAccess.cs" />

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Support/TestWeakDictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Support/TestWeakDictionary.cs?rev=1104370&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Support/TestWeakDictionary.cs
(added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Support/TestWeakDictionary.cs
Tue May 17 16:08:12 2011
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+
+namespace Lucene.Net.Support
+{
+    [TestFixture]
+    public class TestWeakDictionary
+    {
+        [Test]
+        public void TestBasicOps()
+        {
+            WeakDictionary<string, string> wd = new WeakDictionary<string, string>();
+            List<string> list = new List<string>();
+            for (int i = 0; i < 100; i++)
+            {
+                list.Add(i.ToString());
+            }
+
+            foreach (string s in list)
+            {
+                wd.Add("k" + s, "v" + s);
+            }
+            foreach(string key in list)
+            {
+                Assert.AreEqual(wd["k"+key],"v"+key);
+            }
+            foreach (string key in list)
+            {
+                wd.Remove("k"+key);
+            }
+            Assert.AreEqual(0,wd.Count);
+
+
+            foreach (string s in list)
+            {
+                wd.Add("k" + s, "v" + s);
+            }
+            foreach (string key in wd.Keys)
+            {
+                Assert.True(list.Contains(key.Substring(1)));
+            }
+
+            foreach(KeyValuePair<string,string> kv in wd)
+            {
+                Assert.True(list.Contains(kv.Key.Substring(1)));
+                Assert.AreEqual(kv.Key.Substring(1), kv.Value.Substring(1));
+            }
+        }
+    
+        
+    }
+}



Mime
View raw message