Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/Mono.C5/Test/trees/Dictionary.cs')
-rw-r--r--mcs/class/Mono.C5/Test/trees/Dictionary.cs99
1 files changed, 27 insertions, 72 deletions
diff --git a/mcs/class/Mono.C5/Test/trees/Dictionary.cs b/mcs/class/Mono.C5/Test/trees/Dictionary.cs
index 5380c332d71..e9ed72995d8 100644
--- a/mcs/class/Mono.C5/Test/trees/Dictionary.cs
+++ b/mcs/class/Mono.C5/Test/trees/Dictionary.cs
@@ -1,5 +1,6 @@
+#if NET_2_0
/*
- Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
+ Copyright (c) 2003-2004 Niels Kokholm <kokholm@itu.dk> and Peter Sestoft <sestoft@dina.kvl.dk>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@@ -22,40 +23,13 @@
using System;
using C5;
using NUnit.Framework;
-using SCG=System.Collections.Generic;
+using MSG=System.Collections.Generic;
-namespace C5UnitTests.trees.RBDictionary
+namespace nunit.trees.RBDictionary
{
- static class Factory
- {
- public static IDictionary<K,V> New<K,V>() { return new TreeDictionary<K,V>(); }
- }
-
-
- [TestFixture]
- public class Formatting
- {
- IDictionary<int,int> coll;
- IFormatProvider rad16;
- [SetUp]
- public void Init() { coll = Factory.New<int,int>(); rad16 = new RadixFormatProvider(16); }
- [TearDown]
- public void Dispose() { coll = null; rad16 = null; }
- [Test]
- public void Format()
- {
- Assert.AreEqual("[ ]", coll.ToString());
- coll.Add(23, 67); coll.Add(45, 89);
- Assert.AreEqual("[ 23 => 67, 45 => 89 ]", coll.ToString());
- Assert.AreEqual("[ 17 => 43, 2D => 59 ]", coll.ToString(null, rad16));
- Assert.AreEqual("[ 23 => 67, ... ]", coll.ToString("L14", null));
- Assert.AreEqual("[ 17 => 43, ... ]", coll.ToString("L14", rad16));
- }
- }
-
- [TestFixture]
- public class RBDict
+ [TestFixture]
+ public class RBDict
{
private TreeDictionary<string,string> dict;
@@ -67,26 +41,11 @@ namespace C5UnitTests.trees.RBDictionary
[TearDown]
public void Dispose() { dict = null; }
- [Test]
- [ExpectedException(typeof(NullReferenceException))]
- public void NullEqualityComparerinConstructor1()
- {
- new TreeDictionary<int,int>(null);
- }
-
- [Test]
- public void Choose()
- {
- dict.Add("YES","NO");
- Assert.AreEqual(new KeyValuePair<string,string>("YES","NO"), dict.Choose());
- }
-
- [Test]
- [ExpectedException(typeof(NoSuchItemException))]
- public void BadChoose()
- {
- dict.Choose();
- }
+ [Test]
+ public void SyncRoot()
+ {
+ Assert.IsFalse(dict.SyncRoot == null);
+ }
[Test]
public void Pred()
@@ -94,14 +53,14 @@ namespace C5UnitTests.trees.RBDictionary
dict.Add("A", "1");
dict.Add("C", "2");
dict.Add("E", "3");
- Assert.AreEqual("1", dict.Predecessor("B").Value);
- Assert.AreEqual("1", dict.Predecessor("C").Value);
- Assert.AreEqual("1", dict.WeakPredecessor("B").Value);
- Assert.AreEqual("2", dict.WeakPredecessor("C").Value);
- Assert.AreEqual("2", dict.Successor("B").Value);
- Assert.AreEqual("3", dict.Successor("C").Value);
- Assert.AreEqual("2", dict.WeakSuccessor("B").Value);
- Assert.AreEqual("2", dict.WeakSuccessor("C").Value);
+ Assert.AreEqual("1", dict.Predecessor("B").value);
+ Assert.AreEqual("1", dict.Predecessor("C").value);
+ Assert.AreEqual("1", dict.WeakPredecessor("B").value);
+ Assert.AreEqual("2", dict.WeakPredecessor("C").value);
+ Assert.AreEqual("2", dict.Successor("B").value);
+ Assert.AreEqual("3", dict.Successor("C").value);
+ Assert.AreEqual("2", dict.WeakSuccessor("B").value);
+ Assert.AreEqual("2", dict.WeakSuccessor("C").value);
}
@@ -141,7 +100,7 @@ namespace C5UnitTests.trees.RBDictionary
[Test]
- [ExpectedException(typeof(DuplicateNotAllowedException), "Key being added: 'A'")]
+ [ExpectedException(typeof(ArgumentException), "Item has already been added. Key in dictionary: 'A' Key being added: 'A'")]
public void IllegalAdd()
{
dict.Add("A", "B");
@@ -150,8 +109,8 @@ namespace C5UnitTests.trees.RBDictionary
[Test]
- [ExpectedException(typeof(NoSuchItemException))]
- public void GettingNonExisting()
+ [ExpectedException(typeof(ArgumentException), "Key not present in Dictionary")]
+ public void GettingNonExisting()
{
Console.WriteLine(dict["R"]);
}
@@ -176,7 +135,7 @@ namespace C5UnitTests.trees.RBDictionary
{
private TreeDictionary<string,string> dict;
- private SCG.IEnumerator<KeyValuePair<string,string>> dictenum;
+ private MSG.IEnumerator<KeyValuePair<string,string>> dictenum;
[SetUp]
@@ -202,7 +161,7 @@ namespace C5UnitTests.trees.RBDictionary
[Test]
public void Keys()
{
- SCG.IEnumerator<string> keys = dict.Keys.GetEnumerator();
+ MSG.IEnumerator<string> keys = dict.Keys.GetEnumerator();
Assert.AreEqual(3, dict.Keys.Count);
Assert.IsTrue(keys.MoveNext());
Assert.AreEqual("R",keys.Current);
@@ -216,7 +175,7 @@ namespace C5UnitTests.trees.RBDictionary
[Test]
public void Values()
{
- SCG.IEnumerator<string> values = dict.Values.GetEnumerator();
+ MSG.IEnumerator<string> values = dict.Values.GetEnumerator();
Assert.AreEqual(3, dict.Values.Count);
Assert.IsTrue(values.MoveNext());
Assert.AreEqual("C",values.Current);
@@ -227,11 +186,6 @@ namespace C5UnitTests.trees.RBDictionary
Assert.IsFalse(values.MoveNext());
}
- [Test]
- public void Fun()
- {
- Assert.AreEqual("B", dict.Fun("T"));
- }
[Test]
@@ -293,7 +247,7 @@ namespace C5UnitTests.trees.RBDictionary
[Test]
- [ExpectedException(typeof(ReadOnlyCollectionException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void UpdateSnap()
{
snap["Y"] = "J";
@@ -309,3 +263,4 @@ namespace C5UnitTests.trees.RBDictionary
}
}
}
+#endif