Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 441ccbc

Browse files
committed
Revamp test cases.
1 parent 4df1a47 commit 441ccbc

File tree

4 files changed

+89
-69
lines changed

4 files changed

+89
-69
lines changed

‎src/AlgorithmForce.Searching.Test/ExtensionsIndexOfTest.cs‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,47 @@ public override void TestCaseSingleElement()
5656
Assert.Equal(1, s.IndexOf(t));
5757
}
5858

59+
/// <summary>
60+
/// In this test case, we are going to compare
61+
/// string.IndexOf() and Extensions.IndexOf() to see
62+
/// if they have same behavior.
63+
/// </summary>
5964
[Fact]
6065
public override void TestCaseString()
6166
{
62-
var s = @"Vrogros, the Underlord, is a melee strength hero
63-
whose commanding presence is crucial to his team's success.
64-
With his long-lasting abilities, Underlord is able to
65-
control wide areas of the battlefield during teamfights.";
67+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
68+
"whose commanding presence is crucial to his team's success. ",
69+
"With his long-lasting abilities, Underlord is able to ",
70+
"control wide areas of the battlefield during teamfights.");
6671
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
6772

68-
Assert.Equal(13, s.IndexOf(t));
73+
Assert.Equal(s.IndexOf(string.Concat(t)), s.IndexOf(t));
6974
}
7075

76+
/// <summary>
77+
/// In this test case, we are going to compare
78+
/// string.IndexOf() and Extensions.IndexOf() to see
79+
/// if they have same behavior.
80+
/// </summary>
7181
[Fact]
7282
public override void TestCaseStringWithStartIndex()
7383
{
74-
var s = @"Vrogros, the Underlord, is a melee strength hero
75-
whose commanding presence is crucial to his team's success.
76-
With his long-lasting abilities, Underlord is able to
77-
control wide areas of the battlefield during teamfights.";
84+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
85+
"whose commanding presence is crucial to his team's success. ",
86+
"With his long-lasting abilities, Underlord is able to ",
87+
"control wide areas of the battlefield during teamfights.");
7888
var t = new[] { 't', 'e', 'a', 'm', 'f', 'i', 'g', 'h', 't', 's' };
7989

80-
Assert.Equal(261, s.IndexOf(t, 128));
90+
Assert.Equal(s.IndexOf(string.Concat(t),128), s.IndexOf(t, 128));
8191
}
8292

8393
[Fact]
8494
public override void TestCaseStringNotFound()
8595
{
86-
var s = @"Vrogros, the Underlord, is a melee strength hero
87-
whose commanding presence is crucial to his team's success.
88-
With his long-lasting abilities, Underlord is able to
89-
control wide areas of the battlefield during teamfights.";
96+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
97+
"whose commanding presence is crucial to his team's success. ",
98+
"With his long-lasting abilities, Underlord is able to ",
99+
"control wide areas of the battlefield during teamfights.");
90100
var t = new[] { 'S', 'u', 'n', ' ', 'W', 'u', 'k', 'o', 'n', 'g' };
91101

92102
Assert.Equal(-1, s.IndexOf(t));
@@ -95,10 +105,10 @@ whose commanding presence is crucial to his team's success.
95105
[Fact]
96106
public override void TestCaseStringWithStartIndexNotFound()
97107
{
98-
var s = @"Vrogros, the Underlord, is a melee strength hero
99-
whose commanding presence is crucial to his team's success.
100-
With his long-lasting abilities, Underlord is able to
101-
control wide areas of the battlefield during teamfights.";
108+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
109+
"whose commanding presence is crucial to his team's success. ",
110+
"With his long-lasting abilities, Underlord is able to ",
111+
"control wide areas of the battlefield during teamfights.");
102112
var t = new[] { 'V', 'r', 'o', 'g', 'r', 'o', 's' };
103113

104114
Assert.Equal(-1, s.IndexOf(t, 128));

‎src/AlgorithmForce.Searching.Test/ExtensionsIndexesOfTest.cs‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public ExtensionsIndexesOfTest(ITestOutputHelper output)
1515
[Fact]
1616
public void TestCaseDefault()
1717
{
18-
var s = @"Vrogros, the Underlord, is a melee strength hero
19-
whose commanding presence is crucial to his team's success.
20-
With his long-lasting abilities, Underlord is able to
21-
control wide areas of the battlefield during teamfights.";
18+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
19+
"whose commanding presence is crucial to his team's success. ",
20+
"With his long-lasting abilities, Underlord is able to ",
21+
"control wide areas of the battlefield during teamfights.");
2222
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
23-
var expected = new[] { 13, 177 };
23+
var expected = new[] { 13, 142 };
2424

