mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-05-20 13:48:02 -04:00
3aa5885ebe
curated package predated the standard errors package introduced in go1.13 the standard package does a better job of what curated attempted to do the change of package also gave me a opportunity to clean up the error messages a little bit
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
// This file is part of Gopher2600.
|
|
//
|
|
// Gopher2600 is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Gopher2600 is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package regression
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Indicates the State recording method to use.
|
|
type StateType string
|
|
|
|
// List of valid StateType values.
|
|
const (
|
|
StateNone StateType = ""
|
|
StateTV StateType = "TV"
|
|
StatePorts StateType = "PORTS"
|
|
StateTimer StateType = "TIMER"
|
|
StateCPU StateType = "CPU"
|
|
)
|
|
|
|
// NewStateType parses a string and returns a new StateType or an error. Use
|
|
// this rather than casting a string to the StateType.
|
|
func NewStateType(state string) (StateType, error) {
|
|
switch strings.ToUpper(state) {
|
|
case "":
|
|
return StateNone, nil
|
|
case "TV":
|
|
return StateTV, nil
|
|
case "PORTS":
|
|
return StatePorts, nil
|
|
case "TIMER":
|
|
return StateTimer, nil
|
|
case "CPU":
|
|
return StateCPU, nil
|
|
}
|
|
return StateNone, fmt.Errorf("regression: video: unrecognised state type [%s]", state)
|
|
}
|
|
|
|
func (t StateType) String() string {
|
|
return string(t)
|
|
}
|