github.com/rudderlabs/rudder-go-kit@v0.30.0/ro/ro_test.go (about)

     1  package ro
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestMemoize(t *testing.T) {
     8  	var count int
     9  	f := func() int {
    10  		count++
    11  		return count
    12  	}
    13  	g := Memoize(f)
    14  	if g() != 1 {
    15  		t.Fail()
    16  	}
    17  	if g() != 1 {
    18  		t.Fail()
    19  	}
    20  	if g() != 1 {
    21  		t.Fail()
    22  	}
    23  }