reflect_test.go 512 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package mhayaReflect
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. type FunStruct struct {
  7. }
  8. func (f *FunStruct) A() string {
  9. return "A method"
  10. }
  11. func test1111() {}
  12. func TestGetFuncName(t *testing.T) {
  13. f := &FunStruct{}
  14. result0 := GetFuncName(f)
  15. fmt.Println(result0)
  16. result1 := GetFuncName(f.A)
  17. fmt.Println(result1)
  18. result2 := GetFuncName(test1111)
  19. fmt.Println(result2)
  20. }
  21. func TestIsPtr(t *testing.T) {
  22. fmt.Println(IsPtr(nil))
  23. }
  24. func TestIsNotPtr(t *testing.T) {
  25. s := &FunStruct{}
  26. fmt.Println(IsNotPtr(s))
  27. }