2525
Assert.Equal(expected, s.IndexesOf(t));
2626
}
@@ -38,23 +38,23 @@ public void TestCaseWithOverlapped()
3838
[Fact]
3939
public void TestCaseWithStartIndex()
4040
{
41-
var s = @"Vrogros, the Underlord, is a melee strength hero
42-
whose commanding presence is crucial to his team's success.
43-
With his long-lasting abilities, Underlord is able to
44-
control wide areas of the battlefield during teamfights.";
41+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
42+
"whose commanding presence is crucial to his team's success. ",
43+
"With his long-lasting abilities, Underlord is able to ",
44+
"control wide areas of the battlefield during teamfights.");
4545
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
46-
var expected = new[] { 177 };
46+
var expected = new[] { 142 };
4747

4848
Assert.Equal(expected, s.IndexesOf(t, 100));
4949
}
5050

5151
[Fact]
5252
public void TestCaseNotFound()
5353
{
54-
var s = @"Vrogros, the Underlord, is a melee strength hero
55-
whose commanding presence is crucial to his team's success.
56-
With his long-lasting abilities, Underlord is able to
57-
control wide areas of the battlefield during teamfights.";
54+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
55+
"whose commanding presence is crucial to his team's success. ",
56+
"With his long-lasting abilities, Underlord is able to ",
57+
"control wide areas of the battlefield during teamfights.");
5858
var t = new[] { 'S', 'u', 'n', ' ', 'W', 'u', 'k', 'o', 'n', 'g' };
5959

6060
Assert.Empty(s.IndexesOf(t));
@@ -63,10 +63,10 @@ whose commanding presence is crucial to his team's success.
6363
[Fact]
6464
public void TestCaseWithStartIndexNotFound()
6565
{
66-
var s = @"Vrogros, the Underlord, is a melee strength hero
67-
whose commanding presence is crucial to his team's success.
68-
With his long-lasting abilities, Underlord is able to
69-
control wide areas of the battlefield during teamfights.";
66+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
67+
"whose commanding presence is crucial to his team's success. ",
68+
"With his long-lasting abilities, Underlord is able to ",
69+
"control wide areas of the battlefield during teamfights.");
7070
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
7171

7272
Assert.Empty(s.IndexesOf(t, 180));

‎src/AlgorithmForce.Searching.Test/ExtensionsLastIndexOfTest.cs‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,38 @@ public override void TestCaseSingleElement()
5656
Assert.Equal(1, s.LastIndexOf(t));
5757
}
5858

59+
/// <summary>
60+
/// In this test case, we are going to compare
61+
/// string.LastIndexOf() and Extensions.LastIndexOf() to see
62+
/// if they have same behavior.
63+
/// </summary>
5964
[Fact]
6065
public override void TestCaseString()
6166
{
62-
var s = @"Vrogros, the Underlord, is a melee strength hero
63-
whose commanding presence is crucial to his team's success.
64-
With his long-lasting abilitties, Underlord is able to
65-
control wide areas of the battlefield during teamfights.";
67+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
68+
"whose commanding presence is crucial to his team's success. ",
69+
"With his long-lasting abilities, Underlord is able to ",
70+
"control wide areas of the battlefield during teamfights.");
6671
var t = new[] { 'V', 'r', 'o', 'g', 'r', 'o', 's' };
6772

68-
Assert.Equal(0, s.LastIndexOf(t));
73+
Assert.Equal(s.LastIndexOf(string.Concat(t)), s.LastIndexOf(t));
6974
}
7075

76+
/// <summary>
77+
/// In this test case, we are going to compare
78+
/// string.LastIndexOf() and Extensions.LastIndexOf() to see
79+
/// if they have same behavior.
80+
/// </summary>
7181
[Fact]
7282
public override void TestCaseStringWithStartIndex()
7383
{
74-
var s = @"Vrogros, the Underlord, is a melee strength hero
75-
whose commanding presence is crucial to his team's success.
76-
With his long-lasting abilities, Underlord is able to
77-
control wide areas of the battlefield during teamfights.";
84+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
85+
"whose commanding presence is crucial to his team's success. ",
86+
"With his long-lasting abilities, Underlord is able to ",
87+
"control wide areas of the battlefield during teamfights.");
7888
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
7989

