github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/inspector/validation/utils_test.go (about) 1 package validation 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 // TestDuplicateStringTracker tests the duplicateStrTracker.track function. 10 func TestDuplicateStringTracker(t *testing.T) { 11 tracker := make(duplicateStrTracker) 12 require.Equal(t, 1, tracker.track("test1")) 13 require.Equal(t, 2, tracker.track("test1")) 14 15 // tracking a new string, 3 times 16 require.Equal(t, 1, tracker.track("test2")) 17 require.Equal(t, 2, tracker.track("test2")) 18 require.Equal(t, 3, tracker.track("test2")) 19 20 // tracking an empty string 21 require.Equal(t, 1, tracker.track("")) 22 }