Пример #1
0
func TestTime(t *testing.T) {
	config := gojudge.GetLanguageConfig("Python")
	gojudge.Run(config.Time, config.Memory, config.Compile, config.Run, config.FilePlaceholder, "scripts/time.py")
	out, err := ioutil.ReadFile("out.txt")
	if err != nil {
		t.Error("failed to open output file")
	}
	if string(out) == "Done!\n" {
		t.Error("failed to limit time")
	}
}
Пример #2
0
func TestSum(t *testing.T) {
	config := gojudge.GetLanguageConfig("Python")
	in, err := os.Create("in.txt")
	if err != nil {
		t.Error("failed to create input file")
	}
	_, err = in.WriteString("2\n3\n")
	if err != nil {
		t.Error("failed to write input file")
	}
	in.Sync()
	in.Close()
	gojudge.Run(config.Time, config.Memory, config.Compile, config.Run, config.FilePlaceholder, "scripts/sum.py")
	out, err := ioutil.ReadFile("out.txt")
	if err != nil {
		t.Error("failed to open output file")
	}
	if string(out) != "5\n" {
		t.Error("failed to compute the sum")
	}
}