コード例 #1
0
ファイル: equality.go プロジェクト: untoldwind/gorrd
// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual)
func ShouldResemble(actual interface{}, expected ...interface{}) string {
	if message := need(1, expected); message != success {
		return message
	}

	if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil {
		return serializer.serializeDetailed(expected[0], actual,
			fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual)))
	}

	return success
}
コード例 #2
0
ファイル: equality.go プロジェクト: RubidiumStudios/spruce
// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual)
func ShouldResemble(actual interface{}, expected ...interface{}) string {
	if message := need(1, expected); message != success {
		return message
	}

	if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil {
		expectedSyntax := fmt.Sprintf("%#v", expected[0])
		actualSyntax := fmt.Sprintf("%#v", actual)
		var message string
		if expectedSyntax == actualSyntax {
			message = fmt.Sprintf(shouldHaveResembledTypeMismatch, expected[0], actual, expected[0], actual)
		} else {
			message = fmt.Sprintf(shouldHaveResembled, expected[0], actual)
		}
		return serializer.serializeDetailed(expected[0], actual, message)
	}

	return success
}