Home / File/ tree_test.go — gin Source File

tree_test.go — gin Source File

Architecture documentation for tree_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go GinCore Routing 1 imports 30 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  95642d64_cc2a_14f0_a93c_52464b2a60b9["tree_test.go"]
  e8c9ceab_299a_1e0e_919f_ddb404deb199["fmt"]
  95642d64_cc2a_14f0_a93c_52464b2a60b9 --> e8c9ceab_299a_1e0e_919f_ddb404deb199
  style 95642d64_cc2a_14f0_a93c_52464b2a60b9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2013 Julien Schmidt. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// at https://github.com/julienschmidt/httprouter/blob/master/LICENSE

package gin

import (
	"fmt"
	"reflect"
	"regexp"
	"strings"
	"testing"
)

// Used as a workaround since we can't compare functions or their addresses
var fakeHandlerValue string

func fakeHandler(val string) HandlersChain {
	return HandlersChain{func(c *Context) {
		fakeHandlerValue = val
	}}
}

type testRequests []struct {
	path       string
	nilHandler bool
	route      string
	ps         Params
}

func getParams() *Params {
	ps := make(Params, 0, 20)
	return &ps
}

func getSkippedNodes() *[]skippedNode {
	ps := make([]skippedNode, 0, 20)
	return &ps
}

func checkRequests(t *testing.T, tree *node, requests testRequests, unescapes ...bool) {
	unescape := false
	if len(unescapes) >= 1 {
		unescape = unescapes[0]
	}

	for _, request := range requests {
		value := tree.getValue(request.path, getParams(), getSkippedNodes(), unescape)

		if value.handlers == nil {
			if !request.nilHandler {
				t.Errorf("handle mismatch for route '%s': Expected non-nil handle", request.path)
			}
		} else if request.nilHandler {
			t.Errorf("handle mismatch for route '%s': Expected nil handle", request.path)
		} else {
			value.handlers[0](nil)
			if fakeHandlerValue != request.route {
				t.Errorf("handle mismatch for route '%s': Wrong handle (%s != %s)", request.path, fakeHandlerValue, request.route)
			}
// ... (961 more lines)

Domain

Subdomains

Dependencies

  • fmt

Frequently Asked Questions

What does tree_test.go do?
tree_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Routing subdomain.
What functions are defined in tree_test.go?
tree_test.go defines 30 function(s): TestCatchAllAfterSlash, TestCountParams, TestEmptyWildcardName, TestRedirectTrailingSlash, TestTreeAddAndGet, TestTreeCatchAllConflict, TestTreeCatchAllConflictRoot, TestTreeCatchMaxParams, TestTreeChildConflict, TestTreeDoubleWildcard, and 20 more.
What does tree_test.go depend on?
tree_test.go imports 1 module(s): fmt.
Where is tree_test.go in the architecture?
tree_test.go is located at tree_test.go (domain: GinCore, subdomain: Routing).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free