Skip to content
Browse files

Added solution file and project files for Mono

  • Loading branch information...
1 parent dc56cda commit d02df4e46ceffcbd4a04202eadf5103a0bb69f51 Rasmus Nielsen committed Apr 19, 2012
Showing with 59,055 additions and 29,868 deletions.
  1. BIN .DS_Store
  2. +19 −19 .gitignore
  3. +5 −5 .nuget/NuGet.Config
  4. +51 −51 .nuget/NuGet.targets
  5. +32 −0 C5.Mono.sln
  6. BIN C5.Tests/.DS_Store
  7. +578 −578 C5.Tests/BasesTest.cs
  8. +139 −0 C5.Tests/C5.Tests.Mono.csproj
  9. +133 −133 C5.Tests/C5.Tests.csproj
  10. +17 −17 C5.Tests/Properties/AssemblyInfo.cs
  11. +493 −493 C5.Tests/SupportClasses.cs
  12. +856 −856 C5.Tests/WrappersTest.cs
  13. +3,839 −3,839 C5.Tests/arrays/ArrayListTest.cs
  14. +229 −229 C5.Tests/arrays/CircularQueueTest.cs
  15. +3,423 −3,423 C5.Tests/arrays/HashedArrayListTest.cs
  16. +2,491 −2,491 C5.Tests/arrays/SortedArrayTests.cs
  17. +636 −636 C5.Tests/hashing/HashBagTests.cs
  18. +339 −339 C5.Tests/hashing/HashDictionaryTests.cs
  19. +1,137 −1,137 C5.Tests/hashing/HashTableTests.cs
  20. +664 −664 C5.Tests/heaps/HeapTests.cs
  21. +2,923 −2,923 C5.Tests/linkedlists/HashedLinkedListTest.cs
  22. +3,430 −3,430 C5.Tests/linkedlists/LinkedListTest.cs
  23. +3 −3 C5.Tests/packages.config
  24. +157 −157 C5.Tests/templates/Clone.cs
  25. +892 −892 C5.Tests/templates/Events.cs
  26. +86 −86 C5.Tests/templates/GenericCollectionTester.cs
  27. +28,923 −0 C5.Tests/test-results/C5.Tests.Mono.csproj-Debug-2012-04-19.xml
  28. +3,011 −3,011 C5.Tests/trees/Bag.cs
  29. +509 −509 C5.Tests/trees/Dictionary.cs
  30. +3,029 −3,029 C5.Tests/trees/RedBlackTreeSetTests.cs
  31. BIN C5.UserGuideExamples/.DS_Store
  32. +146 −146 C5.UserGuideExamples/AnagramHashBag.cs
  33. +142 −142 C5.UserGuideExamples/AnagramStrings.cs
  34. +147 −147 C5.UserGuideExamples/AnagramTreeBag.cs
  35. +160 −160 C5.UserGuideExamples/Anagrams.cs
  36. +91 −91 C5.UserGuideExamples/Antipatterns.cs
  37. +232 −232 C5.UserGuideExamples/BipartiteMatching.cs
  38. +93 −0 C5.UserGuideExamples/C5.UserGuideExamples.Mono.csproj
