Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ploption_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ruby

import (
"reflect"
"testing"

"github.com/go-plot/plot"
)

// A parameterless option constructor is a switch: true gives the option,
// false gives no option at all (nil, nil), anything else is a TypeError.
func TestPlOptionSwitchTrueAppliesFalseDoesNot(t *testing.T) {
fn := reflect.ValueOf(plot.Density)
o, err := plOption("density", fn, true)
if err != nil || o == nil {
t.Errorf("true: option %v, err %v; want an option, nil", o != nil, err)
}
o, err = plOption("density", fn, false)
if err != nil || o != nil {
t.Errorf("false: option %v, err %v; want none, nil", o != nil, err)
}
if _, err = plOption("density", fn, 1); err == nil {
t.Error("a non-boolean switch value was accepted")
}
}
Loading