helpers_test.go 767 B

1234567891011121314151617181920212223242526
  1. // Copyright 2017 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 xorm
  5. import "testing"
  6. func TestSplitTag(t *testing.T) {
  7. var cases = []struct {
  8. tag string
  9. tags []string
  10. }{
  11. {"not null default '2000-01-01 00:00:00' TIMESTAMP", []string{"not", "null", "default", "'2000-01-01 00:00:00'", "TIMESTAMP"}},
  12. {"TEXT", []string{"TEXT"}},
  13. {"default('2000-01-01 00:00:00')", []string{"default('2000-01-01 00:00:00')"}},
  14. {"json binary", []string{"json", "binary"}},
  15. }
  16. for _, kase := range cases {
  17. tags := splitTag(kase.tag)
  18. if !sliceEq(tags, kase.tags) {
  19. t.Fatalf("[%d]%v is not equal [%d]%v", len(tags), tags, len(kase.tags), kase.tags)
  20. }
  21. }
  22. }