Help us shape the future of Go! Take the 2026 Go Developer Survey

testsupport

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package testsupport holds small helpers shared across package test suites.

Index

Constants

This section is empty.

Variables

View Source
var AskUserTextCases = []AskUserTextCase{
	{"x", true, true},
	{"", false, false},
	{" ", false, false},
	{"\t\n\r\f\v ", false, false},
	{"   \t  ", false, false},
	{" x ", true, true},
	{string(rune(0x00A0)), false, false},
	{string(rune(0x0085)), false, false},
	{string(rune(0xFEFF)), false, false},
	{string(rune(0x200B)), false, false},
	{string(rune(0x754C)), true, true},
	{"e" + string(rune(0x0301)), true, true},
	{"a" + string(rune(0x200B)) + "b", false, false},

	{"Yes\tNo", false, false},
	{"Choose\nnow", false, false},
	{"Choose\rnow", false, false},
	{"Choose\fnow", false, false},
	{"Choose\vnow", false, false},
	{"Choose" + string(rune(0x0085)) + "now", false, false},
	{"Choose" + string(rune(0x2028)) + "now", false, false},

	{"Choose" + string(rune(0x202E)) + "now", false, false},
	{"Choose" + string(rune(0x2061)) + "now", false, false},
	{"Choose" + string(rune(0xFFF9)) + "now", false, false},
	{"Choose" + string(rune(0x180E)) + "now", false, false},
	{"Choose" + string(rune(0xE000)) + "now", false, false},

	{string(rune(0x2800)), false, false},
	{string(rune(0x3164)), false, false},
	{string(rune(0x115F)), false, false},
	{string(rune(0x1160)), false, false},
	{string(rune(0xFFA0)), false, false},
	{"Choose" + string(rune(0x2800)) + "now", false, false},
	{"Choose" + string(rune(0x3164)) + "now", false, false},
	{string(rune(0x2801)), true, true},
	{string(rune(0xFFA1)), true, true},

	{string(rune(0x20DD)), false, true},
	{"a" + string(rune(0x20DD)), true, true},

	{string(rune(0x0301)), false, true},
	{"Choose" + string(rune(0x0378)) + "now", false, true},
	{"Choose" + string(rune(0xE0020)) + "now", false, true},
	{"Yes\x00", false, true},
	{"\x00", false, true},
}

AskUserTextCases is asserted by both the provider schema test and the bootstrap decoder test. The rule is shared here rather than restated in each package because the schema and the decoder previously enforced two defensible blank-text rules that disagreed on values a model can actually send. Where they still differ the schema must be the looser of the two, so every Valid case is also a Pattern case: a value the form can show must never be one the advertised schema refuses. The six Valid=false/Pattern=true values are examples, not a list — the provider sweep test bounds that difference over every code point.

Functions

func CaptureStderr

func CaptureStderr(t *testing.T, fn func()) string

CaptureStderr runs fn with os.Stderr redirected through a pipe and returns everything written to stderr during the call. It restores os.Stderr before returning.

CaptureStderr redirects process-wide os.Stderr, so it must not be used from tests (or call sites) running under t.Parallel(): concurrent captures would race on the shared os.Stderr.

Types

type AskUserTextCase

type AskUserTextCase struct {
	Text    string
	Valid   bool
	Pattern bool
}

AskUserTextCase is one value of the ask_user displayed-text rule with the verdict each layer must reach on it: Valid is what the authoritative renderability rule decides, and Pattern is what the advertised schema class can express on its own.

Jump to

Keyboard shortcuts

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