// Expect sorted string-length.
185491
func AutoLink(html string, names []string) string {
	doc, err := gq.NewDocumentFromReader(strings.NewReader(html))
	if err != nil {
		return html
	}

	for _, name := range names {
		if len([]rune(name)) <= 1 {
			continue
		}

		doc.Find("*").EachWithBreak(func(i int, s *gq.Selection) bool {
			if strings.Contains(s.Text(), name) {
				t := s.Text()
				h, _ := s.Html()
				if t != "" && h == "" {
					html := strings.Replace(t, name, fmt.Sprintf(`<a class="link-underline external" href="/d/%[1]s">%[1]s</a>`, name), 1)
					s.ReplaceWithHtml(html)
					return false
				}
			}
			return true
		})
	}

	res, err := doc.Find("body").Html()
	if err != nil {
		return html
	}

	return res
}
1206546
func AssertEqualStringArray(expected []string, result []string) {
	AssertType(expected, result)
	if expected == nil && result == nil {
		return
	}
	if len(expected) != len(result) {
		panic(fmt.Sprintf("Error: [] Different count of items\nExpected Value: %v\nResult: %v", expected, result))
	}
	for expectedIdx := range expected {
		elementExists := false
		for resultIdx := range result {
			if result[resultIdx] == expected[expectedIdx] {
				elementExists = true
			}
		}
		if !elementExists {
			panic(fmt.Sprintf("Error: [] Item missing: %v.\nExpected Value: %v\nResult: %v", expected[expectedIdx], expected, result))
		}
	}
}
1121575
func (d *Decoder) expect(t tokenType) {
	if tok := d.next(); tok.t != t {
		d.error(d.pos(tok), "expected %v found %v", t, tok)
	}
}
74988
func (arguments Arguments) LengthNonIndexed() int {
	out := 0
	for _, arg := range arguments {
		if !arg.Indexed {
			out++
		}
	}
	return out
}
383474
func (c Case) ShortString(length int) string {
	return fmt.Sprintf("%s%d [%s, %s]: %s(%s) = %s %s",
		c.Prefix, c.Prec, c.Trap, c.Mode, c.Op,
		join(c.Inputs, ", ", length), trunc(c.Output, length), c.Excep)
}
613603
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
	if h, ok := t.(tHelper); ok {
		h.Helper()
	}
	if assert.Len(t, object, length, msgAndArgs...) {
		return
	}
	t.FailNow()
}
614933
func ExpectNe(expected, actual interface{}, errorParts ...interface{}) {
	expectThat(
		actual,
		oglematchers.Not(oglematchers.Equals(expected)),
		1,
		errorParts)
}
114682
func (F *Frisby) ExpectJsonLength(path string, length int) *Frisby {
	Global.NumAsserts++
	json, err := F.Resp.Json()
	if err != nil {
		F.AddError(err.Error())
		return F
	}

	if path != "" {
		path_items := strings.Split(path, Global.PathSeparator)
		json = json.GetPath(path_items...)
	}

	ary, err := json.Array()
	if err != nil {
		F.AddError(err.Error())
		return F
	}
	L := len(ary)

	if L != length {
		err_str := fmt.Sprintf("Expect length to be %d, but got %d", length, L)
		F.AddError(err_str)
	}

	return F
}
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
}
776374
func sort(s1, s2 string) (shorter, longer string) {
	if utf8.RuneCountInString(s1) < utf8.RuneCountInString(s2) {
		return s1, s2
	}
	return s2, s1
}
107204
func (c *Conn) ExpectationsWereMet() error {
	errMsg := ""
	for _, err := range c.Errors {
		errMsg = fmt.Sprintf("%s%s\n", errMsg, err.Error())
	}

	for _, cmd := range c.commands {
		if !cmd.Called {
			errMsg = fmt.Sprintf("%sCommand %s with arguments %#v expected but never called.\n", errMsg, cmd.Name, cmd.Args)
		}
	}

	if errMsg != "" {
		return fmt.Errorf("%s", errMsg)
	}

	return nil
}
772192
func Examples(s string) string {
	if len(s) == 0 {
		return s
	}
	return normalizer{s}.trim().indent().string
}
765757
func (t *T) ExpectPanic(f func(), err interface{}, desc ...string) {
	prefix := ""
	if len(desc) > 0 {
		prefix = strings.Join(desc, " ") + ": "
	}
	defer func() {
		i := recover()
		if i == nil {
			t.Fatalf("%sFunction call did not panic as expected.", prefix)
		}
		t.Equal(i, err, "Raised value is not correct")
	}()
	f()
}
127537
func String(length, cardinality int) string {
	globalLk.Lock()
	defer globalLk.Unlock()
	return globalGen.String(length, cardinality)
}
424532
func (e Env) Sorted() []string {
	var r []string
	if len(e.env) > 0 {
		r = make([]string, 0, len(e.env))
		for _, v := range e.env {
			r = append(r, v)
		}
		sort.Strings(r)
	}
	return r
}
1151121
func (v *OrderedValues) StringGet(key string) string {
	if len(key) == 0 {
		return ""
	}
	return string(v.Get([]byte(key)))
}
427706
func (e *Expect) String(value string) *String {
	return NewString(e.config.Reporter, value)
}