util_test.go 749 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2025 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package sqlite
  7. import (
  8. "testing"
  9. "github.com/syncthing/syncthing/lib/protocol"
  10. )
  11. func TestDbvector(t *testing.T) {
  12. vec := protocol.Vector{Counters: []protocol.Counter{{ID: 42, Value: 7}, {ID: 123456789, Value: 42424242}}}
  13. dbVec := dbVector{vec}
  14. val, err := dbVec.Value()
  15. if err != nil {
  16. t.Fatal(val)
  17. }
  18. var dbVec2 dbVector
  19. if err := dbVec2.Scan(val); err != nil {
  20. t.Fatal(err)
  21. }
  22. if !dbVec2.Vector.Equal(vec) {
  23. t.Log(vec)
  24. t.Log(dbVec2.Vector)
  25. t.Fatal("should match")
  26. }
  27. }