github.com/dim4egster/coreth@v0.10.2/precompile/utils_test.go (about)

     1  package precompile
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestFunctionSignatureRegex(t *testing.T) {
    10  	type test struct {
    11  		str  string
    12  		pass bool
    13  	}
    14  
    15  	for _, test := range []test{
    16  		{
    17  			str:  "getBalance()",
    18  			pass: true,
    19  		},
    20  		{
    21  			str:  "getBalance(address)",
    22  			pass: true,
    23  		},
    24  		{
    25  			str:  "getBalance(address,address)",
    26  			pass: true,
    27  		},
    28  		{
    29  			str:  "getBalance(address,address,address)",
    30  			pass: true,
    31  		},
    32  		{
    33  			str:  "getBalance(address,address,address,uint256)",
    34  			pass: true,
    35  		},
    36  		{
    37  			str:  "getBalance(address,)",
    38  			pass: false,
    39  		},
    40  		{
    41  			str:  "getBalance(address,address,)",
    42  			pass: false,
    43  		},
    44  		{
    45  			str:  "getBalance(,)",
    46  			pass: false,
    47  		},
    48  		{
    49  			str:  "(address,)",
    50  			pass: false,
    51  		},
    52  		{
    53  			str:  "()",
    54  			pass: false,
    55  		},
    56  		{
    57  			str:  "dummy",
    58  			pass: false,
    59  		},
    60  	} {
    61  		assert.Equal(t, test.pass, functionSignatureRegex.MatchString(test.str), "unexpected result for %q", test.str)
    62  	}
    63  }