testutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 7 Imported by: 2 modules, 59 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Once bool

	// 用于编写 struct + method 的题目,方便打断点
	DebugCallIndex int

	DebugTLE = 2 * time.Second

	AssertOutput = true
)

Functions

func CompareInf

func CompareInf(t *testing.T, inputGenerator, runACFunc, runFunc interface{})

无尽对拍模式 todo 构造器+方法的对拍

可以外面套一个函数去分配不同的调用

func CountNodes

func CountNodes(root *TreeNode) (cnt int)

func GetParents

func GetParents(root *TreeNode) map[*TreeNode]*TreeNode

func RunLeetCodeClass

func RunLeetCodeClass(t *testing.T, constructor interface{}, rawInputs, rawOutputs []string) error

func RunLeetCodeClassWithCase

func RunLeetCodeClassWithCase(t *testing.T, constructor interface{}, rawInputs, rawOutputs []string, targetCaseNum int) (err error)

func RunLeetCodeClassWithExamples

func RunLeetCodeClassWithExamples(t *testing.T, constructor interface{}, rawExamples [][3]string, targetCaseNum int) (err error)

若反射出来的函数或 rawExamples 数据不合法,则会返回一个非空的 error,否则返回 nil

func RunLeetCodeFunc

func RunLeetCodeFunc(t *testing.T, f interface{}, rawInputs [][]string, rawOutputs [][]string) error

func RunLeetCodeFuncWithCase

func RunLeetCodeFuncWithCase(t *testing.T, f interface{}, rawInputs [][]string, rawOutputs [][]string, targetCaseNum int) (err error)

func RunLeetCodeFuncWithExamples

func RunLeetCodeFuncWithExamples(t *testing.T, f interface{}, rawExamples [][]string, targetCaseNum int) (err error)

rawExamples[i] = 输入+输出 若反射出来的函数或 rawExamples 数据不合法,则会返回一个非空的 error,否则返回 nil

func ToGraph

func ToGraph(root *TreeNode) [][]int

加权图见下面的 ToWeightedGraph

func ToGraphWithDir

func ToGraphWithDir(root *TreeNode) [][]DirEdge

func ToWeightedGraph

func ToWeightedGraph(root *TreeNode) [][]Edge

func Values

func Values(head *ListNode) (values []int)

Types

type DirEdge

type DirEdge struct {
	// contains filtered or unexported fields
}

type Edge

type Edge struct {
	// contains filtered or unexported fields
}

type Interval

type Interval struct {
	Start int
	End   int
}

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

func BuildListNodeFromInts

func BuildListNodeFromInts(a []int) *ListNode

func ModifyNodes

func ModifyNodes(head *ListNode, f func([]int) []int) *ListNode

func MustBuildListNode

func MustBuildListNode(rawArray string) *ListNode

func Nodes

func Nodes(head *ListNode) []*ListNode

type Point

type Point struct {
	X int
	Y int
}

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func MustBuildTreeNode

func MustBuildTreeNode(rawArray string) *TreeNode

Jump to

Keyboard shortcuts

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