...

Source file src/golang.org/x/xerrors/wrap_113_test.go

Documentation: golang.org/x/xerrors

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build go1.13
     6  
     7  package xerrors_test
     8  
     9  import (
    10  	"errors"
    11  	"testing"
    12  
    13  	"golang.org/x/xerrors"
    14  )
    15  
    16  func TestErrorsIs(t *testing.T) {
    17  	var errSentinel = errors.New("sentinel")
    18  
    19  	got := errors.Is(xerrors.Errorf("%w", errSentinel), errSentinel)
    20  	if !got {
    21  		t.Error("got false, want true")
    22  	}
    23  
    24  	got = errors.Is(xerrors.Errorf("%w: %s", errSentinel, "foo"), errSentinel)
    25  	if !got {
    26  		t.Error("got false, want true")
    27  	}
    28  }
    29  

View as plain text