testingz

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 7 Imported by: 0

README

gopherz

ezpkg.io/testingz

PkgGoDev GitHub License version

Packages testingz provides utilities for testing. Support ignoring spaces and using placeholders.

Installation

go get -u ezpkg.io/testingz@v0.2.2

Examples

formatted, isDiff := testingz.DiffByChar("code: 123A", "code: ███A")
// isDiff: true

formatted, isDiff := testingz.DiffByCharZ("code: 123A", "code: ███A")
// isDiff: false

// placeholder is useful for comparing tests with uuid or random values
formatted, isDiff := testingz.DiffByLineZ(left, right)
left := "id: ████\ncode: AF███\nname: Alice\n"
right := "id: 1234\ncode: AF123\nname: Alice\n"
// isDiff: false

About ezpkg.io

As I work on various Go projects, I often find myself creating utility functions, extending existing packages, or developing packages to solve specific problems. Moving from one project to another, I usually have to copy or rewrite these solutions. So I created this repository to have all these utilities and packages in one place. Hopefully, you'll find them useful as well.

For more information, see the main repository.

Author

Oliver Nguyen  github

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConveyDiffByChar added in v0.2.0

func ConveyDiffByChar(opt diffz.Option) func(actual, expect string, msgArgs ...any)

Usage with conveyz:

ΩxNoDiff := ConveyDiffByChar(diffz.IgnoreSpace().AndPlaceholder())
ΩxNoDiff(expect, actual, "my message")

func ConveyDiffByLine added in v0.1.2

func ConveyDiffByLine(opt diffz.Option) func(actual, expect string, msgArgs ...any)

Usage with conveyz:

ΩxNoDiff := ConveyDiffByLine(diffz.IgnoreSpace().AndPlaceholder())
ΩxNoDiff(expect, actual, "my message")

func DiffByChar

func DiffByChar(actual, expect string) (formatted string, isDiff bool)

func DiffByCharX

func DiffByCharX(actual, expect string, opt diffz.Option) (formatted string, isDiff bool)

func DiffByCharZ

func DiffByCharZ(actual, expect string) (formatted string, isDiff bool)

func DiffByLine

func DiffByLine(actual, expect string) (formatted string, isDiff bool)

func DiffByLineX

func DiffByLineX(actual, expect string, opt diffz.Option) (formatted string, isDiff bool)

func DiffByLineZ

func DiffByLineZ(actual, expect string) (formatted string, isDiff bool)

func ΩxNoDiffByChar added in v0.2.0

func ΩxNoDiffByChar(actual, expect string, msgArgs ...any)

func ΩxNoDiffByCharZ added in v0.2.0

func ΩxNoDiffByCharZ(actual, expect string, msgArgs ...any)

func ΩxNoDiffByLine added in v0.1.2

func ΩxNoDiffByLine(actual, expect string, msgArgs ...any)

func ΩxNoDiffByLineZ added in v0.1.2

func ΩxNoDiffByLineZ(actual, expect string, msgArgs ...any)

Types

This section is empty.

Jump to

Keyboard shortcuts

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