Skip to content

Commit

Permalink
[#1301] Add some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fivitti committed Apr 3, 2024
1 parent e8f3936 commit 53a4711
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestIsHexIdentifier(t *testing.T) {
require.False(t, IsHexIdentifier("12:56:9"))
require.False(t, IsHexIdentifier("ab,cd"))
require.False(t, IsHexIdentifier("ab: cd"))
require.False(t, IsHexIdentifier("abcde"))
}

// Test splitting an identifier into a slice of bytes.
Expand All @@ -104,11 +105,13 @@ func TestCountHexIdentifierBytes(t *testing.T) {

// Invalid output for invalid input.
require.Zero(t, CountHexIdentifierBytes(" "))
require.Zero(t, CountHexIdentifierBytes(""))
require.Equal(t, 3, CountHexIdentifierBytes("1234gh"))
require.Equal(t, 2, CountHexIdentifierBytes("12:56:"))
require.Equal(t, 2, CountHexIdentifierBytes("12:56:9"))
require.Equal(t, 2, CountHexIdentifierBytes("ab,cd"))
require.Equal(t, 2, CountHexIdentifierBytes("ab: cd"))
require.Equal(t, 2, CountHexIdentifierBytes("abcde"))
}

// Check if BytesToHex works.
Expand Down

0 comments on commit 53a4711

Please sign in to comment.