-
Notifications
You must be signed in to change notification settings - Fork 2
/
exp_test.go
78 lines (67 loc) · 2.42 KB
/
exp_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
75
76
77
78
package functions_for_govaluate_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/jamillosantos/functions-for-govaluate"
"math"
)
var _ = Describe("exp functions", func() {
Describe("exp", func() {
It("should get correct value with a float param", func() {
c, err := functions_for_govaluate.Exp(0.1363122)
Expect(err).To(BeNil())
Expect(c).To(Equal(math.Exp(0.1363122)))
})
It("should get correct value with an integer param", func() {
c, err := functions_for_govaluate.Exp(3)
Expect(err).To(BeNil())
Expect(c).To(Equal(math.Exp(3)))
})
It("should return an param wrong type error", func() {
_, err := functions_for_govaluate.Exp("invalid param value")
Expect(err).NotTo(BeNil())
Expect(functions_for_govaluate.IsWrongParamType(err)).To(BeTrue())
})
It("should get an wrong param count error (too few arguments)", func() {
c, err := functions_for_govaluate.Exp()
Expect(c).To(BeNil())
Expect(functions_for_govaluate.IsWrongParamsCount(err)).To(BeTrue())
Expect(err).NotTo(BeNil())
})
It("should get an wrong param count error (too many arguments)", func() {
c, err := functions_for_govaluate.Exp(1, 2)
Expect(c).To(BeNil())
Expect(functions_for_govaluate.IsWrongParamsCount(err)).To(BeTrue())
Expect(err).NotTo(BeNil())
})
})
Describe("exp2", func() {
It("should get correct value with a float param", func() {
c, err := functions_for_govaluate.Exp2(0.1363122)
Expect(err).To(BeNil())
Expect(c).To(Equal(math.Exp2(0.1363122)))
})
It("should get correct value with an integer param", func() {
c, err := functions_for_govaluate.Exp2(1)
Expect(err).To(BeNil())
Expect(c).To(Equal(math.Exp2(1)))
})
It("should return an param wrong type error", func() {
_, err := functions_for_govaluate.Exp2("invalid param value")
Expect(err).NotTo(BeNil())
Expect(functions_for_govaluate.IsWrongParamType(err)).To(BeTrue())
})
It("should get an wrong param count error (too few arguments)", func() {
c, err := functions_for_govaluate.Exp2()
Expect(c).To(BeNil())
Expect(functions_for_govaluate.IsWrongParamsCount(err)).To(BeTrue())
Expect(err).NotTo(BeNil())
})
It("should get an wrong param count error (too many arguments)", func() {
c, err := functions_for_govaluate.Exp2(1, 2)
Expect(c).To(BeNil())
Expect(functions_for_govaluate.IsWrongParamsCount(err)).To(BeTrue())
Expect(err).NotTo(BeNil())
})
})
})