-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_test.go
41 lines (32 loc) · 907 Bytes
/
types_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
//
// Copyright (C) 2024 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
// https://github.com/kshard/vector
//
package vector_test
import (
"testing"
"github.com/kshard/vector"
"github.com/kshard/vector/internal/pure"
"github.com/kshard/vector/internal/vtest"
)
type Node struct {
ID int
Vector vector.F32
}
func ntov(n Node) []float32 { return n.Vector }
func TestContraMap(t *testing.T) {
node := func(f []float32) Node { return Node{Vector: f} }
ref := vector.ContraMap[vector.F32, Node]{
Surface: pure.Euclidean(0),
ContraMap: func(n Node) []float32 { return n.Vector },
}
sut := vector.ContraMap[vector.F32, Node]{
Surface: vector.Euclidean(),
ContraMap: func(n Node) []float32 { return n.Vector },
}
vtest.TestEqual(t, node, sut)
vtest.TestDistance(t, node, ref, sut)
}