github.com/gogf/gf/v2@v2.7.4/debug/gdebug/gdebug_z_unit_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_test
     8  
     9  import (
    10  	"fmt"
    11  	"testing"
    12  
    13  	"github.com/gogf/gf/v2/debug/gdebug"
    14  	"github.com/gogf/gf/v2/test/gtest"
    15  	"github.com/gogf/gf/v2/text/gstr"
    16  )
    17  
    18  func Test_CallerPackage(t *testing.T) {
    19  	gtest.C(t, func(t *gtest.T) {
    20  		t.Assert(gdebug.CallerPackage(), "github.com/gogf/gf/v2/test/gtest")
    21  	})
    22  }
    23  
    24  func Test_CallerFunction(t *testing.T) {
    25  	gtest.C(t, func(t *gtest.T) {
    26  		t.Assert(gdebug.CallerFunction(), "C")
    27  	})
    28  }
    29  
    30  func Test_CallerFilePath(t *testing.T) {
    31  	gtest.C(t, func(t *gtest.T) {
    32  		t.Assert(gstr.Contains(gdebug.CallerFilePath(), "gtest_util.go"), true)
    33  	})
    34  }
    35  
    36  func Test_CallerDirectory(t *testing.T) {
    37  	gtest.C(t, func(t *gtest.T) {
    38  		t.Assert(gstr.Contains(gdebug.CallerDirectory(), "gtest"), true)
    39  	})
    40  }
    41  
    42  func Test_CallerFileLine(t *testing.T) {
    43  	gtest.C(t, func(t *gtest.T) {
    44  		fmt.Println(gdebug.CallerFileLine())
    45  		t.Assert(gstr.Contains(gdebug.CallerFileLine(), "gtest_util.go:36"), true)
    46  	})
    47  }
    48  
    49  func Test_CallerFileLineShort(t *testing.T) {
    50  	gtest.C(t, func(t *gtest.T) {
    51  		t.Assert(gstr.Contains(gdebug.CallerFileLineShort(), "gtest_util.go:36"), true)
    52  	})
    53  }
    54  
    55  func Test_FuncPath(t *testing.T) {
    56  	gtest.C(t, func(t *gtest.T) {
    57  		t.Assert(gdebug.FuncPath(Test_FuncPath), "github.com/gogf/gf/v2/debug/gdebug_test.Test_FuncPath")
    58  	})
    59  }
    60  
    61  func Test_FuncName(t *testing.T) {
    62  	gtest.C(t, func(t *gtest.T) {
    63  		t.Assert(gdebug.FuncName(Test_FuncName), "gdebug_test.Test_FuncName")
    64  	})
    65  }
    66  
    67  func Test_PrintStack(t *testing.T) {
    68  	gtest.C(t, func(t *gtest.T) {
    69  		gdebug.PrintStack()
    70  	})
    71  }
    72  
    73  func Test_GoroutineId(t *testing.T) {
    74  	gtest.C(t, func(t *gtest.T) {
    75  		t.AssertGT(gdebug.GoroutineId(), 0)
    76  	})
    77  }
    78  
    79  func Test_Stack(t *testing.T) {
    80  	gtest.C(t, func(t *gtest.T) {
    81  		t.Assert(gstr.Contains(gdebug.Stack(), "gtest_util.go:36"), true)
    82  	})
    83  }
    84  
    85  func Test_StackWithFilter(t *testing.T) {
    86  	gtest.C(t, func(t *gtest.T) {
    87  		t.Assert(gstr.Contains(gdebug.StackWithFilter([]string{"github.com"}), "gtest_util.go:36"), true)
    88  	})
    89  }
    90  
    91  func Test_BinVersion(t *testing.T) {
    92  	gtest.C(t, func(t *gtest.T) {
    93  		t.AssertGT(len(gdebug.BinVersion()), 0)
    94  	})
    95  }
    96  
    97  func Test_BinVersionMd5(t *testing.T) {
    98  	gtest.C(t, func(t *gtest.T) {
    99  		t.AssertGT(len(gdebug.BinVersionMd5()), 0)
   100  	})
   101  }