github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/porting-solidity-to-gno/porting-1.gno (about)

     1  func shouldEqual(t *testing.T, got interface{}, expected interface{}) {
     2  	t.Helper()
     3  
     4  	if got != expected {
     5  		t.Errorf("expected %v(%T), got %v(%T)", expected, expected, got, got)
     6  	}
     7  }
     8  
     9  func shouldErr(t *testing.T, err error) {
    10  	t.Helper()
    11  	if err == nil {
    12  		t.Errorf("expected an error, but got nil.")
    13  	}
    14  }
    15  
    16  func shouldNoErr(t *testing.T, err error) {
    17  	t.Helper()
    18  	if err != nil {
    19  		t.Errorf("expected no error, but got err: %s.", err.Error())
    20  	}
    21  }
    22  
    23  func shouldPanic(t *testing.T, f func()) {
    24  	defer func() {
    25  		if r := recover(); r == nil {
    26  			t.Errorf("should have panic")
    27  		}
    28  	}()
    29  	f()
    30  }
    31  
    32  func shouldNoPanic(t *testing.T, f func()) {
    33  	defer func() {
    34  		if r := recover(); r != nil {
    35  			t.Errorf("should not have panic")
    36  		}
    37  	}()
    38  	f()
    39  }