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

gtest-483.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba8a361a7ef51199201c7243708fae7562b14c88 (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
61
62
63
64
65
66
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
	public static int Main ()
	{
		Int32Collection src = new Int32Collection ();
		Int32Collection dest = new Int32Collection ();

		src.Add (5);
		src.Add (7);
		dest.Add (4);

		ReplaceContentsWith<Int32Collection> (src, dest);

		if (dest.Count != 2)
			return 1;
		if (dest[0] != 5)
			return 2;
		if (dest[1] != 7)
			return 3;

		return 0;
	}

	private static void ReplaceContentsWith<T> (T src, T dst)
		where T : Int32Collection
	{
		dst.Clear ();
		foreach (int value in src)
			dst.Add (value);
	}
}

class Int32Collection : IEnumerable
{
	List<int> list = new List<int> ();

	public int Count
	{
		get { return list.Count; }
	}

	public int this[int index]
	{
		get { return (int) list[index]; }
		set { list[index] = value; }
	}

	public void Add (int value)
	{
		list.Add (value);
	}

	public void Clear ()
	{
		list.Clear ();
	}

	IEnumerator IEnumerable.GetEnumerator ()
	{
		return list.GetEnumerator ();
	}
}