feat(runner): add the own code runner contract, client and nsjail service
This commit is contained in:
1 parent
5e1db37746
commit
cdf6bcbb91
109 files changed
+24084
-28
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package checker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCheckersCompareOutput(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
kind Kind
|
||||
expected string
|
||||
actual string
|
||||
accepted bool
|
||||
}{
|
||||
{"exact equal", Exact, "6\n", "6\n", true},
|
||||
{"exact missing final newline", Exact, "6\n", "6", true},
|
||||
{"exact CRLF and trailing spaces", Exact, "1 2\n3\n", "1 2 \r\n3\t\r\n\r\n", true},
|
||||
{"exact inner spaces matter", Exact, "1 2\n", "1 2\n", false},
|
||||
{"exact leading empty line matters", Exact, "1\n", "\n1\n", false},
|
||||
{"exact different value", Exact, "6\n", "7\n", false},
|
||||
{"exact empty output", Exact, "", "\n\n", true},
|
||||
{"tokens ignore layout", Tokens, "1 2\n3\n", "1\n2 3", true},
|
||||
{"tokens different count", Tokens, "1 2 3", "1 2", false},
|
||||
{"tokens different token", Tokens, "1 2 3", "1 2 4", false},
|
||||
{"tokens are case sensitive", Tokens, "Yes", "yes", false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
check, err := New(Spec{Kind: tc.kind})
|
||||
if err != nil {
|
||||
t.Fatalf("New: %v", err)
|
||||
}
|
||||
accepted, err := check.Check(t.Context(), Input{Expected: []byte(tc.expected), Actual: []byte(tc.actual)})
|
||||
if err != nil {
|
||||
t.Fatalf("Check: %v", err)
|
||||
}
|
||||
if accepted != tc.accepted {
|
||||
t.Fatalf("Check(%q, %q) = %v, want %v", tc.expected, tc.actual, accepted, tc.accepted)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRejectsUnknownKind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if _, err := New(Spec{Kind: "float"}); err == nil {
|
||||
t.Fatal("New accepted an unknown checker kind")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user