github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/errors/value_test.go (about)

     1  package errors
     2  
     3  import "testing"
     4  
     5  func TestValueMalformedBare(t *testing.T) {
     6  	var err error = ErrValueMalformed
     7  	assert(t, "malformed", err.Error())
     8  	assert(t, ErrValueMalformed, err)
     9  	assert(t, true, IsValueMalformedError(err))
    10  }
    11  
    12  func TestValueMalformedNil(t *testing.T) {
    13  	var err error
    14  	assert(t, false, IsValueMalformedError(err))
    15  }
    16  
    17  func TestValueMalformedNegative(t *testing.T) {
    18  	var err error = Msg("nothing")
    19  	assert(t, false, IsValueMalformedError(err))
    20  }
    21  
    22  func TestValueMalformedComplexNil(t *testing.T) {
    23  	var err error = ValueMalformed()
    24  	assert(t, "malformed", err.Error())
    25  	assert(t, true, IsValueMalformedError(err))
    26  	assert(t, nil, Unwrap(err))
    27  }
    28  
    29  func TestValueMalformedComplexWithDetails(t *testing.T) {
    30  	var err error = ValueMalformed().Wrap(ErrValueInvalid)
    31  	assert(t, "malformed: invalid", err.Error())
    32  	assert(t, true, IsValueMalformedError(err))
    33  	assert(t, ErrValueInvalid, Unwrap(err))
    34  }
    35  
    36  func TestDescriptorDetailsBlank(t *testing.T) {
    37  	var err error = &valueDescriptorDetailsError{}
    38  	assert(t, "", err.Error())
    39  }
    40  
    41  func TestDescriptorDetailsOnlyDetails(t *testing.T) {
    42  	var err error = &valueDescriptorDetailsError{wrapped: ErrValueInvalid}
    43  	assert(t, "invalid", err.Error())
    44  }