mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
67 lines
1.0 KiB
Go
67 lines
1.0 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package contract
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFunctionSignatureRegex(t *testing.T) {
|
|
type test struct {
|
|
str string
|
|
pass bool
|
|
}
|
|
|
|
for _, test := range []test{
|
|
{
|
|
str: "getBalance()",
|
|
pass: true,
|
|
},
|
|
{
|
|
str: "getBalance(address)",
|
|
pass: true,
|
|
},
|
|
{
|
|
str: "getBalance(address,address)",
|
|
pass: true,
|
|
},
|
|
{
|
|
str: "getBalance(address,address,address)",
|
|
pass: true,
|
|
},
|
|
{
|
|
str: "getBalance(address,address,address,uint256)",
|
|
pass: true,
|
|
},
|
|
{
|
|
str: "getBalance(address,)",
|
|
pass: false,
|
|
},
|
|
{
|
|
str: "getBalance(address,address,)",
|
|
pass: false,
|
|
},
|
|
{
|
|
str: "getBalance(,)",
|
|
pass: false,
|
|
},
|
|
{
|
|
str: "(address,)",
|
|
pass: false,
|
|
},
|
|
{
|
|
str: "()",
|
|
pass: false,
|
|
},
|
|
{
|
|
str: "dummy",
|
|
pass: false,
|
|
},
|
|
} {
|
|
assert.Equal(t, test.pass, functionSignatureRegex.MatchString(test.str), "unexpected result for %q", test.str)
|
|
}
|
|
}
|