Skip to content
343 changes: 155 additions & 188 deletions README.md

Large diffs are not rendered by default.

65 changes: 0 additions & 65 deletions bool.go

This file was deleted.

47 changes: 0 additions & 47 deletions context_examples_test.go

This file was deleted.

62 changes: 0 additions & 62 deletions context_test.go

This file was deleted.

31 changes: 0 additions & 31 deletions emptiness_test.go

This file was deleted.

29 changes: 0 additions & 29 deletions error.go

This file was deleted.

30 changes: 0 additions & 30 deletions error_test.go

This file was deleted.

62 changes: 48 additions & 14 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,56 @@ import (
"errors"
)

// general errors
var (
// general errors
ErrInvalidArgument = errors.New("invalid argument")
// ErrInvalidArgument indicates that an argument provided to a function or method is invalid.
ErrInvalidArgument = errors.New("invalid argument")

// ErrInvalidOperation indicates that an attempted operation is invalid in the current context.
ErrInvalidOperation = errors.New("invalid operation")
)

// mock and fake errors
// mock and fake errors
var (
// ErrExpectationsNotMet indicates that the expectations set on a mock or fake
// were not met.
ErrExpectationsNotMet = errors.New("expectations not met")
ErrExpectedArgs = errors.New("arguments were expected but not recorded")
ErrNoResultForArgs = errors.New("no result for arguments")
ErrUnexpectedArgs = errors.New("the arguments recorded did not match those expected")
ErrUnexpectedCall = errors.New("unexpected call")
ErrResultNotUsed = errors.New("result not used")

// recording errors
ErrRecordingFailed = errors.New("recording failed")
ErrRecordingStdout = errors.New("error recording stdout")
ErrRecordingStderr = errors.New("error recording stderr")
ErrRecordingUnableToRedirectLogger = errors.New("unable to redirect logger output")

// ErrExpectedArgs indicates that arguments were expected but not recorded.
ErrExpectedArgs = errors.New("arguments were expected but not recorded")

// ErrNoResultForArgs indicates that no result was found for the given arguments.
ErrNoResultForArgs = errors.New("no result for arguments")

// ErrUnexpectedArgs indicates that the arguments recorded did not match those expected.
ErrUnexpectedArgs = errors.New("the arguments recorded did not match those expected")

// ErrUnexpectedCall indicates that a call was made that was not expected.
ErrUnexpectedCall = errors.New("unexpected call")

// ErrResultNotUsed indicates that a result was provided but not used.
ErrResultNotUsed = errors.New("result not used")
)

// recording errors
var (
// ErrRecordingFailed indicates that an error occurred while trying to
// record output.
ErrRecordingFailed = errors.New("recording failed")

// ErrRecordingStdout indicates that an error occurred while trying to
// record stdout.
ErrRecordingStdout = errors.New("error recording stdout")

// ErrRecordingStderr indicates that an error occurred while trying to
// record stderr.
ErrRecordingStderr = errors.New("error recording stderr")

// ErrFailedToRedirectLogger indicates that an error occurred while trying
// to redirect logger output.
ErrFailedToRedirectLogger = errors.New("failed to redirect logger output")

// Deprecated: this error is deprecated and will be removed in a future version;
// use [ErrFailedToRedirectLogger] instead.
ErrRecordingUnableToRedirectLogger = ErrFailedToRedirectLogger
)
45 changes: 45 additions & 0 deletions expect/bool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package expect

import "github.com/blugnu/test"

// False fails a test if a specified bool is not false. An optional
// name (string) may be specified to be included in the test report in the
// event of failure.
//
// This test is a convenience for these equivalent alternatives:
//
// Expect(got).To(Equal(false))
// Expect(got).To(BeFalse())
//
// # Supported Options
//
// string // a name for the value, for use in any test
// // failure report
//
// opt.FailureReport(func) // a function returning a custom failure report
// // in the event that the test fails
func False[T ~bool](got T, opts ...any) {
test.T().Helper()
test.Expect(bool(got), opts...).To(test.BeFalse(), opts...)
}

// True fails a test if a specified bool is not true. An optional
// name (string) may be specified to be included in the test report in the
// event of failure.
//
// This test is a convenience for these equivalent alternatives:
//
// Expect(got).To(Equal(true))
// Expect(got).To(BeTrue())
//
// # Supported Options
//
// string // a name for the value, for use in any test
// // failure report
//
// opt.FailureReport(func) // a function returning a custom failure report
// // in the event that the test fails
func True[T ~bool](got T, opts ...any) {
test.T().Helper()
test.Expect(bool(got), opts...).To(test.BeTrue(), opts...)
}
Loading
Loading