testutil

package
v2.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 15 Imported by: 0

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) (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 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