aboutsummaryrefslogtreecommitdiff
path: root/xmpp/component_test.go
blob: 7e7e5e7fdcd3b08b80ddc877a51e049036bfc38c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
	}
}