80-
Assert.Equal(13, s.LastIndexOf(t, 128));
90+
Assert.Equal(s.LastIndexOf(string.Concat(t),128), s.LastIndexOf(t, 128));
8191
}
8292

8393
[Fact]
@@ -95,10 +105,10 @@ whose commanding presence is crucial to his team's success.
95105
[Fact]
96106
public override void TestCaseStringWithStartIndexNotFound()
97107
{
98-
var s = @"Vrogros, the Underlord, is a melee strength hero
99-
whose commanding presence is crucial to his team's success.
100-
With his long-lasting abilities, Underlord is able to
101-
control wide areas of the battlefield during teamfights.";
108+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
109+
"whose commanding presence is crucial to his team's success. ",
110+
"With his long-lasting abilities, Underlord is able to ",
111+
"control wide areas of the battlefield during teamfights.");
102112
var t = new[] { 't', 'e', 'a', 'm', 'f', 'i', 'g', 'h', 't', 's' };
103113

104114
Assert.Equal(-1, s.LastIndexOf(t, 128));

‎src/AlgorithmForce.Searching.Test/ExtensionsLastIndexesOfTest.cs‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public ExtensionsLastIndexesOfTest(ITestOutputHelper output)
1515
[Fact]
1616
public void TestCaseDefault()
1717
{
18-
var s = @"Vrogros, the Underlord, is a melee strength hero
19-
whose commanding presence is crucial to his team's success.
20-
With his long-lasting abilities, Underlord is able to
21-
control wide areas of the battlefield during teamfights.";
18+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
19+
"whose commanding presence is crucial to his team's success. ",
20+
"With his long-lasting abilities, Underlord is able to ",
21+
"control wide areas of the battlefield during teamfights.");
2222
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
23-
var expected = new[] { 177, 13 };
23+
var expected = new[] { 142, 13 };
2424

2525
Assert.Equal(expected, s.LastIndexesOf(t));
2626
}
@@ -38,23 +38,23 @@ public void TestCaseWithOverlapped()
3838
[Fact]
3939
public void TestCaseWithStartIndex()
4040
{
41-
var s = @"Vrogros, the Underlord, is a melee strength hero
42-
whose commanding presence is crucial to his team's success.
43-
With his long-lasting abilities, Underlord is able to
44-
control wide areas of the battlefield during teamfights.";
41+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
42+
"whose commanding presence is crucial to his team's success. ",
43+
"With his long-lasting abilities, Underlord is able to ",
44+
"control wide areas of the battlefield during teamfights.");
4545
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
4646
var expected = new[] { 13 };
4747

48-
Assert.Equal(expected, s.LastIndexesOf(t, 177));
48+
Assert.Equal(expected, s.LastIndexesOf(t, 100));
4949
}
5050

5151
[Fact]
5252
public void TestCaseNotFound()
5353
{
54-
var s = @"Vrogros, the Underlord, is a melee strength hero
55-
whose commanding presence is crucial to his team's success.
56-
With his long-lasting abilities, Underlord is able to
57-
control wide areas of the battlefield during teamfights.";
54+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
55+
"whose commanding presence is crucial to his team's success. ",
56+
"With his long-lasting abilities, Underlord is able to ",
57+
"control wide areas of the battlefield during teamfights.");
5858
var t = new[] { 'S', 'u', 'n', ' ', 'W', 'u', 'k', 'o', 'n', 'g' };
5959

6060
Assert.Empty(s.LastIndexesOf(t));
@@ -63,13 +63,13 @@ whose commanding presence is crucial to his team's success.
6363
[Fact]
6464
public void TestCaseWithStartIndexNotFound()
6565
{
66-
var s = @"Vrogros, the Underlord, is a melee strength hero
67-
whose commanding presence is crucial to his team's success.
68-
With his long-lasting abilities, Underlord is able to
69-
control wide areas of the battlefield during teamfights.";
66+
var s = string.Concat("Vrogros, the Underlord, is a melee strength hero ",
67+
"whose commanding presence is crucial to his team's success. ",
68+
"With his long-lasting abilities, Underlord is able to ",
69+
"control wide areas of the battlefield during teamfights.");
7070
var t = new[] { 'U', 'n', 'd', 'e', 'r', 'l', 'o', 'r', 'd' };
7171

72-
Assert.Empty(s.LastIndexesOf(t, 13));
72+
Assert.Empty(s.LastIndexesOf(t, 13));
7373
}
7474
}
7575
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /