Skip to content

Commit 01c8ee7

Browse files
authored
chore: updated panic message for the TokenSupplyType (#1766)
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 4724990 commit 01c8ee7

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

sdk/token_supply_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ func (tokenSupplyType TokenSupplyType) String() string {
2020
return "TOKEN_SUPPLY_TYPE_FINITE"
2121
}
2222

23-
panic(fmt.Sprintf("unreachable: TokenType.String() switch statement is non-exhaustive. Status: %v", uint32(tokenSupplyType)))
23+
panic(fmt.Sprintf("unreachable: TokenSupplyType.String() switch statement is non-exhaustive. Status: %v", uint32(tokenSupplyType)))
2424
}

sdk/token_supply_type_unit_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package hiero
2+
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
import (
6+
"github.com/stretchr/testify/assert"
7+
"testing"
8+
)
9+
10+
func TestUnitTokenSupplyTypeString(t *testing.T) {
11+
t.Parallel()
12+
13+
tests := []struct {
14+
name string
15+
tst TokenSupplyType
16+
want string
17+
}{
18+
{name: "Infinite", tst: TokenSupplyTypeInfinite, want: "TOKEN_SUPPLY_TYPE_INFINITE"},
19+
{name: "Finite", tst: TokenSupplyTypeFinite, want: "TOKEN_SUPPLY_TYPE_FINITE"},
20+
}
21+
22+
for _, test := range tests {
23+
t.Run(test.name, func(t *testing.T) {
24+
t.Parallel()
25+
assert.Equal(t, test.want, test.tst.String(), "TokenSupplyType(%d).String()", test.tst)
26+
})
27+
}
28+
}
29+
30+
func TestUnitTokenSupplyTypeStringPanic(t *testing.T) {
31+
t.Parallel()
32+
33+
var unknownSupplyType TokenSupplyType = 100
34+
assert.PanicsWithValue(
35+
t,
36+
"unreachable: TokenSupplyType.String() switch statement is non-exhaustive. Status: 100",
37+
func() {
38+
_ = unknownSupplyType.String()
39+
},
40+
)
41+
}

0 commit comments

Comments
 (0)