Files
judge/example/showcase/03-matchers.jdg

70 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Все способы сматчить stdout/stderr: exact, contains, regex, anyOrder,
// numeric-eps. Плюс случай, когда сравнение вывода вообще не нужно
// (достаточно exitCode).
toolchains {
gcc { platforms = "linux" }
}
build "release" {
language = "c"
standard = "c11"
sources = "solution.c"
output = "solution"
profile = release
}
group("matchers") {
weight = 1.0
// Точное совпадение (по умолчанию). Пробелы, переводы строк и
// регистр важны. Нормализация CRLF / trim_ws настраивается на
// уровне файла.
test("exact") {
stdin = "42\n"
stdout = "42\n"
}
// Подстрока в любом месте вывода.
test("contains") {
stdin = "log me\n"
stdout contains "log me"
}
// Регулярное выражение (Go regexp syntax).
test("regex") {
stdin = "7\n"
stdout matches "^result:\\s+[0-9]+\\s*$"
}
// Лайны могут прийти в любом порядке — полезно для stress-тестов
// с параллельным выводом.
test("any-order") {
stdin = "start\n"
stdout anyOrder {
"alpha"
"beta"
"gamma"
}
}
// Числовое сравнение с epsilon — для задач с плавающей точкой.
// Синтаксис: ~ <float> of "<ожидаемое значение как строка>"
test("numeric") {
stdin = "3.14159\n"
stdout ~ 0.0001 of "3.14159\n"
}
// Проверяем только stderr; stdout не трогаем вообще (NoMatcher).
test("stderr-only") {
args = "--version"
stderr contains "version 1."
}
// Никакого матчинга вывода — нас интересует только exit code.
test("exit-code-only") {
args = "--help"
exitCode = 0
}
}