-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* flatten-array: add generator * connect: add generator * Remove old * sgf-parsing: add generator * linked-list: add generator * binary-search-tree: add generator * Remove [no important files changed]
- Loading branch information
1 parent
cde0f16
commit 5c937a9
Showing
16 changed files
with
319 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{ func assertions(node, path) | ||
checks = [$"Assert.Equal({string.to_int node.data}, tree.{path}Value);"] | ||
if node.left | ||
checks = array.add_range checks (assertions node.left (path + "Left.")) | ||
end | ||
if node.right | ||
checks = array.add_range checks (assertions node.right (path + "Right.")) | ||
end | ||
ret checks | ||
end }} | ||
|
||
using System.Linq; | ||
using Xunit; | ||
|
||
public class {{ testClass }} | ||
{ | ||
{{- for test in tests }} | ||
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}] | ||
public void {{ test.testMethod }}() | ||
{ | ||
{{- if test.input.treeData | array.size == 1 }} | ||
var tree = new {{ testedClass }}({{ test.input.treeData[0] | @string.to_int }}); | ||
{{- else -}} | ||
var tree = new {{ testedClass }}(new[] { {{ test.input.treeData | array.each @string.to_int | array.join "," }} }); | ||
{{- end -}} | ||
{{- if test.property == "data" }} | ||
{{ test.expected | assertions "" | array.join "\n" }} | ||
{{- else }} | ||
int[] expected = {{ test.expected | array.each @string.to_int }}; | ||
Assert.Equal(expected, tree.AsEnumerable()); | ||
{{ end -}} | ||
} | ||
{{ end -}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{ func color | ||
case $0 | ||
when "X" | ||
ret "Black" | ||
when "O" | ||
ret "White" | ||
else | ||
ret "None" | ||
end | ||
end }} | ||
|
||
using Xunit; | ||
|
||
public class {{ testClass }} | ||
{ | ||
{{- for test in tests }} | ||
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}] | ||
public void {{ test.testMethod }}() | ||
{ | ||
string[] board = [ | ||
{{- for line in test.input.board }} | ||
{{ line | string.literal }}{{- if !for.last }},{{ end -}} | ||
{{ end }} | ||
]; | ||
var sut = new {{ testedClass }}(board); | ||
Assert.Equal({{ test.expected | color | enum "ConnectWinner" }}, sut.Result()); | ||
} | ||
{{ end -}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ func toarg(input) | ||
case (object.typeof input) | ||
when "array" | ||
if input.empty? | ||
ret "Array.Empty<object>()" | ||
else | ||
elements = array.join (array.each input @toarg) ", " | ||
ret "new object[] { " + elements + " }" | ||
end | ||
else | ||
if input | ||
ret input | ||
else | ||
ret "null" | ||
end | ||
end | ||
end }} | ||
|
||
using System; | ||
using Xunit; | ||
|
||
public class {{ testClass }} | ||
{ | ||
{{- for test in tests }} | ||
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}] | ||
public void {{ test.testMethod }}() | ||
{ | ||
{{- if test.input.array.empty? }} | ||
var array = Array.Empty<object>(); | ||
Assert.Empty({{ testedClass }}.{{ test.testedMethod }}(array)); | ||
{{- else }} | ||
object[] array = {{ test.input.array | toarg }}; | ||
object[] expected = {{ test.expected }}; | ||
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}(array)); | ||
{{ end -}} | ||
} | ||
{{ end -}} | ||
} |
Oops, something went wrong.