diff options
| author | Eyal Posener <[email protected]> | 2019-11-22 14:58:47 +0200 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2019-11-22 15:01:47 +0200 |
| commit | a48bf3f8566559660c11fa0f08a09914a37214f1 (patch) | |
| tree | 6600827ee13af81816009f701808c17010649f0a /predict/options.go | |
| parent | 0f93c0740cb6ed49e04cc32292dc554b9b129a6f (diff) | |
Options: add tests
Diffstat (limited to 'predict/options.go')
| -rw-r--r-- | predict/options.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/predict/options.go b/predict/options.go index 1c34feb..8d88b54 100644 --- a/predict/options.go +++ b/predict/options.go @@ -23,12 +23,22 @@ func OptValues(values ...string) Option { // OptPredictor allows to set a custom predictor. func OptPredictor(p complete.Predictor) Option { - return func(o *Config) { o.Predictor = p } + return func(o *Config) { + if o.Predictor != nil { + panic("predictor set more than once.") + } + o.Predictor = p + } } // OptCheck enforces the valid values on the predicted flag. func OptCheck() Option { - return func(o *Config) { o.check = true } + return func(o *Config) { + if o.check { + panic("check set more than once") + } + o.check = true + } } type Config struct { |
