compare

package module
v0.0.0-...-be8c917 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 10 Imported by: 1

README

compare

Compare testing

package compare // import "github.com/Konstantin8105/compare"


CONSTANTS

const (
	Key      = "UPDATE"
	KeyValid = "true"
)
    Basic values


FUNCTIONS

func Save(filename string, img image.Image) (err error)
    Save `.png` files

func Test(t Testing, filename string, actual []byte)
    for update test screens run in console: UPDATE=true go test

func TestPng(t Testing, filename string, actual image.Image)
    TestPng compare `.png` files for update test screens run in console:
    UPDATE=true go test


TYPES

type Testing interface {
	Errorf(format string, args ...any)
}
    Testing interface is valid for *testing.T

Documentation

Overview

Example
package main

import (
	"fmt"
	"os"

	"github.com/Konstantin8105/compare"
)

type checker struct {
	iserror bool
	err     error
}

func (c *checker) Errorf(format string, args ...any) {
	c.iserror = true
	c.err = fmt.Errorf(format, args...)
}

func main() {
	var c checker

	wrong := []byte("bad\n")
	compare.Test(&c, ".test", wrong)
	if !c.iserror {
		panic("check wrong body")
	}
	fmt.Fprintf(os.Stdout, "%v", c.err)

}
Output:

*   1 "good"                                  "bad"
*   2 "good"                                  ""
*   3 "good"                                  << EMPTY LINE>>
*   4 "good"                                  << EMPTY LINE>>
and more other ...
meld ".test" ".test.new" &

Index

Examples

Constants

View Source
const (
	Key      = "UPDATE"
	KeyValid = "true"
)

Basic values

Variables

This section is empty.

Functions

func Diff

func Diff(txt1, txt2 []byte) (err error)

Diff will print two strings vertically next to each other so that line differences are easier to read.

func Save

func Save(filename string, img image.Image) (err error)

Save `.png` files

func Test

func Test(t Testing, filename string, actual []byte)

for update test screens run in console: UPDATE=true go test

func TestDiff

func TestDiff(t Testing, txt1, txt2 []byte)

TestDiff will print two strings vertically next to each other so that line differences are easier to read.

func TestPng

func TestPng(t Testing, filename string, actual image.Image)

TestPng compare `.png` files for update test screens run in console: UPDATE=true go test

Types

type Testing

type Testing interface {
	Errorf(format string, args ...any)
}

Testing interface is valid for *testing.T

Jump to

Keyboard shortcuts

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