From 4116dd248a1533c83eebd4eaacc690f4ebb63ff8 Mon Sep 17 00:00:00 2001 From: Alkaid Jiang <38248129+jyz0309@users.noreply.github.com> Date: Fri, 23 Jul 2021 11:08:14 +0800 Subject: [PATCH] util/disjointset: remove pingcap/check for test (#26484) --- util/disjointset/int_set_test.go | 32 +++++++++++--------------------- util/disjointset/main_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 util/disjointset/main_test.go diff --git a/util/disjointset/int_set_test.go b/util/disjointset/int_set_test.go index 222c63ec5fc9f..3c6072c2414f6 100644 --- a/util/disjointset/int_set_test.go +++ b/util/disjointset/int_set_test.go @@ -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) @@ -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)) } diff --git a/util/disjointset/main_test.go b/util/disjointset/main_test.go new file mode 100644 index 0000000000000..2d5559e618905 --- /dev/null +++ b/util/disjointset/main_test.go @@ -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) +}