test

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Example (Output)
package main

import (
	"fmt"

	"codeberg.org/japh/psv"
	"codeberg.org/japh/psv/internal/column"
	"codeberg.org/japh/psv/internal/ruler"
)

func main() {
	t := psv.Table{
		Prefix: ">> ",
	}
	t.AppendFields("size", "weight")
	t.AppendRuler(ruler.FromTemplate("| -"))
	t.AppendFields("1", "1")
	t.AppendFields("2", "4")
	t.AppendFields("3", "9")
	t.AppendFields("4", "16")
	t.Index.Column("weight").SetAlignment(column.AlignRightFlag)
	fmt.Print(t.String())

}
Output:

>> | size | weight |
>> | ---- | ------ |
>> | 1    |      1 |
>> | 2    |      4 |
>> | 3    |      9 |
>> | 4    |     16 |

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestArchive

type TestArchive struct {
	Name string
	*txtar.Archive
}

TestArchive wraps a *txtar.Archive and adds the filename of the archive

Use ar.ReadFileData( name ) []byte to get an archived file's data - []byte{} is returned if the archived file does not exist

See also as.HasFile( name ) to check for existence of a file in the archive

func TestArchives

func TestArchives() []*TestArchive

TestArchives provides shared access to all .txtar files for testing etc in multiple packages

Usage:

for _, ar := range test.TestArchives() {
	givenInput := ar.ReadFileData( "input" )
	wantOutput := ar.ReadFileData( "output" )

	gotOutput := doSomething( input )
	if gotOutput != wantOutput {
		...
	}
}

Jump to

Keyboard shortcuts

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