if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pg != 0
}
- return IsOneOf(GraphicRanges, r)
+ return In(r, GraphicRanges...)
}
// IsPrint reports whether the rune is defined as printable by Go. Such
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pp != 0
}
- return IsOneOf(PrintRanges, r)
+ return In(r, PrintRanges...)
}
// IsOneOf reports whether the rune is a member of one of the ranges.
-func IsOneOf(set []*RangeTable, r rune) bool {
- for _, inside := range set {
+// The function "In" provides a nicer signature and should be used in preference to IsOneOf.
+func IsOneOf(ranges []*RangeTable, r rune) bool {
+ for _, inside := range ranges {
+ if Is(inside, r) {
+ return true
+ }
+ }
+ return false
+}
+
+// In reports whether the rune is a member of one of the ranges.
+func In(r rune, ranges ...*RangeTable) bool {
+ for _, inside := range ranges {
if Is(inside, r) {
return true
}
func TestIsPrintLatin1(t *testing.T) {
for i := rune(0); i <= MaxLatin1; i++ {
got := IsPrint(i)
- want := IsOneOf(PrintRanges, i)
+ want := In(i, PrintRanges...)
if i == ' ' {
want = true
}
func TestIsGraphicLatin1(t *testing.T) {
for i := rune(0); i <= MaxLatin1; i++ {
got := IsGraphic(i)
- want := IsOneOf(GraphicRanges, i)
+ want := In(i, GraphicRanges...)
if got != want {
t.Errorf("%U incorrect: got %t; want %t", i, got, want)
}