From aedd25ebb3bfb47336b080a4acaa99d7b82d4a59 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Sat, 12 Nov 2022 19:08:21 +0800 Subject: [PATCH 1/2] Add test coverage instructions --- .gitignore | 2 ++ README.md | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43937e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.html +*.out \ No newline at end of file diff --git a/README.md b/README.md index 167dc81..c988253 100644 --- a/README.md +++ b/README.md @@ -438,6 +438,12 @@ func main() { } ``` +## Testing + +```sh +go test -v -coverprofile coverage.out && go tool cover -html coverage.out -o coverage.html +``` + ## Performance See [tidwall/btree-benchmark](https://github.com/tidwall/btree-benchmark) for benchmark numbers. From 4afb1624b113ab966e28f702723544aab627790d Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Sat, 12 Nov 2022 19:16:54 +0800 Subject: [PATCH 2/2] Add test case for degreeToMinMax --- btreeg_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/btreeg_test.go b/btreeg_test.go index cf61aa9..b11dc69 100644 --- a/btreeg_test.go +++ b/btreeg_test.go @@ -75,6 +75,12 @@ func kindsAreEqual(a, b []testKind) bool { return true } +func TestDegreeToMinMax(t *testing.T) { + if min, max := degreeToMinMax(1); min != 1 || max != 3 { + panic("mismatch") + } +} + func TestGenericMakeItemOrder(t *testing.T) { tr := testNewBTree() ints := []int{0, 1, 2, 3, 4, 10, 20, 30, 40, 100, 200, 300, 400}