ut

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ut provides commonly used func for unit testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{}, opts ...cmp.Option) bool

AssertEqual return result of comparison. AssetEqual is wrapping google compare which will try to use Equal func of the object first. Don't use reflect.DeepEqual directly because it will not compare time correctly. Recommended to use AssertEqual

Note: If comparing struct that contain unexported field, must add cmp.AllowUnexported(expected, actual) as opts. However, this option only allow comparing of value struct. Therefore, we need to dereference pointer struct.

func AssertNotEqual

func AssertNotEqual(t *testing.T, expected, actual interface{}, opts ...cmp.Option) bool

func Clone

func Clone(a interface{}) interface{}

Clone return deep copy of a reprint lib is better than other deep copy lib due to its ability to copy unexported field too.

func Ptr

func Ptr[T any](value T) *T

Ptr return the pointer of the value

func TimeParse

func TimeParse(layout, timeStr string) *time.Time

TimeParse will parse time from string to *time.Time. Panic if parse failed

Types

This section is empty.

Jump to

Keyboard shortcuts

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