Skip to content

Commit 039812d

Browse files
committed
Added powershell test
1 parent c4ea3f3 commit 039812d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

cpp/test.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$run = "$PSScriptRoot\a.exe"
12+
13+
$Error.clear()
14+
g++ -std=c++20 "$PSScriptRoot\anagrams.cpp" && . $run rats |
15+
Compare-Object (Get-Content "$PSScriptRoot\..\test\rats_heap_expected") |
16+
Assert-MatchTests &&
17+
g++ -std=c++20 "$PSScriptRoot\animals.cpp" && . $run &&
18+
g++ -std=c++20 "$PSScriptRoot\basic_types.cpp" && . $run &&
19+
g++ -std=c++20 "$PSScriptRoot\if_then_else.cpp" && . $run &&
20+
g++ -std=c++20 "$PSScriptRoot\maps.cpp" && . $run &&
21+
g++ -std=c++20 "$PSScriptRoot\permutations.cpp" && . $run I like carrots |
22+
Compare-Object (Get-Content "$PSScriptRoot\..\test\carrots_expected") |
23+
Assert-MatchTests &&
24+
g++ -std=c++20 "$PSScriptRoot\smart_pointers.cpp" && . $run &&
25+
g++ -std=c++20 "$PSScriptRoot\sum_of_even_squares.cpp" && . $run &&
26+
g++ -std=c++20 "$PSScriptRoot\top_ten_scorers.cpp" && Get-Content "$PSScriptRoot\..\test\wnba_input" | . $run |
27+
Compare-Object (Get-Content "$PSScriptRoot\..\test\wnba_expected") |
28+
Assert-MatchTests &&
29+
g++ -std=c++20 "$PSScriptRoot\triple.cpp" && . $run |
30+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
31+
Assert-MatchTests &&
32+
ForEach-Object 'foo'
33+
34+
if ($Error -or !$?) {
35+
"*** C++ TESTS FAILED ***"
36+
}
37+
else {
38+
"C++ TESTS PASSED"
39+
}

0 commit comments

Comments
 (0)