github.com/wuhuizuo/gomplate@v3.5.0+incompatible/tests/integration/math_test.go (about)

     1  //+build integration
     2  
     3  package integration
     4  
     5  import (
     6  	. "gopkg.in/check.v1"
     7  )
     8  
     9  type MathSuite struct{}
    10  
    11  var _ = Suite(&MathSuite{})
    12  
    13  func (s *MathSuite) TestMath(c *C) {
    14  	inOutTest(c, `{{ math.Add 1 2 3 4 }} {{ add -5 5 }}`, "10 0")
    15  	inOutTest(c, `{{ math.Sub 10 5 }} {{ sub -5 5 }}`, "5 -10")
    16  	inOutTest(c, `{{ math.Mul 1 2 3 4 }} {{ mul -5 5 }}`, "24 -25")
    17  	inOutTest(c, `{{ math.Div 5 2 }} {{ div -5 5 }}`, "2.5 -1")
    18  	inOutTest(c, `{{ math.Rem 5 3 }} {{ rem 2 2 }}`, "2 0")
    19  	inOutTest(c, `{{ math.Pow 8 4 }} {{ pow 2 2 }}`, "4096 4")
    20  	inOutTest(c, `{{ math.Seq 0 }}, {{ seq 0 3 }}, {{ seq -5 -10 2 }}`,
    21  		`[1 0], [0 1 2 3], [-5 -7 -9]`)
    22  	inOutTest(c, `{{ math.Round 0.99 }}, {{ math.Round "foo" }}, {{math.Round 3.5}}`,
    23  		`1, 0, 4`)
    24  	inOutTest(c, `{{ math.Max -0 "+Inf" "NaN" }}, {{ math.Max 3.4 3.401 3.399 }}`,
    25  		`+Inf, 3.401`)
    26  }