test

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestBinaryMarshaler

func TestBinaryMarshaler[K interface {
	kad.Key[K]
	MarshalBinary() ([]byte, error)
}](t *testing.T, k K, newFunc func([]byte) K,
)

TestBinaryMarshaler tests the behaviour of a kad.Key implementation that also implements the BinaryMarshaler interface

Types

type KeyTester

type KeyTester[K kad.Key[K]] struct {
	// Key 0 is zero
	Key0 K

	// Key1 is Key0 + 1 (00000...001)
	Key1 K

	// Key2 is Key0 + 2 (00000...010)
	Key2 K

	// Key1xor2 is Key1 ^ Key2 (00000...011)
	Key1xor2 K

	// Key100 is Key0 with the most significant bit set (10000...000)
	Key100 K

	// Key010 is Key0 with the second most significant bit set (01000...000)
	Key010 K

	// KeyX is a random key
	KeyX K
}

KeyTester tests a kad.Key's implementation

func (*KeyTester[K]) RunTests

func (kt *KeyTester[K]) RunTests(t *testing.T)

func (*KeyTester[K]) TestBit

func (kt *KeyTester[K]) TestBit(t *testing.T)

func (*KeyTester[K]) TestBitString

func (kt *KeyTester[K]) TestBitString(t *testing.T)

func (*KeyTester[K]) TestCommonPrefixLength

func (kt *KeyTester[K]) TestCommonPrefixLength(t *testing.T)

func (*KeyTester[K]) TestCompare

func (kt *KeyTester[K]) TestCompare(t *testing.T)

func (*KeyTester[K]) TestHexString

func (kt *KeyTester[K]) TestHexString(t *testing.T)

func (*KeyTester[K]) TestXor

func (kt *KeyTester[K]) TestXor(t *testing.T)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL