Skip to content

Commit

Permalink
util/disjointset: remove pingcap/check for test (#26484)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyz0309 authored Jul 23, 2021
1 parent cb40004 commit 4116dd2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
32 changes: 11 additions & 21 deletions util/disjointset/int_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@ package disjointset
import (
"testing"

. "github.com/pingcap/check"
"github.com/stretchr/testify/assert"
)

var _ = Suite(&testDisjointSetSuite{})

func TestT(t *testing.T) {
CustomVerboseFlag = true
TestingT(t)
}

type testDisjointSetSuite struct {
}

func (s *testDisjointSetSuite) TestIntDisjointSet(c *C) {
func TestIntDisjointSet(t *testing.T) {
set := NewIntSet(10)
c.Assert(len(set.parent), Equals, 10)
assert.Len(t, set.parent, 10)
for i := range set.parent {
c.Assert(set.parent[i], Equals, i)
assert.Equal(t, i, set.parent[i])
}
set.Union(0, 1)
set.Union(1, 3)
Expand All @@ -42,11 +32,11 @@ func (s *testDisjointSetSuite) TestIntDisjointSet(c *C) {
set.Union(3, 5)
set.Union(7, 8)
set.Union(9, 6)
c.Assert(set.FindRoot(0), Equals, set.FindRoot(1))
c.Assert(set.FindRoot(3), Equals, set.FindRoot(1))
c.Assert(set.FindRoot(5), Equals, set.FindRoot(1))
c.Assert(set.FindRoot(2), Equals, set.FindRoot(4))
c.Assert(set.FindRoot(6), Equals, set.FindRoot(4))
c.Assert(set.FindRoot(9), Equals, set.FindRoot(2))
c.Assert(set.FindRoot(7), Equals, set.FindRoot(8))
assert.Equal(t, set.FindRoot(0), set.FindRoot(1))
assert.Equal(t, set.FindRoot(3), set.FindRoot(1))
assert.Equal(t, set.FindRoot(5), set.FindRoot(1))
assert.Equal(t, set.FindRoot(2), set.FindRoot(4))
assert.Equal(t, set.FindRoot(6), set.FindRoot(4))
assert.Equal(t, set.FindRoot(9), set.FindRoot(2))
assert.Equal(t, set.FindRoot(7), set.FindRoot(8))
}
26 changes: 26 additions & 0 deletions util/disjointset/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2021 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package disjointset

import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.WorkaroundGoCheckFlags()
goleak.VerifyTestMain(m)
}

0 comments on commit 4116dd2

Please sign in to comment.