From 8ef7d3251d272a52d9ff54cbe97700be68aa42c0 Mon Sep 17 00:00:00 2001 From: Xiantank Date: Wed, 27 Apr 2022 10:03:38 +0800 Subject: [PATCH] doc: add Compare (#547) * doc: add Compare * doc: rename Compare -> BeComparableTo --- index.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.md b/index.md index 25820d8bb..bc912d8c5 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. +#### BeComparableTo(expected interface{}, ...opts cmp.Option) + +uses go-cmp cmp.Equal to compare `ACTUAL` with `EXPECTED`. + +```go + Ω(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 + #### BeEquivalentTo(expected interface{}) ```go