mirror of https://github.com/dsoprea/go-exif.git
parent
a1cb4443b2
commit
dca55bf8ca
|
@ -156,11 +156,11 @@ type SignedRational struct {
|
|||
}
|
||||
|
||||
func isPrintableText(s string) bool {
|
||||
|
||||
// TODO(dustin): Add text
|
||||
|
||||
for _, c := range s {
|
||||
if unicode.IsPrint(rune(c)) == false {
|
||||
// unicode.IsPrint() returns false for newline characters.
|
||||
if c == 0x0d || c == 0x0a {
|
||||
continue
|
||||
} else if unicode.IsPrint(rune(c)) == false {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -411,3 +411,27 @@ func TestTranslateStringToType__InvalidType(t *testing.T) {
|
|||
// log.Panicf("from-string encoding for type not supported; this shouldn't happen: [%s]", tagType.String())
|
||||
// return nil, nil
|
||||
// }
|
||||
|
||||
func TestIsPrintableText_letters(t *testing.T) {
|
||||
if isPrintableText("abc") != true {
|
||||
t.Fatalf("Printable text interpreted as nonprintable.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsPrintableText_space(t *testing.T) {
|
||||
if isPrintableText(" ") != true {
|
||||
t.Fatalf("Printable text interpreted as nonprintable.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsPrintableText_newlines(t *testing.T) {
|
||||
if isPrintableText("\r\n") != true {
|
||||
t.Fatalf("Printable text interpreted as nonprintable.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsPrintableText_punctuationAndSymbols(t *testing.T) {
|
||||
if isPrintableText(",:-/$©") != true {
|
||||
t.Fatalf("Printable text interpreted as nonprintable.")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue