Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainItem ¶
ContainItem checks if an array contains an item that meets a matcher's criteria.
Example ¶
t := &SpyTB{} anArray := []string{"HELLO", "WORLD"} Expect(t, anArray).To(ContainItem(HaveAllCaps)) fmt.Println(t.Result())
Output: Test passed
Example (Fail) ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(ContainItem(HaveAllCaps)) fmt.Println(t.Result())
Output: Test failed: [expected [hello world] to contain an item in all caps, but it did not]
func EveryItem ¶
EveryItem checks if every item in an array meets a matcher's criteria.
Example ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(EveryItem(Containing("o"))) fmt.Println(t.Result())
Output: Test passed
Example (Fail) ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(EveryItem(Containing("h"))) fmt.Println(t.Result())
Output: Test failed: [expected [hello world] to have every item contain "h"]
func HaveSize ¶
HaveSize checks if an array's size meets a matcher's criteria.
Example ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(HaveSize[string](EqualTo(2))) fmt.Println(t.Result())
Output: Test passed
Example (Fail) ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(HaveSize[string](EqualTo(3))) fmt.Println(t.Result())
Output: Test failed: [expected [hello world] to have a size be equal to 3, but it was 2]
func ShallowEquals ¶ added in v0.6.0
func ShallowEquals[T comparable](other []T) pepper.Matcher[[]T]
ShallowEquals checks if two slices are equal, only works with slices of comparable types.
Example ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(ShallowEquals([]string{"hello", "world"})) fmt.Println(t.Result())
Output: Test passed
Example (Fail) ¶
t := &SpyTB{} anArray := []string{"hello", "world"} Expect(t, anArray).To(ShallowEquals([]string{"goodbye", "world"})) fmt.Println(t.Result())
Output: Test failed: [expected [hello world] to be equal to [goodbye world]]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.