pk_test.go 650 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package core
  5. import (
  6. "reflect"
  7. "testing"
  8. )
  9. func TestPK(t *testing.T) {
  10. p := NewPK(1, 3, "string")
  11. str, err := p.ToString()
  12. if err != nil {
  13. t.Error(err)
  14. }
  15. t.Log(str)
  16. s := &PK{}
  17. err = s.FromString(str)
  18. if err != nil {
  19. t.Error(err)
  20. }
  21. t.Log(s)
  22. if len(*p) != len(*s) {
  23. t.Fatal("p", *p, "should be equal", *s)
  24. }
  25. for i, ori := range *p {
  26. if ori != (*s)[i] {
  27. t.Fatal("ori", ori, reflect.ValueOf(ori), "should be equal", (*s)[i], reflect.ValueOf((*s)[i]))
  28. }
  29. }
  30. }