File: fastlog_test.go

package info (click to toggle)
golang-github-go-enry-go-license-detector 4.3.0%2Bgit20221007.a3a1cc6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,068 kB
  • sloc: makefile: 25
file content (24 lines) | stat: -rw-r--r-- 441 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package fastlog

import (
	"math"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestFastlog(t *testing.T) {
	tests := []float32{
		0.1, 0.5, 0.9, 1.0, 1.1, 2.0, 2.718281828, 3.0, 4.0,
		10.0, 20.0, 100.0, 500.0, 1000.0,
	}
	for _, v := range tests {
		flog := Log(v)
		plog := float32(math.Log(float64(v)))
		if plog != 0 {
			assert.InEpsilon(t, plog, flog, 0.002)
		} else {
			assert.InDelta(t, plog, flog, 0.000002)
		}
	}
}