Files
wehub-resource-sync 75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:11:07 +08:00

56 lines
1.1 KiB
Go

package walmath_test
import (
"testing"
"github.com/stretchr/testify/assert"
"databasus-backend/internal/util/walmath"
)
func Test_ParseLSN_ValidHex_RoundtripsViaString(t *testing.T) {
cases := []string{
"0/0",
"0/1",
"1/0",
"0/2A33FF50",
"12345678/90ABCDEF",
"FFFFFFFF/FFFFFFFF",
}
for _, c := range cases {
lsn, err := walmath.ParseLSN(c)
assert.NoError(t, err, c)
assert.Equal(t, c, lsn.String(), c)
}
}
func Test_ParseLSN_MalformedInput_ReturnsError(t *testing.T) {
cases := []string{
"",
"/0",
"0/",
"GGG/0",
"deadbeef",
"0",
}
for _, c := range cases {
_, err := walmath.ParseLSN(c)
assert.Error(t, err, c)
}
}
func Test_LSN_String_ZeroPaddingMatches_X_X_Format(t *testing.T) {
assert.Equal(t, "12345678/90ABCDEF", walmath.LSN(0x1234567890ABCDEF).String())
assert.Equal(t, "0/A", walmath.LSN(0xA).String())
assert.Equal(t, "1/0", walmath.LSN(0x100000000).String())
}
func Test_ParseLSN_LowercaseHex_ParsesCorrectly(t *testing.T) {
lsn, err := walmath.ParseLSN("0/2a33ff50")
assert.NoError(t, err)
assert.Equal(t, walmath.LSN(0x2A33FF50), lsn)
}