From 93b62f451a0bbe4c114bbe85cd3a4fe8292ec3d6 Mon Sep 17 00:00:00 2001 From: tank Date: Sat, 23 Apr 2022 12:31:45 +0800 Subject: [PATCH 1/2] doc: add Compare --- index.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.md b/index.md index 25820d8bb..2377eaf78 100644 --- a/index.md +++ b/index.md @@ -518,6 +518,17 @@ When both `ACTUAL` and `EXPECTED` are a very long strings, it will attempt to pr > For asserting equality between numbers of different types, you'll want to use the [`BeNumerically()`](#benumericallycomparator-string-compareto-interface) matcher. +#### Compare(expected interface{}, ...opts cmp.Option) + +uses go-cmp cmp.Equal to compare `ACTUAL` with `EXPECTED`. + +```go + Ω(ACTUAL).Should(Compare(EXPECTED)) + Ω(ACTUAL).Should(Compare(EXPECTED), cmpopts.EquateApproxTime(time.Millisecond)) +``` + +You can pass cmp.Option as options ,See the [go-cmp documentation](https://github.com/google/go-cmp) for more option information + #### BeEquivalentTo(expected interface{}) ```go From c1cfb65914f89527a24dd636cc58722a63a2e278 Mon Sep 17 00:00:00 2001 From: tank Date: Wed, 27 Apr 2022 10:00:47 +0800 Subject: [PATCH 2/2] doc: rename Compare -> BeComparableTo --- index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.md b/index.md index 2377eaf78..bc912d8c5 100644 --- a/index.md +++ b/index.md @@ -518,13 +518,13 @@ When both `ACTUAL` and `EXPECTED` are a very long strings, it will attempt to pr > For asserting equality between numbers of different types, you'll want to use the [`BeNumerically()`](#benumericallycomparator-string-compareto-interface) matcher. -#### Compare(expected interface{}, ...opts cmp.Option) +#### BeComparableTo(expected interface{}, ...opts cmp.Option) uses go-cmp cmp.Equal to compare `ACTUAL` with `EXPECTED`. ```go - Ω(ACTUAL).Should(Compare(EXPECTED)) - Ω(ACTUAL).Should(Compare(EXPECTED), cmpopts.EquateApproxTime(time.Millisecond)) + Ω(ACTUAL).Should(BeComparableTo(EXPECTED)) + Ω(ACTUAL).Should(BeComparableTo(EXPECTED), cmpopts.EquateApproxTime(time.Millisecond)) ``` You can pass cmp.Option as options ,See the [go-cmp documentation](https://github.com/google/go-cmp) for more option information