-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_test.go
54 lines (47 loc) · 1.35 KB
/
func_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
package main
import "testing"
import "strings"
import "fmt"
// Input mimik a csv Exel file.
var Input = `num point;x;y;z
5;793964,82;87556,226;210,6
`
func TestFixStringLen(t *testing.T) {
const in, out, len = "4", "0004", 4
if x := FixStringLen(in, len); x != out {
t.Errorf("FixStringLen((%v, %v) = %v, want %v", in, len, x, out)
}
}
func TestFixStringLen2(t *testing.T) {
const in, out, len = "4", "0000000000000004", 16
if x := FixStringLen(in, len); x != out {
t.Errorf("FixStringLen((%v, %v) = %v, want %v", in, len, x, out)
}
}
func TestFixLen(t *testing.T) {
const in, out, len = 12, "0000000000000012", 16
if x := FixLen(in, len); x != out {
t.Errorf("FixLen((%v, %v) = %v, want %v", in, len, x, out)
}
}
func TestRemoveComa(t *testing.T) {
var ReadInput = strings.NewReader(Input)
r := ExelCsvNewReader(ReadInput)
rout, err := r.ReadAll()
if err != nil { // check for error
fmt.Println(err)
}
for ligne, tt := range rout {
if ligne != 0 { // ignore first line
if x := RemoveComa(tt[1:2]); x != "793964820" {
t.Errorf("RemoveComa((%v) = %v, want %v", tt[1:2], x, "793964820")
}
if x := RemoveComa(tt[2:3]); x != "87556226" {
t.Errorf("RemoveComa((%v) = %v, want %v", tt[2:3], x, "87556226")
}
if x := RemoveComa(tt[3:4]); x != "210600" {
t.Errorf("RemoveComa((%v) = %v, want %v", tt[3:4], x, "210600")
}
}
}
}