Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statements & Testing modules added + little additions to .gitignore(.idea added) #3

Merged
merged 6 commits into from
Dec 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions modules/10-basics/40-testing/Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import java.io.BufferedReader
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets
import java.util.stream.Collectors

fun main() {
val expected = 420262531

val p = Runtime.getRuntime().exec("kotlin -classpath Main.jar MainKt")
p.waitFor()
val input = BufferedReader(
InputStreamReader(p.inputStream, StandardCharsets.UTF_8)
)
.lines()
.collect(Collectors.joining("\n"))
val error = BufferedReader(
InputStreamReader(p.errorStream, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"))

println(input)

if (!expected.equals(input) || error.isNotBlank()) {
println("Test(statements): ERROR")
throw Exception(
"Expected: "
+ expected
+ ", but got: "
+ input
+ "\n"
+ error
)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Настрой плз редактор, чтобы он вставлял перенос строки в конце файлов =)