Movatterモバイル変換


[0]ホーム

URL:


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

Commite060cec

Browse files
authored
Improved tests and readme
1 parentf3668c6 commite060cec

File tree

13 files changed

+365
-344
lines changed

13 files changed

+365
-344
lines changed

‎LeetCodeNet.Tests/G0001_0100/S0012_integer_to_roman/SolutionTest.cs‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,29 @@ namespace LeetCodeNet.G0001_0100.S0012_integer_to_roman {
33
usingSystem;
44
usingXunit;
55

6-
publicclassSolutionTest
7-
{
6+
publicclassSolutionTest{
87
[Fact]
9-
publicvoidIntToRoman()
10-
{
8+
publicvoidIntToRoman(){
119
Assert.Equal("III",newSolution().IntToRoman(3));
1210
}
1311

1412
[Fact]
15-
publicvoidIntToRoman2()
16-
{
13+
publicvoidIntToRoman2(){
1714
Assert.Equal("IV",newSolution().IntToRoman(4));
1815
}
1916

2017
[Fact]
21-
publicvoidIntToRoman3()
22-
{
18+
publicvoidIntToRoman3(){
2319
Assert.Equal("IX",newSolution().IntToRoman(9));
2420
}
2521

2622
[Fact]
27-
publicvoidIntToRoman4()
28-
{
23+
publicvoidIntToRoman4(){
2924
Assert.Equal("LVIII",newSolution().IntToRoman(58));
3025
}
3126

3227
[Fact]
33-
publicvoidIntToRoman5()
34-
{
28+
publicvoidIntToRoman5(){
3529
Assert.Equal("MCMXCIV",newSolution().IntToRoman(1994));
3630
}
3731
}

‎LeetCodeNet.Tests/G0001_0100/S0013_roman_to_integer/SolutionTest.cs‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,29 @@ namespace LeetCodeNet.G0001_0100.S0013_roman_to_integer {
33
usingSystem;
44
usingXunit;
55

6-
publicclassSolutionTest
7-
{
6+
publicclassSolutionTest{
87
[Fact]
9-
publicvoidRomanToInt()
10-
{
8+
publicvoidRomanToInt(){
119
Assert.Equal(3,newSolution().RomanToInt("III"));
1210
}
1311

1412
[Fact]
15-
publicvoidRomanToInt2()
16-
{
13+
publicvoidRomanToInt2(){
1714
Assert.Equal(4,newSolution().RomanToInt("IV"));
1815
}
1916

2017
[Fact]
21-
publicvoidRomanToInt3()
22-
{
18+
publicvoidRomanToInt3(){
2319
Assert.Equal(9,newSolution().RomanToInt("IX"));
2420
}
2521

2622
[Fact]
27-
publicvoidRomanToInt4()
28-
{
23+
publicvoidRomanToInt4(){
2924
Assert.Equal(58,newSolution().RomanToInt("LVIII"));
3025
}
3126

3227
[Fact]
33-
publicvoidRomanToInt5()
34-
{
28+
publicvoidRomanToInt5(){
3529
Assert.Equal(1994,newSolution().RomanToInt("MCMXCIV"));
3630
}
3731
}

‎LeetCodeNet.Tests/G0001_0100/S0014_longest_common_prefix/SolutionTest.cs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ namespace LeetCodeNet.G0001_0100.S0014_longest_common_prefix {
33
usingSystem;
44
usingXunit;
55

6-
publicclassSolutionTest
7-
{
6+
publicclassSolutionTest{
87
[Fact]
9-
publicvoidLongestCommonPrefix()
10-
{
8+
publicvoidLongestCommonPrefix(){
119
Assert.Equal("fl",newSolution().LongestCommonPrefix(newstring[]{"flower","flow","flight"}));
1210
}
1311

1412
[Fact]
15-
publicvoidLongestCommonPrefix2()
16-
{
13+
publicvoidLongestCommonPrefix2(){
1714
Assert.Equal("",newSolution().LongestCommonPrefix(newstring[]{"dog","racecar","car"}));
1815
}
1916
}
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1+
namespaceLeetCodeNet.G0001_0100.S0030_substring_with_concatenation_of_all_words{
2+
13
usingSystem.Collections.Generic;
24
usingXunit;
35

4-
namespaceLeetCodeNet.G0001_0100.S0030_substring_with_concatenation_of_all_words{
5-
publicclassSolutionTest{
6-
[Fact]
7-
publicvoidFindSubstring(){
8-
varsolution=newSolution();
9-
varresult=solution.FindSubstring("barfoothefoobarman",newstring[]{"foo","bar"});
10-
varexpected=newList<int>{0,9};
11-
varresultList=newList<int>(result);
12-
resultList.Sort();
13-
expected.Sort();
14-
Assert.Equal(expected,resultList);
15-
}
6+
publicclassSolutionTest{
7+
[Fact]
8+
publicvoidFindSubstring(){
9+
varsolution=newSolution();
10+
varresult=solution.FindSubstring("barfoothefoobarman",newstring[]{"foo","bar"});
11+
varexpected=newList<int>{0,9};
12+
varresultList=newList<int>(result);
13+
resultList.Sort();
14+
expected.Sort();
15+
Assert.Equal(expected,resultList);
16+
}
1617

17-
[Fact]
18-
publicvoidFindSubstring2(){
19-
varsolution=newSolution();
20-
varresult=solution.FindSubstring("wordgoodgoodgoodbestword",newstring[]{"word","good","best","word"});
21-
Assert.Equal(newList<int>(),result);
22-
}
18+
[Fact]
19+
publicvoidFindSubstring2(){
20+
varsolution=newSolution();
21+
varresult=solution.FindSubstring("wordgoodgoodgoodbestword",newstring[]{"word","good","best","word"});
22+
Assert.Equal(newList<int>(),result);
23+
}
2324

24-
[Fact]
25-
publicvoidFindSubstring3(){
26-
varsolution=newSolution();
27-
varresult=solution.FindSubstring("barfoofoobarthefoobarman",newstring[]{"bar","foo","the"});
28-
varexpected=newList<int>{6,9,12};
29-
varresultList=newList<int>(result);
30-
resultList.Sort();
31-
expected.Sort();
32-
Assert.Equal(expected,resultList);
33-
}
25+
[Fact]
26+
publicvoidFindSubstring3(){
27+
varsolution=newSolution();
28+
varresult=solution.FindSubstring("barfoofoobarthefoobarman",newstring[]{"bar","foo","the"});
29+
varexpected=newList<int>{6,9,12};
30+
varresultList=newList<int>(result);
31+
resultList.Sort();
32+
expected.Sort();
33+
Assert.Equal(expected,resultList);
3434
}
3535
}
36+
}
Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1+
namespaceLeetCodeNet.G0001_0100.S0036_valid_sudoku{
2+
13
usingXunit;
24

3-
namespaceLeetCodeNet.G0001_0100.S0036_valid_sudoku{
4-
publicclassSolutionTest{
5-
[Fact]
6-
publicvoidIsValidSudoku_ValidBoard(){
7-
varsolution=newSolution();
8-
varboard=newchar[][]{
9-
newchar[]{'5','3','.','.','7','.','.','.','.'},
10-
newchar[]{'6','.','.','1','9','5','.','.','.'},
11-
newchar[]{'.','9','8','.','.','.','.','6','.'},
12-
newchar[]{'8','.','.','.','6','.','.','.','3'},
13-
newchar[]{'4','.','.','8','.','3','.','.','1'},
14-
newchar[]{'7','.','.','.','2','.','.','.','6'},
15-
newchar[]{'.','6','.','.','.','.','2','8','.'},
16-
newchar[]{'.','.','.','4','1','9','.','.','5'},
17-
newchar[]{'.','.','.','.','8','.','.','7','9'}
18-
};
19-
Assert.True(solution.IsValidSudoku(board));
20-
}
5+
publicclassSolutionTest{
6+
[Fact]
7+
publicvoidIsValidSudoku(){
8+
varsolution=newSolution();
9+
varboard=newchar[][]{
10+
newchar[]{'5','3','.','.','7','.','.','.','.'},
11+
newchar[]{'6','.','.','1','9','5','.','.','.'},
12+
newchar[]{'.','9','8','.','.','.','.','6','.'},
13+
newchar[]{'8','.','.','.','6','.','.','.','3'},
14+
newchar[]{'4','.','.','8','.','3','.','.','1'},
15+
newchar[]{'7','.','.','.','2','.','.','.','6'},
16+
newchar[]{'.','6','.','.','.','.','2','8','.'},
17+
newchar[]{'.','.','.','4','1','9','.','.','5'},
18+
newchar[]{'.','.','.','.','8','.','.','7','9'}
19+
};
20+
Assert.True(solution.IsValidSudoku(board));
21+
}
2122

22-
[Fact]
23-
publicvoidIsValidSudoku_InvalidBoard(){
24-
varsolution=newSolution();
25-
varboard=newchar[][]{
26-
newchar[]{'8','3','.','.','7','.','.','.','.'},
27-
newchar[]{'6','.','.','1','9','5','.','.','.'},
28-
newchar[]{'.','9','8','.','.','.','.','6','.'},
29-
newchar[]{'8','.','.','.','6','.','.','.','3'},
30-
newchar[]{'4','.','.','8','.','3','.','.','1'},
31-
newchar[]{'7','.','.','.','2','.','.','.','6'},
32-
newchar[]{'.','6','.','.','.','.','2','8','.'},
33-
newchar[]{'.','.','.','4','1','9','.','.','5'},
34-
newchar[]{'.','.','.','.','8','.','.','7','9'}
35-
};
36-
Assert.False(solution.IsValidSudoku(board));
37-
}
23+
[Fact]
24+
publicvoidIsValidSudoku2(){
25+
varsolution=newSolution();
26+
varboard=newchar[][]{
27+
newchar[]{'8','3','.','.','7','.','.','.','.'},
28+
newchar[]{'6','.','.','1','9','5','.','.','.'},
29+
newchar[]{'.','9','8','.','.','.','.','6','.'},
30+
newchar[]{'8','.','.','.','6','.','.','.','3'},
31+
newchar[]{'4','.','.','8','.','3','.','.','1'},
32+
newchar[]{'7','.','.','.','2','.','.','.','6'},
33+
newchar[]{'.','6','.','.','.','.','2','8','.'},
34+
newchar[]{'.','.','.','4','1','9','.','.','5'},
35+
newchar[]{'.','.','.','.','8','.','.','7','9'}
36+
};
37+
Assert.False(solution.IsValidSudoku(board));
3838
}
3939
}
40+
}

‎LeetCodeNet.Tests/G0001_0100/S0048_rotate_image/SolutionTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,15 @@ public void Rotate() {
1010
newSolution().Rotate(input);
1111
Assert.Equal(exected,input);
1212
}
13+
14+
[Fact]
15+
publicvoidRotate2(){
16+
varinput=newint[][]{newint[]{5,1,9,11},newint[]{2,4,8,10},newint[]{13,3,6,7},
17+
newint[]{15,14,12,16}};
18+
varexected=newint[][]{newint[]{15,13,2,5},newint[]{14,3,4,1},newint[]{12,6,8,9},
19+
newint[]{16,7,10,11}};
20+
newSolution().Rotate(input);
21+
Assert.Equal(exected,input);
22+
}
1323
}
1424
}
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1+
namespaceLeetCodeNet.G0001_0100.S0050_powx_n{
2+
13
usingXunit;
24

3-
namespaceLeetCodeNet.G0001_0100.S0050_powx_n{
4-
publicclassSolutionTest{
5-
[Fact]
6-
publicvoidMyPow_PositiveExponent(){
7-
Assert.True(System.Math.Abs(newSolution().MyPow(2.0,10)-1024.0)<1e-5);
8-
}
5+
publicclassSolutionTest{
6+
[Fact]
7+
publicvoidMyPow(){
8+
Assert.True(System.Math.Abs(newSolution().MyPow(2.0,10)-1024.0)<1e-5);
9+
}
910

10-
[Fact]
11-
publicvoidMyPow_DecimalBase(){
12-
Assert.True(System.Math.Abs(newSolution().MyPow(2.1,3)-9.261)<1e-5);
13-
}
11+
[Fact]
12+
publicvoidMyPow2(){
13+
Assert.True(System.Math.Abs(newSolution().MyPow(2.1,3)-9.261)<1e-5);
14+
}
1415

15-
[Fact]
16-
publicvoidMyPow_NegativeExponent(){
17-
Assert.True(System.Math.Abs(newSolution().MyPow(2.0,-2)-0.25)<1e-5);
18-
}
16+
[Fact]
17+
publicvoidMyPow3(){
18+
Assert.True(System.Math.Abs(newSolution().MyPow(2.0,-2)-0.25)<1e-5);
19+
}
1920

20-
[Fact]
21-
publicvoidMyPow_ZeroExponent(){
22-
Assert.True(System.Math.Abs(newSolution().MyPow(1.0,0)-1.0)<1e-5);
23-
}
21+
[Fact]
22+
publicvoidMyPow4(){
23+
Assert.True(System.Math.Abs(newSolution().MyPow(1.0,0)-1.0)<1e-5);
24+
}
2425

25-
[Fact]
26-
publicvoidMyPow_NegativeBase(){
27-
Assert.True(System.Math.Abs(newSolution().MyPow(-1.0,1)-(-1.0))<1e-5);
28-
}
26+
[Fact]
27+
publicvoidMyPow5(){
28+
Assert.True(System.Math.Abs(newSolution().MyPow(-1.0,1)-(-1.0))<1e-5);
2929
}
3030
}
31+
}
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1+
namespaceLeetCodeNet.G0001_0100.S0052_n_queens_ii{
2+
13
usingXunit;
24

3-
namespaceLeetCodeNet.G0001_0100.S0052_n_queens_ii{
4-
publicclassSolutionTest{
5-
[Fact]
6-
publicvoidTotalNQueens_1(){
7-
Assert.Equal(1,newSolution().TotalNQueens(1));
8-
}
5+
publicclassSolutionTest{
6+
[Fact]
7+
publicvoidTotalNQueens(){
8+
Assert.Equal(1,newSolution().TotalNQueens(1));
9+
}
910

10-
[Fact]
11-
publicvoidTotalNQueens_4(){
12-
Assert.Equal(2,newSolution().TotalNQueens(4));
13-
}
11+
[Fact]
12+
publicvoidTotalNQueens2(){
13+
Assert.Equal(2,newSolution().TotalNQueens(4));
14+
}
1415

15-
[Fact]
16-
publicvoidTotalNQueens_5(){
17-
Assert.Equal(10,newSolution().TotalNQueens(5));
18-
}
16+
[Fact]
17+
publicvoidTotalNQueens3(){
18+
Assert.Equal(10,newSolution().TotalNQueens(5));
19+
}
1920

20-
[Fact]
21-
publicvoidTotalNQueens_8(){
22-
Assert.Equal(92,newSolution().TotalNQueens(8));
23-
}
21+
[Fact]
22+
publicvoidTotalNQueens4(){
23+
Assert.Equal(92,newSolution().TotalNQueens(8));
2424
}
2525
}
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp