-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats_test.go
74 lines (64 loc) · 1.71 KB
/
stats_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"testing"
)
func TestIncludedFolderCount(t *testing.T) {
rs1 := resource{Dir: "/t/e/s/t/1"}
rs2 := resource{Dir: "/t/e/s/t/2"}
err1 := rs1.commit()
err2 := rs2.commit()
if err1 != nil || err2 != nil {
t.Error("invalid committed content")
} else {
defer func() {
deleteResource(rs1.Dir, rs1.ID)
deleteResource(rs2.Dir, rs2.ID)
}()
}
count, err := includedFolderCount("/t/e/s/t")
if err != nil || count != 2 {
t.Error("invalid count number")
}
}
func TestAverageWorldLength(t *testing.T) {
rs1 := resource{Dir: "/t/e/s/t/1", Content: "a"}
rs2 := resource{Dir: "/t/e/s/t/2", Content: "a b"}
rs3 := resource{Dir: "/t/e/s/t/3", Content: "a b c"}
err1 := rs1.commit()
err2 := rs2.commit()
err3 := rs3.commit()
if err1 != nil || err2 != nil || err3 != nil {
t.Error("invalid committed content")
} else {
defer func() {
deleteResource(rs1.Dir, rs1.ID)
deleteResource(rs2.Dir, rs2.ID)
deleteResource(rs3.Dir, rs3.ID)
}()
}
mean, dev, err := averageWorldLength("/t/e/s/t")
if err != nil || mean != 2 || dev != 1 {
t.Error("invalid count number")
}
}
func TestAlphanumericStatic(t *testing.T) {
rs1 := resource{Dir: "/t/e/s/t/1", Content: "a"}
rs2 := resource{Dir: "/t/e/s/t/2", Content: "a b"}
rs3 := resource{Dir: "/t/e/s/t/3", Content: "a b c"}
err1 := rs1.commit()
err2 := rs2.commit()
err3 := rs3.commit()
if err1 != nil || err2 != nil || err3 != nil {
t.Error("invalid committed content")
} else {
defer func() {
deleteResource(rs1.Dir, rs1.ID)
deleteResource(rs2.Dir, rs2.ID)
deleteResource(rs3.Dir, rs3.ID)
}()
}
mean, dev, err := alphanumericStatic("/t/e/s/t")
if err != nil || mean != 2 || dev != 1 {
t.Error("invalid committed content")
}
}