diff options
Diffstat (limited to 'xmpp/component_test.go')
-rw-r--r-- | xmpp/component_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xmpp/component_test.go b/xmpp/component_test.go new file mode 100644 index 0000000..7e7e5e7 --- /dev/null +++ b/xmpp/component_test.go @@ -0,0 +1,47 @@ +package xmpp + +import ( + "testing" +) + +func TestParseSizeGarbage(t *testing.T) { + _, err := parseSize("abc") + if err == nil { + t.Error("abc should not be accepted") + } +} + +func TestParseSizeAsphalt(t *testing.T) { + size, err := parseSize("2B") + if size != 2 { + t.Errorf("Error parsing two bytes: %v %v", size, err) + } +} + +func TestParseSize9K(t *testing.T) { + size, err := parseSize("9 KB") + if size != 9216 { + t.Errorf("Error parsing 9K: %v %v", size, err) + } +} + +func TestParseSizeBits(t *testing.T) { + size, err := parseSize("9 Kb") + if err == nil { + t.Errorf("Error parsing kilobits: %v %v", size, err) + } +} + +func TestParseSizeEB(t *testing.T) { + size, err := parseSize("3EB") + if size != 3458764513820540928 { + t.Errorf("Error parsing exabytes: %v %v", size, err) + } +} + +func TestParseSizeOverflow(t *testing.T) { + size, err := parseSize("314EB") + if err == nil { + t.Errorf("Overflow is not overflowing: %v %v", size, err) + } +} |