-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathParseFastTest.cs
More file actions
73 lines (60 loc) · 1.55 KB
/
Copy pathParseFastTest.cs
File metadata and controls
73 lines (60 loc) · 1.55 KB
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
67
68
69
70
71
72
73
using System;
using System.Text;
using NUnit.Framework;
namespace IntXLib.Test
{
[TestFixture]
public class ParseFastTest
{
const int StartLength = 1024;
const int LengthIncrement = 101;
const int RepeatCount = 50;
const int RandomStartLength = 1024;
const int RandomEndLength = 4000;
const int RandomRepeatCount = 50;
int _length = StartLength;
public string GetAllNineChars(int length)
{
return new string('9', length);
}
public string GetRandomChars()
{
Random random = new Random();
int length = random.Next(RandomStartLength, RandomEndLength);
StringBuilder builder = new StringBuilder(length);
builder.Append((char)random.Next('1', '9'));
--length;
while (length-- != 0) {
builder.Append((char)random.Next('0', '9'));
}
return builder.ToString();
}
[Test]
public void CompareWithClassic()
{
TestHelper.Repeat(
RepeatCount,
delegate
{
string str = GetAllNineChars(_length);
IntX classic = IntX.Parse(str, ParseMode.Classic);
IntX fast = IntX.Parse(str, ParseMode.Fast);
Assert.IsTrue(classic == fast);
_length += LengthIncrement;
});
}
[Test]
public void CompareWithClassicRandom()
{
TestHelper.Repeat(
RandomRepeatCount,
delegate
{
string str = GetRandomChars();
IntX classic = IntX.Parse(str, ParseMode.Classic);
IntX fast = IntX.Parse(str, ParseMode.Fast);
Assert.IsTrue(classic == fast);
});
}
}
}