testutils

package
v0.0.0-...-9907f30 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Once bool

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

	DebugTLE = 2 * time.Second

	AssertOutput = true
)

Functions

func CountNodes

func CountNodes(root *TreeNode) (cnt int)

func GetParents

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

func IsDebugging

func IsDebugging() bool

IsDebugging will return true if the process was launched from Delve or the gopls language server debugger.

It does not detect situations where a debugger attached after process start. Adapted from https://stackoverflow.com/a/70969754/4419904

func RunLeetCodeFuncWithExamples

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

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

func RunLeetCodeFuncWithFile

func RunLeetCodeFuncWithFile(t *testing.T, f interface{}, filePath string, targetCaseNum int) error

func ToGraph

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

ToGraph 加权图见下面的 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