Skip to content

Commit

Permalink
add session_id test
Browse files Browse the repository at this point in the history
  • Loading branch information
issueMel committed Mar 18, 2024
1 parent d7cd016 commit 7bc5370
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pkg/utils/session_id_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package utils

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestGenerateSessionIdShouldEqual(t *testing.T) {
testCase := []struct {
a, b int64
c string
}{
{100, 200, "100200"},
{-1, -1, "-1-1"},
{1<<63 - 1, 1<<63 - 1, "92233720368547758079223372036854775807"},
{1<<63 - 1, -1 << 63, "-92233720368547758089223372036854775807"},
}

for _, tt := range testCase {
require.Equal(t, GenerateSessionId(tt.a, tt.b), tt.c)
}
}

func TestGenerateSessionIdShouldNotEqual(t *testing.T) {
testCase := []struct {
a, b int64
c string
}{
{100, 200, "111222"},
{-1, -1, "-11"},
{-1, -1, "1-1"},
{1<<63 - 1, -1 << 63, "9223372036854775807-9223372036854775808"},
}

for _, tt := range testCase {
require.NotEqual(t, GenerateSessionId(tt.a, tt.b), tt.c)
}
}

0 comments on commit 7bc5370

Please sign in to comment.