Sorry, we could not display the entire diff because it was too big.
View
BIN .DS_Store
Binary file not shown.
View
38 .gitignore
@@ -1,19 +1,19 @@
-# Untracked files:
-*.docstates
-*.pidb
-*.nupkg
-*.suo
-*.userprefs
-*.user
-*ReSharper*
-packages/*
-Help/*
-C5/bin/*
-C5/obj/*
-C5.Tests/bin/*
-C5.Tests/obj/*
-C5.UserGuideExamples/bin/*
-C5.UserGuideExamples/obj/*
-
-# Include
-!/.nuget/*
+# Untracked files:
+*.docstates
+*.pidb
+*.nupkg
+*.suo
+*.userprefs
+*.user
+*ReSharper*
+packages/*
+Help/*
+C5/bin/*
+C5/obj/*
+C5.Tests/bin/*
+C5.Tests/obj/*
+C5.UserGuideExamples/bin/*
+C5.UserGuideExamples/obj/*
+
+# Include
+!/.nuget/*
View
10 .nuget/NuGet.Config
@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <solution>
- <add key="disableSourceControlIntegration" value="true" />
- </solution>
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <solution>
+ <add key="disableSourceControlIntegration" value="true" />
+ </solution>
</configuration>
View
102 .nuget/NuGet.targets
@@ -1,52 +1,52 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
- <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
- <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
- <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
- <PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
- <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
-
- <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
- <PackageSources>""</PackageSources>
-
- <!-- Enable the restore command to run before builds -->
- <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
-
- <!-- Property that enables building a package from a project -->
- <BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
-
- <!-- Commands -->
- <RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
- <BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
-
- <!-- Make the build depend on restore packages -->
- <BuildDependsOn Condition="$(RestorePackages) == 'true'">
- RestorePackages;
- $(BuildDependsOn);
- </BuildDependsOn>
-
- <!-- Make the build depend on restore packages -->
- <BuildDependsOn Condition="$(BuildPackage) == 'true'">
- $(BuildDependsOn);
- BuildPackage;
- </BuildDependsOn>
- </PropertyGroup>
-
- <Target Name="CheckPrerequisites">
- <!-- Raise an error if we're unable to locate nuget.exe -->
- <Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
- </Target>
-
- <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
- <Exec Command="$(RestoreCommand)"
- LogStandardErrorAsError="true"
- Condition="Exists('$(PackagesConfig)')" />
- </Target>
-
- <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
- <Exec Command="$(BuildCommand)"
- LogStandardErrorAsError="true" />
- </Target>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+ <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+ <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
+ <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
+ <PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
+ <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+
+ <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
+ <PackageSources>""</PackageSources>
+
+ <!-- Enable the restore command to run before builds -->
+ <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
+
+ <!-- Property that enables building a package from a project -->
+ <BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
+
+ <!-- Commands -->
+ <RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
+ <BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+ RestorePackages;
+ $(BuildDependsOn);
+ </BuildDependsOn>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+ $(BuildDependsOn);
+ BuildPackage;
+ </BuildDependsOn>
+ </PropertyGroup>
+
+ <Target Name="CheckPrerequisites">
+ <!-- Raise an error if we're unable to locate nuget.exe -->
+ <Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+ </Target>
+
+ <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(RestoreCommand)"
+ LogStandardErrorAsError="true"
+ Condition="Exists('$(PackagesConfig)')" />
+ </Target>
+
+ <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(BuildCommand)"
+ LogStandardErrorAsError="true" />
+ </Target>
</Project>
View
32 C5.Mono.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C5.Mono", "C5\C5.Mono.csproj", "{1BD0D1BD-512B-4228-B02D-B50ADAF000B3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C5.Tests.Mono", "C5.Tests\C5.Tests.Mono.csproj", "{08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C5.UserGuideExamples.Mono", "C5.UserGuideExamples\C5.UserGuideExamples.Mono.csproj", "{B2A29FF2-A5C5-4F07-8CE7-FF5D744D7562}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}.Debug|x86.Build.0 = Debug|Any CPU
+ {08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}.Release|x86.ActiveCfg = Release|Any CPU
+ {08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}.Release|x86.Build.0 = Release|Any CPU
+ {1BD0D1BD-512B-4228-B02D-B50ADAF000B3}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {1BD0D1BD-512B-4228-B02D-B50ADAF000B3}.Debug|x86.Build.0 = Debug|Any CPU
+ {1BD0D1BD-512B-4228-B02D-B50ADAF000B3}.Release|x86.ActiveCfg = Release|Any CPU
+ {1BD0D1BD-512B-4228-B02D-B50ADAF000B3}.Release|x86.Build.0 = Release|Any CPU
+ {B2A29FF2-A5C5-4F07-8CE7-FF5D744D7562}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B2A29FF2-A5C5-4F07-8CE7-FF5D744D7562}.Debug|x86.Build.0 = Debug|Any CPU
+ {B2A29FF2-A5C5-4F07-8CE7-FF5D744D7562}.Release|x86.ActiveCfg = Release|Any CPU
+ {B2A29FF2-A5C5-4F07-8CE7-FF5D744D7562}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = C5\C5.Mono.csproj
+ EndGlobalSection
+EndGlobal
View
BIN C5.Tests/.DS_Store
Binary file not shown.
View
1,156 C5.Tests/BasesTest.cs
@@ -1,578 +1,578 @@
-/*
- Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
- 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
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-*/
-
-using System;
-using C5;
-using NUnit.Framework;
-using SCG = System.Collections.Generic;
-
-
-namespace C5UnitTests.support
-{
- namespace bases
- {
- [TestFixture]
- public class ArrayBaseTest
- {
- class ABT : ArrayBase<string>
- {
- public ABT() : base(8, C5.EqualityComparer<string>.Default) { }
-
- public override string Choose() { if (size > 0) return array[0]; throw new NoSuchItemException(); }
-
- public string this[int i] { get { return array[i]; } set { array[i] = value; } }
-
-
- public int thesize { get { return size; } set { size = value; } }
- }
-
-
- [Test]
- public void Check()
- {
- ABT abt = new ABT();
-
- abt.thesize = 3;
- abt[2] = "aaa";
- // Assert.IsFalse(abt.Check());
- abt[0] = "##";
- abt[1] = "##";
- Assert.IsTrue(abt.Check());
- }
- }
- }
-
- namespace itemops
- {
- [TestFixture]
- public class Comparers
- {
- class dbl : IComparable<dbl>
- {
- double d;
-
- public dbl(double din) { d = din; }
-
- public int CompareTo(dbl that)
- {
- return d < that.d ? -1 : d == that.d ? 0 : 1;
- }
- public bool Equals(dbl that) { return d == that.d; }
- }
-
- [Test]
- public void GenericC()
- {
- SCG.IComparer<dbl> h = SCG.Comparer<dbl>.Default;
- dbl s = new dbl(3.4);
- dbl t = new dbl(3.4);
- dbl u = new dbl(7.4);
-
- Assert.AreEqual(0, h.Compare(s, t));
- Assert.IsTrue(h.Compare(s, u) < 0);
- }
-
-
- [Test]
- public void OrdinaryC()
- {
- SCG.IComparer<string> h = SCG.Comparer<string>.Default;
- string s = "bamse";
- string t = "bamse";
- string u = "bimse";
-
- Assert.AreEqual(0, h.Compare(s, t));
- Assert.IsTrue(h.Compare(s, u) < 0);
- }
-
-
- [Test]
- public void GenericCViaBuilder()
- {
- SCG.IComparer<dbl> h = SCG.Comparer<dbl>.Default;
- dbl s = new dbl(3.4);
- dbl t = new dbl(3.4);
- dbl u = new dbl(7.4);
-
- Assert.AreEqual(0, h.Compare(s, t));
- Assert.IsTrue(h.Compare(s, u) < 0);
- Assert.AreSame(h, SCG.Comparer<dbl>.Default);
- }
-
-
- [Test]
- public void OrdinaryCViaBuilder()
- {
- SCG.IComparer<string> h = SCG.Comparer<string>.Default;
- string s = "bamse";
- string t = "bamse";
- string u = "bimse";
-
- Assert.AreEqual(0, h.Compare(s, t));
- Assert.IsTrue(h.Compare(s, u) < 0);
- Assert.AreSame(h, SCG.Comparer<string>.Default);
-
- }
-
- public void ComparerViaBuilderTest<T>(T item1, T item2)
- where T : IComparable<T>
- {
- SCG.IComparer<T> h = SCG.Comparer<T>.Default;
- Assert.AreSame(h, SCG.Comparer<T>.Default);
- Assert.AreEqual(0, h.Compare(item1, item1));
- Assert.AreEqual(0, h.Compare(item2, item2));
- Assert.IsTrue(h.Compare(item1, item2) < 0);
- Assert.IsTrue(h.Compare(item2, item1) > 0);
- Assert.AreEqual(Math.Sign(item1.CompareTo(item2)), Math.Sign(h.Compare(item1, item2)));
- Assert.AreEqual(Math.Sign(item2.CompareTo(item1)), Math.Sign(h.Compare(item2, item1)));
- }
-
- [Test]
- public void PrimitiveComparersViaBuilder()
- {
- ComparerViaBuilderTest<char>('A', 'a');
- ComparerViaBuilderTest<sbyte>(-122, 126);
- ComparerViaBuilderTest<byte>(122, 126);
- ComparerViaBuilderTest<short>(-30000, 3);
- ComparerViaBuilderTest<ushort>(3, 50000);
- ComparerViaBuilderTest<int>(-10000000, 10000);
- ComparerViaBuilderTest<uint>(10000000, 3000000000);
- ComparerViaBuilderTest<long>(-1000000000000, 10000000);
- ComparerViaBuilderTest<ulong>(10000000000000UL, 10000000000004UL);
- ComparerViaBuilderTest<float>(-0.001F, 0.00001F);
- ComparerViaBuilderTest<double>(-0.001, 0.00001E-200);
- ComparerViaBuilderTest<decimal>(-20.001M, 19.999M);
- }
-
- // This test is obsoleted by the one above, but we keep it for good measure
- [Test]
- public void IntComparerViaBuilder()
- {
- SCG.IComparer<int> h = SCG.Comparer<int>.Default;
- int s = 4;
- int t = 4;
- int u = 5;
-
- Assert.AreEqual(0, h.Compare(s, t));
- Assert.IsTrue(h.Compare(s, u) < 0);
- Assert.AreSame(h, SCG.Comparer<int>.Default);
- }
-
- [Test]
- public void Nulls()
- {
- Assert.IsTrue(SCG.Comparer<string>.Default.Compare(null, "abe") < 0);
- Assert.IsTrue(SCG.Comparer<string>.Default.Compare(null, null) == 0);
- Assert.IsTrue(SCG.Comparer<string>.Default.Compare("abe", null) > 0);
- }
- }
-
- [TestFixture]
- public class EqualityComparers
- {
- [Test]
- public void ReftypeequalityComparer()
- {
- SCG.IEqualityComparer<string> h = C5.EqualityComparer<string>.Default;
- string s = "bamse";
- string t = "bamse";
- string u = "bimse";
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- }
-
-
- [Test]
- public void ValuetypeequalityComparer()
- {
- SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
- double s = 3.4;
- double t = 3.4;
- double u = 5.7;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- }
-
- [Test]
- public void ReftypeequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<string> h = C5.EqualityComparer<string>.Default;
- string s = "bamse";
- string t = "bamse";
- string u = "bimse";
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<string>.Default);
- }
-
-
- [Test]
- public void ValuetypeequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
- double s = 3.4;
- double t = 3.4;
- double u = 5.7;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<double>.Default);
- }
-
- [Test]
- public void CharequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<char> h = C5.EqualityComparer<char>.Default;
- char s = 'å';
- char t = 'å';
- char u = 'r';
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<char>.Default);
- }
-
- [Test]
- public void SbyteequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<sbyte> h = C5.EqualityComparer<sbyte>.Default;
- sbyte s = 3;
- sbyte t = 3;
- sbyte u = -5;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<sbyte>.Default);
- }
-
- [Test]
- public void ByteequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<byte> h = C5.EqualityComparer<byte>.Default;
- byte s = 3;
- byte t = 3;
- byte u = 5;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<byte>.Default);
- }
-
- [Test]
- public void ShortequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<short> h = C5.EqualityComparer<short>.Default;
- short s = 3;
- short t = 3;
- short u = -5;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<short>.Default);
- }
-
- [Test]
- public void UshortequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<ushort> h = C5.EqualityComparer<ushort>.Default;
- ushort s = 3;
- ushort t = 3;
- ushort u = 60000;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<ushort>.Default);
- }
-
- [Test]
- public void IntequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<int> h = C5.EqualityComparer<int>.Default;
- int s = 3;
- int t = 3;
- int u = -5;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<int>.Default);
- }
-
- [Test]
- public void UintequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<uint> h = C5.EqualityComparer<uint>.Default;
- uint s = 3;
- uint t = 3;
- uint u = 3000000000;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<uint>.Default);
- }
-
- [Test]
- public void LongequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<long> h = C5.EqualityComparer<long>.Default;
- long s = 3;
- long t = 3;
- long u = -500000000000000L;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<long>.Default);
- }
-
- [Test]
- public void UlongequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<ulong> h = C5.EqualityComparer<ulong>.Default;
- ulong s = 3;
- ulong t = 3;
- ulong u = 500000000000000UL;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<ulong>.Default);
- }
-
- [Test]
- public void FloatequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<float> h = C5.EqualityComparer<float>.Default;
- float s = 3.1F;
- float t = 3.1F;
- float u = -5.2F;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<float>.Default);
- }
-
- [Test]
- public void DoubleequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
- double s = 3.12345;
- double t = 3.12345;
- double u = -5.2;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<double>.Default);
- }
-
- [Test]
- public void DecimalequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<decimal> h = C5.EqualityComparer<decimal>.Default;
- decimal s = 3.0001M;
- decimal t = 3.0001M;
- decimal u = -500000000000000M;
-
- Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<decimal>.Default);
- }
-
- [Test]
- public void UnseqequalityComparerViaBuilder()
- {
- SCG.IEqualityComparer<C5.ICollection<int>> h = C5.EqualityComparer<C5.ICollection<int>>.Default;
- C5.ICollection<int> s = new LinkedList<int>();
- C5.ICollection<int> t = new LinkedList<int>();
- C5.ICollection<int> u = new LinkedList<int>();
- s.Add(1); s.Add(2); s.Add(3);
- t.Add(3); t.Add(2); t.Add(1);
- u.Add(3); u.Add(2); u.Add(4);
- Assert.AreEqual(s.GetUnsequencedHashCode(), h.GetHashCode(s));
- Assert.IsTrue(h.Equals(s, t));
- Assert.IsFalse(h.Equals(s, u));
- Assert.AreSame(h, C5.EqualityComparer<C5.ICollection<int>>.Default);
- }
-
- [Test]
- public void SeqequalityComparerViaBuilder2()
- {
- SCG.IEqualityComparer<LinkedList<int>> h = C5.EqualityComparer<LinkedList<int>>.Default;
- LinkedList<int> s = new LinkedList<int>();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- [Test]
- public void UnseqequalityComparerViaBuilder2()
- {
- SCG.IEqualityComparer<C5.HashSet<int>> h = C5.EqualityComparer<C5.HashSet<int>>.Default;
- C5.HashSet<int> s = new C5.HashSet<int>();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- //generic types implementing collection interfaces
- [Test]
- public void SeqequalityComparerViaBuilder3()
- {
- SCG.IEqualityComparer<C5.IList<int>> h = C5.EqualityComparer<C5.IList<int>>.Default;
- C5.IList<int> s = new LinkedList<int>();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- interface IFoo<T> : C5.ICollection<T> { void Bamse(); }
-
- class Foo<T> : C5.HashSet<T>, IFoo<T>
- {
- internal Foo() : base() { }
- public void Bamse() { }
- }
-
- [Test]
- public void UnseqequalityComparerViaBuilder3()
- {
- SCG.IEqualityComparer<IFoo<int>> h = C5.EqualityComparer<IFoo<int>>.Default;
- IFoo<int> s = new Foo<int>();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- //Nongeneric types implementing collection types:
- interface IBaz : ISequenced<int> { void Bamse(); }
-
- class Baz : LinkedList<int>, IBaz
- {
- internal Baz() : base() { }
- public void Bamse() { }
- //int ISequenced<int>.GetHashCode() { return sequencedhashcode(); }
- //bool ISequenced<int>.Equals(ISequenced<int> that) { return sequencedequals(that); }
- }
-
- [Test]
- public void SeqequalityComparerViaBuilder4()
- {
- SCG.IEqualityComparer<IBaz> h = C5.EqualityComparer<IBaz>.Default;
- IBaz s = new Baz();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- interface IBar : C5.ICollection<int>
- {
- void Bamse();
- }
-
- class Bar : C5.HashSet<int>, IBar
- {
- internal Bar() : base() { }
- public void Bamse() { }
-
- //TODO: remove all this workaround stuff:
-
- bool C5.ICollection<int>.ContainsAll(System.Collections.Generic.IEnumerable<int> items)
- {
- throw new NotImplementedException();
- }
-
- void C5.ICollection<int>.RemoveAll(System.Collections.Generic.IEnumerable<int> items)
- {
- throw new NotImplementedException();
- }
-
- void C5.ICollection<int>.RetainAll(System.Collections.Generic.IEnumerable<int> items)
- {
- throw new NotImplementedException();
- }
-
- void IExtensible<int>.AddAll(SCG.IEnumerable<int> enumerable)
- {
- throw new NotImplementedException();
- }
-
- }
-
- [Test]
- public void UnseqequalityComparerViaBuilder4()
- {
- SCG.IEqualityComparer<IBar> h = C5.EqualityComparer<IBar>.Default;
- IBar s = new Bar();
- s.Add(1); s.Add(2); s.Add(3);
- Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
- }
-
- [Test]
- public void StaticEqualityComparerWithNull()
- {
- ArrayList<double> arr = new ArrayList<double>();
- SCG.IEqualityComparer<double> eqc = C5.EqualityComparer<double>.Default;
- Assert.IsTrue(CollectionBase<double>.StaticEquals(arr, arr, eqc));
- Assert.IsTrue(CollectionBase<double>.StaticEquals(null, null, eqc));
- Assert.IsFalse(CollectionBase<double>.StaticEquals(arr, null, eqc));
- Assert.IsFalse(CollectionBase<double>.StaticEquals(null, arr, eqc));
- }
-
- private class EveryThingIsEqual : SCG.IEqualityComparer<Object>
- {
- public new bool Equals(Object o1, Object o2)
- {
- return true;
- }
-
- public int GetHashCode(Object o)
- {
- return 1;
- }
- }
-
- [Test]
- public void UnsequencedCollectionComparerEquality()
- {
- // Repro for bug20101103
- SCG.IEqualityComparer<Object> eqc = new EveryThingIsEqual();
- Object o1 = new Object(), o2 = new Object();
- C5.ICollection<Object> coll1 = new ArrayList<Object>(eqc),
- coll2 = new ArrayList<Object>(eqc);
- coll1.Add(o1);
- coll2.Add(o2);
- Assert.IsFalse(o1.Equals(o2));
- Assert.IsTrue(coll1.UnsequencedEquals(coll2));
- }
- }
- }
-}
+/*
+ Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
+ 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
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+using System;
+using C5;
+using NUnit.Framework;
+using SCG = System.Collections.Generic;
+
+
+namespace C5UnitTests.support
+{
+ namespace bases
+ {
+ [TestFixture]
+ public class ArrayBaseTest
+ {
+ class ABT : ArrayBase<string>
+ {
+ public ABT() : base(8, C5.EqualityComparer<string>.Default) { }
+
+ public override string Choose() { if (size > 0) return array[0]; throw new NoSuchItemException(); }
+
+ public string this[int i] { get { return array[i]; } set { array[i] = value; } }
+
+
+ public int thesize { get { return size; } set { size = value; } }
+ }
+
+
+ [Test]
+ public void Check()
+ {
+ ABT abt = new ABT();
+
+ abt.thesize = 3;
+ abt[2] = "aaa";
+ // Assert.IsFalse(abt.Check());
+ abt[0] = "##";
+ abt[1] = "##";
+ Assert.IsTrue(abt.Check());
+ }
+ }
+ }
+
+ namespace itemops
+ {
+ [TestFixture]
+ public class Comparers
+ {
+ class dbl : IComparable<dbl>
+ {
+ double d;
+
+ public dbl(double din) { d = din; }
+
+ public int CompareTo(dbl that)
+ {
+ return d < that.d ? -1 : d == that.d ? 0 : 1;
+ }
+ public bool Equals(dbl that) { return d == that.d; }
+ }
+
+ [Test]
+ public void GenericC()
+ {
+ SCG.IComparer<dbl> h = SCG.Comparer<dbl>.Default;
+ dbl s = new dbl(3.4);
+ dbl t = new dbl(3.4);
+ dbl u = new dbl(7.4);
+
+ Assert.AreEqual(0, h.Compare(s, t));
+ Assert.IsTrue(h.Compare(s, u) < 0);
+ }
+
+
+ [Test]
+ public void OrdinaryC()
+ {
+ SCG.IComparer<string> h = SCG.Comparer<string>.Default;
+ string s = "bamse";
+ string t = "bamse";
+ string u = "bimse";
+
+ Assert.AreEqual(0, h.Compare(s, t));
+ Assert.IsTrue(h.Compare(s, u) < 0);
+ }
+
+
+ [Test]
+ public void GenericCViaBuilder()
+ {
+ SCG.IComparer<dbl> h = SCG.Comparer<dbl>.Default;
+ dbl s = new dbl(3.4);
+ dbl t = new dbl(3.4);
+ dbl u = new dbl(7.4);
+
+ Assert.AreEqual(0, h.Compare(s, t));
+ Assert.IsTrue(h.Compare(s, u) < 0);
+ Assert.AreSame(h, SCG.Comparer<dbl>.Default);
+ }
+
+
+ [Test]
+ public void OrdinaryCViaBuilder()
+ {
+ SCG.IComparer<string> h = SCG.Comparer<string>.Default;
+ string s = "bamse";
+ string t = "bamse";
+ string u = "bimse";
+
+ Assert.AreEqual(0, h.Compare(s, t));
+ Assert.IsTrue(h.Compare(s, u) < 0);
+ Assert.AreSame(h, SCG.Comparer<string>.Default);
+
+ }
+
+ public void ComparerViaBuilderTest<T>(T item1, T item2)
+ where T : IComparable<T>
+ {
+ SCG.IComparer<T> h = SCG.Comparer<T>.Default;
+ Assert.AreSame(h, SCG.Comparer<T>.Default);
+ Assert.AreEqual(0, h.Compare(item1, item1));
+ Assert.AreEqual(0, h.Compare(item2, item2));
+ Assert.IsTrue(h.Compare(item1, item2) < 0);
+ Assert.IsTrue(h.Compare(item2, item1) > 0);
+ Assert.AreEqual(Math.Sign(item1.CompareTo(item2)), Math.Sign(h.Compare(item1, item2)));
+ Assert.AreEqual(Math.Sign(item2.CompareTo(item1)), Math.Sign(h.Compare(item2, item1)));
+ }
+
+ [Test]
+ public void PrimitiveComparersViaBuilder()
+ {
+ ComparerViaBuilderTest<char>('A', 'a');
+ ComparerViaBuilderTest<sbyte>(-122, 126);
+ ComparerViaBuilderTest<byte>(122, 126);
+ ComparerViaBuilderTest<short>(-30000, 3);
+ ComparerViaBuilderTest<ushort>(3, 50000);
+ ComparerViaBuilderTest<int>(-10000000, 10000);
+ ComparerViaBuilderTest<uint>(10000000, 3000000000);
+ ComparerViaBuilderTest<long>(-1000000000000, 10000000);
+ ComparerViaBuilderTest<ulong>(10000000000000UL, 10000000000004UL);
+ ComparerViaBuilderTest<float>(-0.001F, 0.00001F);
+ ComparerViaBuilderTest<double>(-0.001, 0.00001E-200);
+ ComparerViaBuilderTest<decimal>(-20.001M, 19.999M);
+ }
+
+ // This test is obsoleted by the one above, but we keep it for good measure
+ [Test]
+ public void IntComparerViaBuilder()
+ {
+ SCG.IComparer<int> h = SCG.Comparer<int>.Default;
+ int s = 4;
+ int t = 4;
+ int u = 5;
+
+ Assert.AreEqual(0, h.Compare(s, t));
+ Assert.IsTrue(h.Compare(s, u) < 0);
+ Assert.AreSame(h, SCG.Comparer<int>.Default);
+ }
+
+ [Test]
+ public void Nulls()
+ {
+ Assert.IsTrue(SCG.Comparer<string>.Default.Compare(null, "abe") < 0);
+ Assert.IsTrue(SCG.Comparer<string>.Default.Compare(null, null) == 0);
+ Assert.IsTrue(SCG.Comparer<string>.Default.Compare("abe", null) > 0);
+ }
+ }
+
+ [TestFixture]
+ public class EqualityComparers
+ {
+ [Test]
+ public void ReftypeequalityComparer()
+ {
+ SCG.IEqualityComparer<string> h = C5.EqualityComparer<string>.Default;
+ string s = "bamse";
+ string t = "bamse";
+ string u = "bimse";
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ }
+
+
+ [Test]
+ public void ValuetypeequalityComparer()
+ {
+ SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
+ double s = 3.4;
+ double t = 3.4;
+ double u = 5.7;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ }
+
+ [Test]
+ public void ReftypeequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<string> h = C5.EqualityComparer<string>.Default;
+ string s = "bamse";
+ string t = "bamse";
+ string u = "bimse";
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<string>.Default);
+ }
+
+
+ [Test]
+ public void ValuetypeequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
+ double s = 3.4;
+ double t = 3.4;
+ double u = 5.7;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<double>.Default);
+ }
+
+ [Test]
+ public void CharequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<char> h = C5.EqualityComparer<char>.Default;
+ char s = 'å';
+ char t = 'å';
+ char u = 'r';
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<char>.Default);
+ }
+
+ [Test]
+ public void SbyteequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<sbyte> h = C5.EqualityComparer<sbyte>.Default;
+ sbyte s = 3;
+ sbyte t = 3;
+ sbyte u = -5;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<sbyte>.Default);
+ }
+
+ [Test]
+ public void ByteequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<byte> h = C5.EqualityComparer<byte>.Default;
+ byte s = 3;
+ byte t = 3;
+ byte u = 5;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<byte>.Default);
+ }
+
+ [Test]
+ public void ShortequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<short> h = C5.EqualityComparer<short>.Default;
+ short s = 3;
+ short t = 3;
+ short u = -5;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<short>.Default);
+ }
+
+ [Test]
+ public void UshortequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<ushort> h = C5.EqualityComparer<ushort>.Default;
+ ushort s = 3;
+ ushort t = 3;
+ ushort u = 60000;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<ushort>.Default);
+ }
+
+ [Test]
+ public void IntequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<int> h = C5.EqualityComparer<int>.Default;
+ int s = 3;
+ int t = 3;
+ int u = -5;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<int>.Default);
+ }
+
+ [Test]
+ public void UintequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<uint> h = C5.EqualityComparer<uint>.Default;
+ uint s = 3;
+ uint t = 3;
+ uint u = 3000000000;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<uint>.Default);
+ }
+
+ [Test]
+ public void LongequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<long> h = C5.EqualityComparer<long>.Default;
+ long s = 3;
+ long t = 3;
+ long u = -500000000000000L;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<long>.Default);
+ }
+
+ [Test]
+ public void UlongequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<ulong> h = C5.EqualityComparer<ulong>.Default;
+ ulong s = 3;
+ ulong t = 3;
+ ulong u = 500000000000000UL;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<ulong>.Default);
+ }
+
+ [Test]
+ public void FloatequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<float> h = C5.EqualityComparer<float>.Default;
+ float s = 3.1F;
+ float t = 3.1F;
+ float u = -5.2F;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<float>.Default);
+ }
+
+ [Test]
+ public void DoubleequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<double> h = C5.EqualityComparer<double>.Default;
+ double s = 3.12345;
+ double t = 3.12345;
+ double u = -5.2;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<double>.Default);
+ }
+
+ [Test]
+ public void DecimalequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<decimal> h = C5.EqualityComparer<decimal>.Default;
+ decimal s = 3.0001M;
+ decimal t = 3.0001M;
+ decimal u = -500000000000000M;
+
+ Assert.AreEqual(s.GetHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<decimal>.Default);
+ }
+
+ [Test]
+ public void UnseqequalityComparerViaBuilder()
+ {
+ SCG.IEqualityComparer<C5.ICollection<int>> h = C5.EqualityComparer<C5.ICollection<int>>.Default;
+ C5.ICollection<int> s = new LinkedList<int>();
+ C5.ICollection<int> t = new LinkedList<int>();
+ C5.ICollection<int> u = new LinkedList<int>();
+ s.Add(1); s.Add(2); s.Add(3);
+ t.Add(3); t.Add(2); t.Add(1);
+ u.Add(3); u.Add(2); u.Add(4);
+ Assert.AreEqual(s.GetUnsequencedHashCode(), h.GetHashCode(s));
+ Assert.IsTrue(h.Equals(s, t));
+ Assert.IsFalse(h.Equals(s, u));
+ Assert.AreSame(h, C5.EqualityComparer<C5.ICollection<int>>.Default);
+ }
+
+ [Test]
+ public void SeqequalityComparerViaBuilder2()
+ {
+ SCG.IEqualityComparer<LinkedList<int>> h = C5.EqualityComparer<LinkedList<int>>.Default;
+ LinkedList<int> s = new LinkedList<int>();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ [Test]
+ public void UnseqequalityComparerViaBuilder2()
+ {
+ SCG.IEqualityComparer<C5.HashSet<int>> h = C5.EqualityComparer<C5.HashSet<int>>.Default;
+ C5.HashSet<int> s = new C5.HashSet<int>();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ //generic types implementing collection interfaces
+ [Test]
+ public void SeqequalityComparerViaBuilder3()
+ {
+ SCG.IEqualityComparer<C5.IList<int>> h = C5.EqualityComparer<C5.IList<int>>.Default;
+ C5.IList<int> s = new LinkedList<int>();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ interface IFoo<T> : C5.ICollection<T> { void Bamse(); }
+
+ class Foo<T> : C5.HashSet<T>, IFoo<T>
+ {
+ internal Foo() : base() { }
+ public void Bamse() { }
+ }
+
+ [Test]
+ public void UnseqequalityComparerViaBuilder3()
+ {
+ SCG.IEqualityComparer<IFoo<int>> h = C5.EqualityComparer<IFoo<int>>.Default;
+ IFoo<int> s = new Foo<int>();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ //Nongeneric types implementing collection types:
+ interface IBaz : ISequenced<int> { void Bamse(); }
+
+ class Baz : LinkedList<int>, IBaz
+ {
+ internal Baz() : base() { }
+ public void Bamse() { }
+ //int ISequenced<int>.GetHashCode() { return sequencedhashcode(); }
+ //bool ISequenced<int>.Equals(ISequenced<int> that) { return sequencedequals(that); }
+ }
+
+ [Test]
+ public void SeqequalityComparerViaBuilder4()
+ {
+ SCG.IEqualityComparer<IBaz> h = C5.EqualityComparer<IBaz>.Default;
+ IBaz s = new Baz();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.sequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ interface IBar : C5.ICollection<int>
+ {
+ void Bamse();
+ }
+
+ class Bar : C5.HashSet<int>, IBar
+ {
+ internal Bar() : base() { }
+ public void Bamse() { }
+
+ //TODO: remove all this workaround stuff:
+
+ bool C5.ICollection<int>.ContainsAll(System.Collections.Generic.IEnumerable<int> items)
+ {
+ throw new NotImplementedException();
+ }
+
+ void C5.ICollection<int>.RemoveAll(System.Collections.Generic.IEnumerable<int> items)
+ {
+ throw new NotImplementedException();
+ }
+
+ void C5.ICollection<int>.RetainAll(System.Collections.Generic.IEnumerable<int> items)
+ {
+ throw new NotImplementedException();
+ }
+
+ void IExtensible<int>.AddAll(SCG.IEnumerable<int> enumerable)
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ [Test]
+ public void UnseqequalityComparerViaBuilder4()
+ {
+ SCG.IEqualityComparer<IBar> h = C5.EqualityComparer<IBar>.Default;
+ IBar s = new Bar();
+ s.Add(1); s.Add(2); s.Add(3);
+ Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
+ }
+
+ [Test]
+ public void StaticEqualityComparerWithNull()
+ {
+ ArrayList<double> arr = new ArrayList<double>();
+ SCG.IEqualityComparer<double> eqc = C5.EqualityComparer<double>.Default;
+ Assert.IsTrue(CollectionBase<double>.StaticEquals(arr, arr, eqc));
+ Assert.IsTrue(CollectionBase<double>.StaticEquals(null, null, eqc));
+ Assert.IsFalse(CollectionBase<double>.StaticEquals(arr, null, eqc));
+ Assert.IsFalse(CollectionBase<double>.StaticEquals(null, arr, eqc));
+ }
+
+ private class EveryThingIsEqual : SCG.IEqualityComparer<Object>
+ {
+ public new bool Equals(Object o1, Object o2)
+ {
+ return true;
+ }
+
+ public int GetHashCode(Object o)
+ {
+ return 1;
+ }
+ }
+
+ [Test]
+ public void UnsequencedCollectionComparerEquality()
+ {
+ // Repro for bug20101103
+ SCG.IEqualityComparer<Object> eqc = new EveryThingIsEqual();
+ Object o1 = new Object(), o2 = new Object();
+ C5.ICollection<Object> coll1 = new ArrayList<Object>(eqc),
+ coll2 = new ArrayList<Object>(eqc);
+ coll1.Add(o1);
+ coll2.Add(o2);
+ Assert.IsFalse(o1.Equals(o2));
+ Assert.IsTrue(coll1.UnsequencedEquals(coll2));
+ }
+ }
+ }
+}
View
139 C5.Tests/C5.Tests.Mono.csproj
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>C5.Tests</RootNamespace>
+ <NoStandardLibraries>false</NoStandardLibraries>
+ <AssemblyName>C5.Tests.Mono</AssemblyName>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\C5\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <DebugSymbols>true</DebugSymbols>
+ <Optimize>false</Optimize>
+ <OutputPath>.\bin\Debug\</OutputPath>
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <IncrementalBuild>false</IncrementalBuild>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <DebugSymbols>false</DebugSymbols>
+ <Optimize>true</Optimize>
+ <OutputPath>.\bin\Release\</OutputPath>
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <IncrementalBuild>false</IncrementalBuild>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="arrays\CircularQueueTest.cs" />
+ <Compile Include="BasesTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="InterfacesTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Records.cs" />
+ <Compile Include="Sorting.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SupportClasses.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\ArrayListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\HashedArrayListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\SortedArrayTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashBagTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashDictionaryTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashTableTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="heaps\HeapTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="linkedlists\HashedLinkedListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="linkedlists\LinkedListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="templates\Clone.cs" />
+ <Compile Include="templates\Events.cs" />
+ <Compile Include="templates\GenericCollectionTester.cs" />
+ <Compile Include="templates\List.cs" />
+ <Compile Include="trees\Bag.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="trees\Dictionary.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="trees\RedBlackTreeSetTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="WrappersTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="nunit.mocks">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <OutputPath>bin\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <OutputPath>bin\Release\</OutputPath>
+ </PropertyGroup>
+ <ProjectExtensions>
+ <VisualStudio>
+ </VisualStudio>
+ </ProjectExtensions>
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\C5\C5.Mono.csproj">
+ <Project>{1BD0D1BD-512B-4228-B02D-B50ADAF000B3}</Project>
+ <Name>C5.Mono</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project>
View
266 C5.Tests/C5.Tests.csproj
@@ -1,134 +1,134 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}</ProjectGuid>
- <OutputType>Library</OutputType>
- <StartupObject>
- </StartupObject>
- <RootNamespace>C5.Tests</RootNamespace>
- <NoStandardLibraries>false</NoStandardLibraries>
- <AssemblyName>C5.Tests</AssemblyName>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <OldToolsVersion>3.5</OldToolsVersion>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\C5\</SolutionDir>
- <RestorePackages>true</RestorePackages>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <DebugSymbols>true</DebugSymbols>
- <Optimize>false</Optimize>
- <OutputPath>.\bin\Debug\</OutputPath>
- <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <WarningLevel>4</WarningLevel>
- <IncrementalBuild>false</IncrementalBuild>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
- <DebugSymbols>false</DebugSymbols>
- <Optimize>true</Optimize>
- <OutputPath>.\bin\Release\</OutputPath>
- <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
- <DefineConstants>TRACE</DefineConstants>
- <WarningLevel>4</WarningLevel>
- <IncrementalBuild>false</IncrementalBuild>
- </PropertyGroup>
- <ItemGroup>
- <Compile Include="arrays\CircularQueueTest.cs" />
- <Compile Include="BasesTest.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="InterfacesTest.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Records.cs" />
- <Compile Include="Sorting.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="SupportClasses.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="arrays\ArrayListTest.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="arrays\HashedArrayListTest.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="arrays\SortedArrayTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="hashing\HashBagTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="hashing\HashDictionaryTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="hashing\HashTableTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="heaps\HeapTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="linkedlists\HashedLinkedListTest.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="linkedlists\LinkedListTest.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="templates\Clone.cs" />
- <Compile Include="templates\Events.cs" />
- <Compile Include="templates\GenericCollectionTester.cs" />
- <Compile Include="templates\List.cs" />
- <Compile Include="trees\Bag.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="trees\Dictionary.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="trees\RedBlackTreeSetTests.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="WrappersTest.cs" />
- </ItemGroup>
- <ItemGroup>
- <AppDesigner Include="Properties\" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\C5\C5.csproj">
- <Project>{D02E0664-C56C-4C3F-98E5-C8EC881A8439}</Project>
- <Name>C5</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="nunit.mocks">
- <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
- </Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- </ItemGroup>
- <ItemGroup>
- <None Include="packages.config" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
- <PropertyGroup>
- <PreBuildEvent>
- </PreBuildEvent>
- <PostBuildEvent>
- </PostBuildEvent>
- </PropertyGroup>
- <ProjectExtensions>
- <VisualStudio>
- </VisualStudio>
- </ProjectExtensions>
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{08CBFDEB-A2E2-4F0E-A4E1-B996B05569DE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <StartupObject>
+ </StartupObject>
+ <RootNamespace>C5.Tests</RootNamespace>
+ <NoStandardLibraries>false</NoStandardLibraries>
+ <AssemblyName>C5.Tests</AssemblyName>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\C5\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <DebugSymbols>true</DebugSymbols>
+ <Optimize>false</Optimize>
+ <OutputPath>.\bin\Debug\</OutputPath>
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <IncrementalBuild>false</IncrementalBuild>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <DebugSymbols>false</DebugSymbols>
+ <Optimize>true</Optimize>
+ <OutputPath>.\bin\Release\</OutputPath>
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <IncrementalBuild>false</IncrementalBuild>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="arrays\CircularQueueTest.cs" />
+ <Compile Include="BasesTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="InterfacesTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Records.cs" />
+ <Compile Include="Sorting.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SupportClasses.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\ArrayListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\HashedArrayListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="arrays\SortedArrayTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashBagTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashDictionaryTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="hashing\HashTableTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="heaps\HeapTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="linkedlists\HashedLinkedListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="linkedlists\LinkedListTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="templates\Clone.cs" />
+ <Compile Include="templates\Events.cs" />
+ <Compile Include="templates\GenericCollectionTester.cs" />
+ <Compile Include="templates\List.cs" />
+ <Compile Include="trees\Bag.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="trees\Dictionary.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="trees\RedBlackTreeSetTests.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="WrappersTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\C5\C5.csproj">
+ <Project>{D02E0664-C56C-4C3F-98E5-C8EC881A8439}</Project>
+ <Name>C5</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+ <ProjectExtensions>
+ <VisualStudio>
+ </VisualStudio>
+ </ProjectExtensions>
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
34 C5.Tests/Properties/AssemblyInfo.cs
@@ -1,18 +1,18 @@
-// This file is part of the C5 Generic Collection Library for C# and CLI
-// See https://github.com/sestoft/C5/blob/master/LICENSE.txt for licensing details.
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("C5.Tests")]
-[assembly: AssemblyDescription("Unit testing suite for C5")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Niels Kokholm, Peter Sestoft, Rasmus Nielsen")]
-[assembly: AssemblyProduct("C5")]
-[assembly: AssemblyCopyright("Copyright © Niels Kokholm, Peter Sestoft, and Rasmus Nielsen 2003-2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: AssemblyVersion("2.0.0.0")]
-[assembly: AssemblyFileVersion("2.0.0.0")]
-[assembly: ComVisible(false)]
+// This file is part of the C5 Generic Collection Library for C# and CLI
+// See https://github.com/sestoft/C5/blob/master/LICENSE.txt for licensing details.
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("C5.Tests")]
+[assembly: AssemblyDescription("Unit testing suite for C5")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Niels Kokholm, Peter Sestoft, Rasmus Nielsen")]
+[assembly: AssemblyProduct("C5")]
+[assembly: AssemblyCopyright("Copyright © Niels Kokholm, Peter Sestoft, and Rasmus Nielsen 2003-2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: AssemblyVersion("2.0.0.0")]
+[assembly: AssemblyFileVersion("2.0.0.0")]
+[assembly: ComVisible(false)]
[assembly: Guid("db865c83-8334-4f17-8bdd-2026d35943a6")]
View
986 C5.Tests/SupportClasses.cs
@@ -1,493 +1,493 @@
-/*
- Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
- 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
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-*/
-
-using System;
-using C5;
-using NUnit.Framework;
-using SCG = System.Collections.Generic;
-
-
-namespace C5UnitTests
-{
- class SC : SCG.IComparer<string>
- {
- public int Compare(string a, string b)
- {
- return a.CompareTo(b);
- }
-
-
- public void appl(String s)
- {
- System.Console.WriteLine("--{0}", s);
- }
- }
-
- class TenEqualityComparer : SCG.IEqualityComparer<int>, SCG.IComparer<int>
- {
- TenEqualityComparer() { }
- public static TenEqualityComparer Default { get { return new TenEqualityComparer(); } }
- public int GetHashCode(int item) { return (item / 10).GetHashCode(); }
- public bool Equals(int item1, int item2) { return item1 / 10 == item2 / 10; }
- public int Compare(int a, int b) { return (a / 10).CompareTo(b / 10); }
- }
-
- class IC : SCG.IComparer<int>, IComparable<int>, SCG.IComparer<IC>, IComparable<IC>
- {
- public int Compare(int a, int b)
- {
- return a > b ? 1 : a < b ? -1 : 0;
- }
-
-
- public int Compare(IC a, IC b)
- {
- return a._i > b._i ? 1 : a._i < b._i ? -1 : 0;
- }
-
-
- private int _i;
-
-
- public int i
- {
- get { return _i; }
- set { _i = value; }
- }
-
-
- public IC() { }
-
-
- public IC(int i) { _i = i; }
-
-
- public int CompareTo(int that) { return _i > that ? 1 : _i < that ? -1 : 0; }
-
- public bool Equals(int that) { return _i == that; }
-
-
- public int CompareTo(IC that) { return _i > that._i ? 1 : _i < that._i ? -1 : 0; }
- public bool Equals(IC that) { return _i == that._i; }
-
-
- public static bool eq(SCG.IEnumerable<int> me, params int[] that)
- {
- int i = 0, maxind = that.Length - 1;
-
- foreach (int item in me)
- if (i > maxind || item != that[i++])
- return false;
-
- return i == maxind + 1;
- }
- public static bool seteq(ICollectionValue<int> me, params int[] that)
- {
- int[] me2 = me.ToArray();
-
- Array.Sort(me2);
-
- int i = 0, maxind = that.Length - 1;
-
- foreach (int item in me2)
- if (i > maxind || item != that[i++])
- return false;
-
- return i == maxind + 1;
- }
- public static bool seteq(ICollectionValue<KeyValuePair<int, int>> me, params int[] that)
- {
- ArrayList<KeyValuePair<int, int>> first = new ArrayList<KeyValuePair<int, int>>();
- first.AddAll(me);
- ArrayList<KeyValuePair<int, int>> other = new ArrayList<KeyValuePair<int, int>>();
- for (int i = 0; i < that.Length; i += 2)
- {
- other.Add(new KeyValuePair<int, int>(that[i], that[i + 1]));
- }
- return other.UnsequencedEquals(first);
- }
- }
-
- class RevIC : SCG.IComparer<int>
- {
- public int Compare(int a, int b)
- {
- return a > b ? -1 : a < b ? 1 : 0;
- }
- }
-
- public class FunEnumerable : SCG.IEnumerable<int>
- {
- int size;
- Func<int, int> f;
-
- public FunEnumerable(int size, Func<int, int> f)
- {
- this.size = size; this.f = f;
- }
-
- public SCG.IEnumerator<int> GetEnumerator()
- {
- for (int i = 0; i < size; i++)
- yield return f(i);
- }
-
-
- #region IEnumerable Members
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- throw new NotImplementedException();
- }
-
- #endregion
- }
-
- public class BadEnumerableException : Exception { }
-
- public class BadEnumerable<T> : CollectionValueBase<T>, ICollectionValue<T>
- {
- T[] contents;
- Exception exception;
-
- public BadEnumerable(Exception exception, params T[] contents)
- {
- this.contents = (T[])contents.Clone();
- this.exception = exception;
- }
-
- public override SCG.IEnumerator<T> GetEnumerator()
- {
- for (int i = 0; i < contents.Length; i++)
- yield return contents[i];
- throw exception;
- }
-
- public override bool IsEmpty { get { return false; } }
-
- public override int Count { get { return contents.Length + 1; } }
-
- public override Speed CountSpeed { get { return Speed.Constant; } }
-
- public override T Choose() { throw exception; }
- }
-
- public class CollectionEventList<T>
- {
- ArrayList<CollectionEvent<T>> happened;
- EventTypeEnum listenTo;
- SCG.IEqualityComparer<T> itemequalityComparer;
- public CollectionEventList(SCG.IEqualityComparer<T> itemequalityComparer)
- {
- happened = new ArrayList<CollectionEvent<T>>();
- this.itemequalityComparer = itemequalityComparer;
- }
- public void Listen(ICollectionValue<T> list, EventTypeEnum listenTo)
- {
- this.listenTo = listenTo;
- if ((listenTo & EventTypeEnum.Changed) != 0)
- list.CollectionChanged += new CollectionChangedHandler<T>(changed);
- if ((listenTo & EventTypeEnum.Cleared) != 0)
- list.CollectionCleared += new CollectionClearedHandler<T>(cleared);
- if ((listenTo & EventTypeEnum.Removed) != 0)
- list.ItemsRemoved += new ItemsRemovedHandler<T>(removed);
- if ((listenTo & EventTypeEnum.Added) != 0)
- list.ItemsAdded += new ItemsAddedHandler<T>(added);
- if ((listenTo & EventTypeEnum.Inserted) != 0)
- list.ItemInserted += new ItemInsertedHandler<T>(inserted);
- if ((listenTo & EventTypeEnum.RemovedAt) != 0)
- list.ItemRemovedAt += new ItemRemovedAtHandler<T>(removedAt);
- }
- public void Add(CollectionEvent<T> e) { happened.Add(e); }
- /// <summary>
- /// Check that we have seen exactly the events in expected that match listenTo.
- /// </summary>
- /// <param name="expected"></param>
- public void Check(SCG.IEnumerable<CollectionEvent<T>> expected)
- {
- int i = 0;
- foreach (CollectionEvent<T> expectedEvent in expected)
- {
- if ((expectedEvent.Act & listenTo) == 0)
- continue;
- if (i >= happened.Count)
- Assert.Fail(string.Format("Event number {0} did not happen:\n expected {1}", i, expectedEvent));
- if (!expectedEvent.Equals(happened[i], itemequalityComparer))
- Assert.Fail(string.Format("Event number {0}:\n expected {1}\n but saw {2}", i, expectedEvent, happened[i]));
- i++;
- }
- if (i < happened.Count)
- Assert.Fail(string.Format("Event number {0} seen but no event expected:\n {1}", i, happened[i]));
- happened.Clear();
- }
- public void Clear() { happened.Clear(); }
- public void Print(System.IO.TextWriter writer)
- {
- happened.Apply(delegate(CollectionEvent<T> e) { writer.WriteLine(e); });
- }
- void changed(object sender)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.Changed, new EventArgs(), sender));
- }
- void cleared(object sender, ClearedEventArgs eventArgs)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.Cleared, eventArgs, sender));
- }
- void added(object sender, ItemCountEventArgs<T> eventArgs)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.Added, eventArgs, sender));
- }
- void removed(object sender, ItemCountEventArgs<T> eventArgs)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.Removed, eventArgs, sender));
- }
- void inserted(object sender, ItemAtEventArgs<T> eventArgs)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.Inserted, eventArgs, sender));
- }
- void removedAt(object sender, ItemAtEventArgs<T> eventArgs)
- {
- happened.Add(new CollectionEvent<T>(EventTypeEnum.RemovedAt, eventArgs, sender));
- }
- }
-
- public sealed class CollectionEvent<T>
- {
- public readonly EventTypeEnum Act;
- public readonly EventArgs Args;
- public readonly object Sender;
-
- public CollectionEvent(EventTypeEnum act, EventArgs args, object sender)
- {
- this.Act = act;
- this.Args = args;
- this.Sender = sender;
- }
-
- public bool Equals(CollectionEvent<T> otherEvent, SCG.IEqualityComparer<T> itemequalityComparer)
- {
- if (otherEvent == null || Act != otherEvent.Act || !object.ReferenceEquals(Sender, otherEvent.Sender))
- return false;
- switch (Act)
- {
- case EventTypeEnum.None:
- break;
- case EventTypeEnum.Changed:
- return true;
- case EventTypeEnum.Cleared:
- if (Args is ClearedRangeEventArgs)
- {
- ClearedRangeEventArgs a = Args as ClearedRangeEventArgs, o = otherEvent.Args as ClearedRangeEventArgs;
- if (o == null)
- return false;
- return a.Full == o.Full && a.Start == o.Start && a.Count == o.Count;
- }
- else
- {
- if (otherEvent.Args is ClearedRangeEventArgs)
- return false;
- ClearedEventArgs a = Args as ClearedEventArgs, o = otherEvent.Args as ClearedEventArgs;
- return a.Full == o.Full && a.Count == o.Count;
- }
- case EventTypeEnum.Added:
- {
- ItemCountEventArgs<T> a = Args as ItemCountEventArgs<T>, o = otherEvent.Args as ItemCountEventArgs<T>;
- return itemequalityComparer.Equals(a.Item, o.Item) && a.Count == o.Count;
- }
- case EventTypeEnum.Removed:
- {
- ItemCountEventArgs<T> a = Args as ItemCountEventArgs<T>, o = otherEvent.Args as ItemCountEventArgs<T>;
- return itemequalityComparer.Equals(a.Item, o.Item) && a.Count == o.Count;
- }
- case EventTypeEnum.Inserted:
- {
- ItemAtEventArgs<T> a = Args as ItemAtEventArgs<T>, o = otherEvent.Args as ItemAtEventArgs<T>;
- return a.Index == o.Index && itemequalityComparer.Equals(a.Item, o.Item);
- }
- case EventTypeEnum.RemovedAt:
- {
- ItemAtEventArgs<T> a = Args as ItemAtEventArgs<T>, o = otherEvent.Args as ItemAtEventArgs<T>;
- return a.Index == o.Index && itemequalityComparer.Equals(a.Item, o.Item);
- }
- }
- throw new ApplicationException("Illegal Action: " + Act);
- }
-
- public override string ToString()
- {
- return string.Format("Action: {0}, Args : {1}, Source : {2}", Act, Args, Sender);
- }
-
- }
-
- public class CHC
- {
- static public int unsequencedhashcode(params int[] a)
- {
- int h = 0;
- foreach (int i in a)
- {
- h += (int)(((uint)i * 1529784657 + 1) ^ ((uint)i * 2912831877) ^ ((uint)i * 1118771817 + 2));
- }
- return h;
- }
- static public int sequencedhashcode(params int[] a)
- {
- int h = 0;
- foreach (int i in a) { h = h * 31 + i; }
- return h;
- }
- }
-
- //This class is a modified sample from VS2005 beta1 documentation
- public class RadixFormatProvider : IFormatProvider
- {
- RadixFormatter _radixformatter;
- public RadixFormatProvider(int radix)
- {
- if (radix < 2 || radix > 36)
- throw new ArgumentException(string.Format(
- "The radix \"{0}\" is not in the range 2..36.",
- radix));
- _radixformatter = new RadixFormatter(radix);
- }
- public object GetFormat(Type argType)
- {
- if (argType == typeof(ICustomFormatter))
- return _radixformatter;
- else
- return null;
- }
- }
-
- //This class is a modified sample from VS2005 beta1 documentation
- public class RadixFormatter : ICustomFormatter
- {
- int radix;
- public RadixFormatter(int radix)
- {
- if (radix < 2 || radix > 36)
- throw new ArgumentException(string.Format(
- "The radix \"{0}\" is not in the range 2..36.",
- radix));
- this.radix = radix;
- }
-
- // The value to be formatted is returned as a signed string
- // of digits from the rDigits array.
- private static char[] rDigits = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z' };
-
- public string Format(string formatString,
- object argToBeFormatted, IFormatProvider provider)
- {
- /*switch (Type.GetTypeCode(argToBeFormatted.GetType()))
- {
- case TypeCode.Boolean:
- break;
- case TypeCode.Byte:
- break;
- case TypeCode.Char:
- break;
- case TypeCode.DBNull:
- break;
- case TypeCode.DateTime:
- break;
- case TypeCode.Decimal:
- break;
- case TypeCode.Double:
- break;
- case TypeCode.Empty:
- break;
- case TypeCode.Int16:
- break;
- case TypeCode.Int32:
- break;
- case TypeCode.Int64:
- break;
- case TypeCode.Object:
- break;
- case TypeCode.SByte:
- break;
- case TypeCode.Single:
- break;
- case TypeCode.String:
- break;
- case TypeCode.UInt16:
- break;
- case TypeCode.UInt32:
- break;
- case TypeCode.UInt64:
- break;
- }*/
- int intToBeFormatted;
- try
- {
- intToBeFormatted = (int)argToBeFormatted;
- }
- catch (Exception)
- {
- if (argToBeFormatted is IFormattable)
- return ((IFormattable)argToBeFormatted).
- ToString(formatString, provider);
- else
- return argToBeFormatted.ToString();
- }
- return formatInt(intToBeFormatted);
- }
-
- private string formatInt(int intToBeFormatted)
- {
- // The formatting is handled here.
- if (intToBeFormatted == 0)
- return "0";
- int digitIndex = 0;
- int intPositive;
- char[] outDigits = new char[31];
-
- // Verify that the argument can be converted to a int integer.
- // Extract the magnitude for conversion.
- intPositive = Math.Abs(intToBeFormatted);
-
- // Convert the magnitude to a digit string.
- for (digitIndex = 0; digitIndex <= 32; digitIndex++)
- {
- if (intPositive == 0) break;
-
- outDigits[outDigits.Length - digitIndex - 1] =
- rDigits[intPositive % radix];
- intPositive /= radix;
- }
-
- // Add a minus sign if the argument is negative.
- if (intToBeFormatted < 0)
- outDigits[outDigits.Length - digitIndex++ - 1] =
- '-';
-
- return new string(outDigits,
- outDigits.Length - digitIndex, digitIndex);
- }
- }
-
-}
+/*
+ Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
+ 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
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+using System;
+using C5;
+using NUnit.Framework;
+using SCG = System.Collections.Generic;
+
+
+namespace C5UnitTests
+{
+ class SC : SCG.IComparer<string>
+ {
+ public int Compare(string a, string b)
+ {
+ return a.CompareTo(b);
+ }
+
+
+ public void appl(String s)
+ {
+ System.Console.WriteLine("--{0}", s);
+ }
+ }
+
+ class TenEqualityComparer : SCG.IEqualityComparer<int>, SCG.IComparer<int>
+ {
+ TenEqualityComparer() { }
+ public static TenEqualityComparer Default { get { return new TenEqualityComparer(); } }
+ public int GetHashCode(int item) { return (item / 10).GetHashCode(); }
+ public bool Equals(int item1, int item2) { return item1 / 10 == item2 / 10; }
+ public int Compare(int a, int b) { return (a / 10).CompareTo(b / 10); }
+ }
+
+ class IC : SCG.IComparer<int>, IComparable<int>, SCG.IComparer<IC>, IComparable<IC>
+ {
+ public int Compare(int a, int b)
+ {
+ return a > b ? 1 : a < b ? -1 : 0;
+ }
+
+
+ public int Compare(IC a, IC b)
+ {
+ return a._i > b._i ? 1 : a._i < b._i ? -1 : 0;
+ }
+
+
+ private int _i;
+
+
+ public int i
+ {
+ get { return _i; }
+ set { _i = value; }
+ }
+
+
+ public IC() { }
+
+
+ public IC(int i) { _i = i; }
+
+
+ public int CompareTo(int