pdqhash-go

git clone git://archive.git.mtrnord.blog/MTRNord/pdqhash-go.git
Log | Files | Refs | LICENSE

helpers_test.go (691B)


      1 package helpers
      2 
      3 import (
      4 	"testing"
      5 
      6 	"github.com/stretchr/testify/assert"
      7 )
      8 
      9 func TestTorben(t *testing.T) {
     10 	numRows := 4
     11 	numCols := 8
     12 	m := make([][]float64, numRows)
     13 	for i := range m {
     14 		m[i] = make([]float64, numCols)
     15 		for j := 0; j < numCols; j++ {
     16 			m[i][j] = float64(i) + (float64(j) * 0.01)
     17 		}
     18 	}
     19 
     20 	assert.Equal(t, float64(1.07), Torben(m, numRows, numCols), "The Torben function should produce 1.07 for 3 rows and 8 cols")
     21 }
     22 
     23 func TestAbs(t *testing.T) {
     24 	assert.Equal(t, int(1), Abs(-1), "The absolute value of -1 should be 1")
     25 	assert.Equal(t, int(1), Abs(1), "The absolute value of 1 should be 1")
     26 	assert.Equal(t, int(0), Abs(0), "The absolute value of 0 should be 0")
     27 }