github.com/gogf/gf/v2@v2.7.4/debug/gdebug/gdebug_z_unit_internal_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  
     7  package gdebug
     8  
     9  import (
    10  	"testing"
    11  )
    12  
    13  func Test_getPackageFromCallerFunction(t *testing.T) {
    14  	dataMap := map[string]string{
    15  		"github.com/gogf/gf/v2/test/a":       "github.com/gogf/gf/v2/test/a",
    16  		"github.com/gogf/gf/v2/test/a.C":     "github.com/gogf/gf/v2/test/a",
    17  		"github.com/gogf/gf/v2/test/aa.C":    "github.com/gogf/gf/v2/test/aa",
    18  		"github.com/gogf/gf/v2/test/gtest.C": "github.com/gogf/gf/v2/test/gtest",
    19  	}
    20  	for functionName, packageName := range dataMap {
    21  		if result := getPackageFromCallerFunction(functionName); result != packageName {
    22  			t.Logf(`%s != %s`, result, packageName)
    23  			t.Fail()
    24  		}
    25  	}
    26  }