github.com/haraldrudell/parl@v0.4.176/pfmt/no-recurse-v-print_test.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package pfmt
     7  
     8  import (
     9  	"fmt"
    10  	"testing"
    11  )
    12  
    13  type typeT struct{}
    14  
    15  var _ fmt.Stringer = &typeT{}
    16  
    17  func (valueT typeT) String() (s string) {
    18  	return f(valueT)
    19  }
    20  
    21  func f(valueT typeT) (s string) {
    22  	return fmt.Sprint(valueT)
    23  }
    24  
    25  func TestNoRecurseVPrint(t *testing.T) {
    26  
    27  	var valueT typeT
    28  
    29  	// runtime: goroutine stack exceeds 1000000000-byte limit
    30  	// fatal error: stack overflow
    31  	//_ = fmt.Sprint(valueT)
    32  
    33  	NoRecurseVPrint(valueT)
    34  }