...

Source file src/github.com/onsi/gomega/matchers/be_zero_matcher_test.go

Documentation: github.com/onsi/gomega/matchers

     1  package matchers_test
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo/v2"
     5  	. "github.com/onsi/gomega"
     6  )
     7  
     8  var _ = Describe("BeZero", func() {
     9  	It("succeeds for zero values for its type", func() {
    10  		Expect(nil).Should(BeZero())
    11  
    12  		Expect("").Should(BeZero())
    13  		Expect(" ").ShouldNot(BeZero())
    14  
    15  		Expect(0).Should(BeZero())
    16  		Expect(1).ShouldNot(BeZero())
    17  
    18  		Expect(0.0).Should(BeZero())
    19  		Expect(0.1).ShouldNot(BeZero())
    20  
    21  		// Expect([]int{}).Should(BeZero())
    22  		Expect([]int{1}).ShouldNot(BeZero())
    23  
    24  		// Expect(map[string]int{}).Should(BeZero())
    25  		Expect(map[string]int{"a": 1}).ShouldNot(BeZero())
    26  
    27  		Expect(myCustomType{}).Should(BeZero())
    28  		Expect(myCustomType{s: "a"}).ShouldNot(BeZero())
    29  	})
    30  
    31  	It("builds failure message", func() {
    32  		actual := BeZero().FailureMessage(123)
    33  		Expect(actual).To(Equal("Expected\n    <int>: 123\nto be zero-valued"))
    34  	})
    35  
    36  	It("builds negated failure message", func() {
    37  		actual := BeZero().NegatedFailureMessage(123)
    38  		Expect(actual).To(Equal("Expected\n    <int>: 123\nnot to be zero-valued"))
    39  	})
    40  })
    41  

View as plain text