Skip to content

Commit

Permalink
fmt, radian
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Oct 29, 2015
1 parent 7f8b46a commit 520f5e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fmt_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gocat

import (
"fmt"
"github.com/stretchr/testify/assert"
"math"
"testing"
)

func TestFormatted(t *testing.T) {
assert.Equal(t, "3.14", fmt.Sprintf("%.2f", math.Pi))
}
20 changes: 20 additions & 0 deletions math_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gocat

import (
"github.com/stretchr/testify/assert"
"math"
"testing"
)

func deg_to_rad(deg float64) float64 {
return (deg * math.Pi / 180)
}

func rad_to_deg(rad float64) float64 {
return (rad * 180 / math.Pi)
}

func TestRadian(t *testing.T) {
assert.Equal(t, math.Pi, deg_to_rad(180))
assert.Equal(t, 180.0, rad_to_deg(math.Pi))
}

0 comments on commit 520f5e6

Please sign in to comment.