File: pk_test.go

package info (click to toggle)
golang-github-go-xorm-core 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 224 kB
  • sloc: makefile: 2; sh: 1
file content (36 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package core

import (
	"reflect"
	"testing"
)

func TestPK(t *testing.T) {
	p := NewPK(1, 3, "string")
	str, err := p.ToString()
	if err != nil {
		t.Error(err)
	}
	t.Log(str)

	s := &PK{}
	err = s.FromString(str)
	if err != nil {
		t.Error(err)
	}
	t.Log(s)

	if len(*p) != len(*s) {
		t.Fatal("p", *p, "should be equal", *s)
	}

	for i, ori := range *p {
		if ori != (*s)[i] {
			t.Fatal("ori", ori, reflect.ValueOf(ori), "should be equal", (*s)[i], reflect.ValueOf((*s)[i]))
		}
	}
}