testutil

package
v2.1.16 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 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

Overview

Package testutil provides utilities for unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffPretty

func DiffPretty[T1 []byte | string, T2 []byte | string](v1 T1, v2 T2) []byte

DiffPretty returns pretty formatted diff between given bytes.

func DoTestCase

func DoTestCase(m MarkdownToStringFunc, testCase MarkdownTestCase, t TestingT)

DoTestCase runs a test case.

func DoTestCaseFile

func DoTestCaseFile(m MarkdownToStringFunc, filename string, t TestingT, no ...int)

DoTestCaseFile runs test cases in a given file.

func DoTestCases

func DoTestCases(m MarkdownToStringFunc, cases []MarkdownTestCase, t TestingT)

DoTestCases runs a set of test cases.

func ParseCliCaseArg

func ParseCliCaseArg() []int

ParseCliCaseArg parses -case command line args.

Types

type MarkdownTestCase

type MarkdownTestCase struct {
	No          int
	Description string
	Options     MarkdownTestCaseOptions
	Markdown    string
	Expected    string
}

MarkdownTestCase represents a test case.

type MarkdownTestCaseOptions

type MarkdownTestCaseOptions struct {
	EnableEscape bool
	Trim         bool
}

MarkdownTestCaseOptions represents options for each test case.

type MarkdownToStringFunc

type MarkdownToStringFunc func(source string, opts ...MarkdownToStringFuncOption) (string, error)

MarkdownToStringFunc is a function type that converts markdown to HTML.

func NewMarkdownToStringFunc

func NewMarkdownToStringFunc(p parser.Parser, r renderer.Renderer[io.Writer]) MarkdownToStringFunc

NewMarkdownToStringFunc returns a MarkdownToStringFunc that uses the given parser and renderer.

type MarkdownToStringFuncOption

type MarkdownToStringFuncOption func(*markdownToStringFuncConfig)

MarkdownToStringFuncOption is a function type that modifies the configuration of a MarkdownToStringFunc.

type TestingT

type TestingT interface {
	Logf(string, ...any)
	Skipf(string, ...any)
	Errorf(string, ...any)
	FailNow()
}

TestingT is a subset of the functionality provided by testing.T.

Jump to

Keyboard shortcuts

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