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-20 22:54:46 +00:00
|
|
|
NotTested Result = 0 // change only with schema change
|
|
|
|
Accepted Result = 1
|
|
|
|
CompilationError Result = 2
|
|
|
|
MemoryLimitExceeded Result = 3
|
|
|
|
TimeLimitExceeded Result = 4
|
2024-08-25 17:57:40 +00:00
|
|
|
RuntimeError Result = 5
|
|
|
|
SystemFailDuringTesting Result = 6
|
|
|
|
Testing Result = 7
|
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
|
|
|
}
|