func TestImpliedMaximumRange(t *testing.T) {
	var r *Range
	var err error
	rangeStr := "10:"
	r, err = ParseRange(rangeStr)
	if err != nil {
		t.Fatalf("Failed to parse %v: %v", rangeStr, err)
	}
	tests := []struct {
		value       float64
		shouldAlert bool
	}{
		{-1.0, true},
		{0.0, true},
		{1.0, true},
		{5.0, true},
		{10.0, false},
		{11.0, false},
	}
	for _, test := range tests {
		didAlert := r.Check(test.value)
		if didAlert != test.shouldAlert {
			t.Errorf("Check(%v) should be %v", test.value, test.shouldAlert)
		}
	}
}
TestImpliedMaximumRange ensures that a range string with no explicit
maximum defaults to a maximum of +Inf.
package nagiosplugin
import (
	"testing"
)
func TestInsideRange(t *testing.T) {
	var r *Range
	var err error
	rangeStr := "10:20"
	r, err = ParseRange(rangeStr)
	if err != nil {
		t.Fatalf("Failed to parse %v: %v", rangeStr, err)
	}
	tests := []struct {
		value       float64
		shouldAlert bool
	}{
		{-1.0, true},
		{0.0, true},
		{1.0, true},
		{9.0, true},
		{10.0, false},
		{15.0, false},
		{20.0, false},
		{21.0, true},
	}
	for _, test := range tests {
		didAlert := r.Check(test.value)
		if didAlert != test.shouldAlert {
			t.Errorf("Check(%v) should be %v", test.value, test.shouldAlert)
		}
	}
}
func TestOutsideRange(t *testing.T) {
	var r *Range
	var err error
	rangeStr := "@10:20"
	r, err = ParseRange(rangeStr)
	if err != nil {
		t.Fatalf("Failed to parse %v: %v", rangeStr, err)
	}
	tests := []struct {
		value       float64
		shouldAlert bool
	}{
		{-1.0, false},
		{0.0, false},
		{1.0, false},
		{9.0, false},
		{10.0, true},
		{15.0, true},
		{20.0, true},
		{21.0, false},
	}
	for _, test := range tests {
		didAlert := r.Check(test.value)
		if didAlert != test.shouldAlert {
			t.Errorf("Check(%v) should be %v", test.value, test.shouldAlert)
		}
	}
}
func TestImpliedMinimumRange(t *testing.T) {
	var r *Range
	var err error
	rangeStr := "10"
	r, err = ParseRange(rangeStr)
	if err != nil {
		t.Fatalf("Failed to parse %v: %v", rangeStr, err)
	}
	tests := []struct {
		value       float64
		shouldAlert bool
	}{
		{-1.0, true},
		{0.0, false},
		{5.0, false},
		{11.0, true},
	}
	for _, test := range tests {
		didAlert := r.Check(test.value)
		if didAlert != test.shouldAlert {
			t.Errorf("Check(%v) should be %v", test.value, test.shouldAlert)
		}
	}
}