Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Latest commit

 

History

History

xycond

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Introduction

Package xycond supports to assert or expect many conditions.

It makes source code to be shorter and more readable by using inline commands.

Features

This package has the following features:

  • Assert a condition, panic in case condition is false.
  • Expect a condition to occur and perform actions on this expectation.

Visit pkg.go.dev for more details.

Example

xycond.AssertFalse(1 == 2)

var x int
xycond.AssertZero(x)

// Test a condition with *testing.T or *testing.B.
var t = &testing.T{}
xycond.ExpectEmpty("").Test(t)

// Perform actions on an expectation.
xycond.ExpectEqual(1, 2).
	True(func() {
		fmt.Printf("1 == 2")
	}).
	False(func() {
		fmt.Printf("1 != 2")
	})

// Output:
// 1 != 2