testutil

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIRPattern

func CheckIRPattern(t *testing.T, ir string, pattern string)

CheckIRPattern checks IR against a pattern using regex, abstracting register names. Exported for use in external test packages.

func CompileAndGetFunction

func CompileAndGetFunction(t *testing.T, src, funcName string) *ssa.Function

CompileAndGetFunction builds SSA from source and returns the requested function. This allows low-level analysis packages to be tested in isolation.

func ComputeTopologySimilarityExported

func ComputeTopologySimilarityExported(topo *topology.FunctionTopology, sig detection.Signature) float64

ComputeTopologySimilarityExported exports the computeTopologySimilarity function for testing.

func FindResult

func FindResult(results []diff.FingerprintResult, Name string) *diff.FingerprintResult

FindResult searches for a FingerprintResult by function name. It supports both exact matches and suffix matches (e.g., "functionName" matches "pkg.functionName"). Exported for use in external test packages.

func FormatEntropyKeyExported

func FormatEntropyKeyExported(entropy float64, id string) string

FormatEntropyKeyExported exports the formatEntropyKey function for testing.

func GenerateTopologyHashExported

func GenerateTopologyHashExported(topo *topology.FunctionTopology) string

GenerateTopologyHashExported exports the generateTopologyHash function for testing.

func GetFunctionNames

func GetFunctionNames(results []diff.FingerprintResult) []string

GetFunctionNames extracts function names from results for easier verification. Exported for use in external test packages.

func MatchCallsExported

func MatchCallsExported(topo *topology.FunctionTopology, required []string) (score float64, matched, missing []string)

MatchCallsExported exports the matchCalls function for testing.

func SetupTestEnv

func SetupTestEnv(t *testing.T, prefix string) (string, func())

SetupTestEnv creates an isolated workspace with a valid go.mod. Returns the directory path and a cleanup function.

func ShortFuncName

func ShortFuncName(fullName string) string

ShortFuncName returns the short function name without package prefix. Exported for use in external test packages.

Types

This section is empty.

Jump to

Keyboard shortcuts

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