// Expect calls t.Error and prints a nice comparison message when have != want.
// Especially useful in table-based tests when passing the loop index as iter.
355310
func Expect(t Errorf, have, want interface{}, iter ...int) {
	if !reflect.DeepEqual(have, want) {
		file, line := caller()
		t.Errorf(equal, file, line, exampleNum(iter), have, have, want, want)
	}
}
114975
func NotExist(values ...interface{}) (failureMessage string) {
	if !isNil(values[0]) {
		failureMessage = fmt.Sprintf("Expected `%v` is exist.", values[0])
	}
	return
}
1154348
func Reject(t Errorf, have, want interface{}, iter ...int) {
	if reflect.DeepEqual(have, want) {
		file, line := caller()
		t.Errorf(unequal, file, line, exampleNum(iter), have, have, want, want)
	}
}
4042
func (t *T) ExpectErrorf(err error, spec string, args ...interface{}) {
	if err != nil {
		return
	}
	prefix := fmt.Sprintf(spec, args...) + ": "
	t.Fatalf("%sError not returned when one was expected.", prefix)
}
923595
func Assert(t crossdock.T, tt TT, desc string, got interface{}, err error) {
	checks := crossdock.Checks(t)
	assert := crossdock.Assert(t)

	if tt.WantError != nil || tt.WantErrorLike != "" {
		if !checks.Error(err, "%v: expected failure but got: %v", desc, got) {
			return
		}
		if tt.WantError != nil {
			assert.Equal(tt.WantError, err, "%v: server returned error: %v", desc, err)
		}
		if tt.WantErrorLike != "" {
			assert.Contains(err.Error(), tt.WantErrorLike, "%v: server returned error: %v", desc, err)
		}
	} else {
		if !checks.NoError(err, "%v: call failed", desc) {
			return
		}
		if tt.Want != nil {
			assert.Equal(tt.Want, got, "%v: server returned: %v", desc, got)
		}
	}
}
153326
func (m *Mock) AssertExpectations(t testingT) bool {
	var somethingMissing bool
	var failedExpectations int

	// iterate through each expectation
	expectedQueries := m.expectedQueries()
	for _, expectedQuery := range expectedQueries {
		if !m.queryWasExecuted(expectedQuery) && expectedQuery.executed == 0 {
			somethingMissing = true
			failedExpectations++
			t.Logf("❌\t%s", expectedQuery.Query.Term.String())
		} else {
			m.mu.Lock()
			if expectedQuery.Repeatability > 0 {
				somethingMissing = true
				failedExpectations++
			} else {
				t.Logf("✅\t%s", expectedQuery.Query.Term.String())
			}
			m.mu.Unlock()
		}
	}

	if somethingMissing {
		t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe query you are testing needs to be executed %d more times(s).", len(expectedQueries)-failedExpectations, len(expectedQueries), failedExpectations)
	}

	return !somethingMissing
}
1050078
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
	if h, ok := t.(tHelper); ok {
		h.Helper()
	}
	if !Error(t, theError, msgAndArgs...) {
		return false
	}
	expected := errString
	actual := theError.Error()
	// don't need to use deep equals here, we know they are both strings
	if expected != actual {
		return Fail(t, fmt.Sprintf("Error message not equal:\n"+
			"expected: %q\n"+
			"actual  : %q", expected, actual), msgAndArgs...)
	}
	return true
}
515541
func ExpectGt(x, y interface{}, errorParts ...interface{}) {
	expectThat(x, oglematchers.GreaterThan(y), 1, errorParts)
}
1121559
func expectThat(
	x interface{},
	m oglematchers.Matcher,
	depth int,
	errorParts []interface{}) (passed bool) {
	// Check whether the value matches. If it does, we are finished.
	matcherErr := m.Matches(x)
	if matcherErr == nil {
		passed = true
		return
	}

	var r FailureRecord

	// Get information about the call site.
	var ok bool
	if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok {
		panic("expectThat: runtime.Caller")
	}

	r.FileName = path.Base(r.FileName)

	// Create an appropriate failure message. Make sure that the expected and
	// actual values align properly.
	relativeClause := ""
	if matcherErr.Error() != "" {
		relativeClause = fmt.Sprintf(", %s", matcherErr.Error())
	}

	r.Error = fmt.Sprintf(
		"Expected: %s\nActual:   %v%s",
		m.Description(),
		x,
		relativeClause)

	// Add the user error, if any.
	if len(errorParts) != 0 {
		v := reflect.ValueOf(errorParts[0])
		if v.Kind() != reflect.String {
			panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind()))
		}

		r.Error = fmt.Sprintf(
			"%s\n%s",
			r.Error,
			fmt.Sprintf(v.String(), errorParts[1:]...))
	}

	// Report the failure.
	AddFailureRecord(r)

	return
}
345508
func ExpectLt(x, y interface{}, errorParts ...interface{}) {
	expectThat(x, oglematchers.LessThan(y), 1, errorParts)
}
129289
func (dc *MockDBClient) ExpectRequest(query string, result *sqltypes.Result, err error) {
	select {
	case <-dc.done:
		dc.done = make(chan struct{})
	default:
	}
	dc.expect = append(dc.expect, &mockExpect{
		query:  query,
		result: result,
		err:    err,
	})
}
255991
func ShouldReceiveOnly(t *testing.T, expected string, body fn) {
	got, equals, _ := get(t, expected, body)
	if !equals {
		printLocation(t)
		t.Errorf("Expected: %#v", expected)
		t.Errorf("But got: %#v", got)
	}
}
286595
func Eq(expectedValue interface{}) *eqMatcher {
	matcher := new(eqMatcher)
	matcher.expectedValue = expectedValue
	return matcher
}
1024207
func (t *tree) expect(expected lex.TokenType, context string) lex.Token {
	token := t.Cur()
	if token.T != expected {
		t.unexpected(token, context)
	}
	return token
}
302255
func Error(t testing.TB, expr interface{}, args ...interface{}) {
	if IsNil(expr) { // 空值，必定没有错误
		assert(t, false, args, []interface{}{"Error 失败，实际值为 Nil：[%T]", expr})
		return
	}

	_, ok := expr.(error)
	assert(t, ok, args, []interface{}{"Error 失败，实际类型为[%T]", expr})
}
1307692
func (c *Websocket) Expect() *WebsocketMessage {
	switch {
	case c.chain.failed():
		return makeWebsocketMessage(c.chain)
	case c.conn == nil:
		c.chain.fail("\nunexpected read from failed WebSocket connection")
		return makeWebsocketMessage(c.chain)
	case c.isClosed:
		c.chain.fail("\nunexpected read from closed WebSocket connection")
		return makeWebsocketMessage(c.chain)
	case !c.setReadDeadline():
		return makeWebsocketMessage(c.chain)
	}
	var err error
	m := makeWebsocketMessage(c.chain)
	m.typ, m.content, err = c.conn.ReadMessage()
	if err != nil {
		if cls, ok := err.(*websocket.CloseError); ok {
			m.typ = websocket.CloseMessage
			m.closeCode = cls.Code
			m.content = []byte(cls.Text)
			c.printRead(m.typ, m.content, m.closeCode)
		} else {
			c.chain.fail(
				"\nexpected read WebSocket connection, "+
					"but got failure: %s", err.Error())
			return makeWebsocketMessage(c.chain)
		}
	} else {
		c.printRead(m.typ, m.content, m.closeCode)
	}
	return m
}
1059620
func expectationMatches(exp *InternalExpectation, args []interface{}) bool {
	matchers := exp.ArgMatchers
	if len(args) != len(matchers) {
		panic("expectationMatches: len(args)")
	}

	// Check each matcher.
	for i, matcher := range matchers {
		if err := matcher.Matches(args[i]); err != nil {
			return false
		}
	}

	return true
}