-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
73 lines (61 loc) · 1.3 KB
/
Copy pathmain_test.go
File metadata and controls
73 lines (61 loc) · 1.3 KB
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
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
"testing"
)
func TestCallOutput(t *testing.T) {
resultsLimit = 25
sortKey = "calls"
f, _ := os.Open("test.xt")
reader := bufio.NewReader(f)
funcs := parse(reader, "calls")
sort.Sort(FunctionList(funcs))
writeToStdout(funcs)
}
func TestXxx(t *testing.T) {
num := fmt.Sprintf("%f", float64(1.225788)-float64(1.225784)) // 4e-06
f, _ := strconv.ParseFloat(num, 64)
if f == 0.000004 {
t.Log("Success")
} else {
//How come I don't get 0.000004
t.Error("Not Equal", num)
}
if getFloat(f) == 0.000004 {
t.Log("Success")
} else {
t.Error("Fail", getFloat(f))
}
}
func TestParseIntFromStringWithNewline(t *testing.T) {
value, _ := strconv.ParseInt(strings.Trim(`3375160
`, ""), 10, 64)
if value == 3375160 {
t.Log("Success")
} else {
t.Error("Failed to Convert string to integer", value)
}
}
func TestParseFloatFromStringWithPadding(t *testing.T) {
str := "1.225800"
num, _ := strconv.ParseFloat(str, 64)
if num == 1.225800 {
t.Log("Success")
} else {
t.Error("Invalid COnversion", num)
}
}
func TestSliceCut(t *testing.T) {
a := []string{"Alex", "Samson", "Leon", "Hamida"}
//a = append(a[:3], a[2:]...)
fmt.Println(a[0:2])
}
func getFloat(f float64) float64 {
//fmt.Println("My Float:", f)
return f
}