...

Source file src/github.com/launchdarkly/go-jsonstream/v3/internal/commontest/assertions.go

Documentation: github.com/launchdarkly/go-jsonstream/v3/internal/commontest

     1  package commontest
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  	"reflect"
     7  )
     8  
     9  // These functions provide a simple mechanism for returning errors as errors instead of using
    10  // assert or require.
    11  
    12  func AssertEqual(expected, actual interface{}) error {
    13  	if !reflect.DeepEqual(expected, actual) {
    14  		return fmt.Errorf("expected %s, got %s", expected, actual)
    15  	}
    16  	return nil
    17  }
    18  
    19  func AssertTrue(value bool, failureMessage string) error {
    20  	if !value {
    21  		return errors.New(failureMessage)
    22  	}
    23  	return nil
    24  }
    25  
    26  func AssertNoErrors(errs ...error) error {
    27  	for _, err := range errs {
    28  		if err != nil {
    29  			return err
    30  		}
    31  	}
    32  	return nil
    33  }
    34  

View as plain text