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

ComparerTest.cs « System.Collections « Test « corlib « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38b78de39e768c5b7f04b0f0422ae9998fdc0451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ComparerTest

using System;
using System.Collections;

using NUnit.Framework;



namespace MonoTests.System.Collections {


	/// <summary>Comparer test suite.</summary>
	public class ComparerTest : TestCase {
		public ComparerTest() : base ("MonoTests.System.Collections.ComparerTest testcase") {}
		public ComparerTest(String name) : base(name)
		{
		}

		protected override void SetUp ()
		{
		}

		public static ITest Suite
		{
			get {
				return new TestSuite(typeof(ComparerTest));
			}
		}

		public void TestDefaultInstance ()
		{
			// Make sure the instance returned by Default
			// is really a Comparer.
			Assert((Comparer.Default as Comparer) != null);
		}

		public void TestCompare ()
		{
			Comparer c = Comparer.Default;

			bool thrown = false;

			try {
				c.Compare (new Object (), new Object ());
			} catch (ArgumentException) {
				thrown = true;
			}

			Assert("ArgumentException expected", thrown);

			Assert(c.Compare (1, 2) < 0);
			Assert(c.Compare (2, 2) == 0);
			Assert(c.Compare (3, 2) > 0);

		}
			
	}

}