ms-tester/pkg/models/result.go

32 lines
824 B
Go
Raw Normal View History

2024-08-17 12:23:35 +00:00
package models
2024-08-22 23:02:14 +00:00
import (
"errors"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
)
2024-08-17 12:23:35 +00:00
type Result int32
const (
2024-08-25 18:17:47 +00:00
NotTested Result = 1 // change only with schema change
Accepted Result = 2
WrongAnswer Result = 3
PresentationError Result = 4
CompilationError Result = 5
MemoryLimitExceeded Result = 6
TimeLimitExceeded Result = 7
RuntimeError Result = 8
SystemFailDuringTesting Result = 9
Testing Result = 10
2024-08-17 12:23:35 +00:00
)
2024-08-22 23:02:14 +00:00
var ErrBadResult = errors.New("bad result")
2024-08-17 12:23:35 +00:00
func (result Result) Valid() error {
2024-08-20 22:54:46 +00:00
switch result {
case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
return nil
}
2024-08-22 23:02:14 +00:00
return lib.ServiceError(ErrBadResult, lib.ErrValidationFailed, "bad result")
2024-08-17 12:23:35 +00:00
}