github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/protoc-gen-openapiv2/internal/genopenapi/cycle_test.go (about)

     1  package genopenapi
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestCycle(t *testing.T) {
     8  	for _, tt := range []struct {
     9  		max     int
    10  		attempt int
    11  		e       bool
    12  	}{
    13  		{
    14  			max:     3,
    15  			attempt: 3,
    16  			e:       true,
    17  		},
    18  		{
    19  			max:     5,
    20  			attempt: 6,
    21  		},
    22  		{
    23  			max:     1000,
    24  			attempt: 1001,
    25  		},
    26  	} {
    27  
    28  		c := newCycleChecker(tt.max)
    29  		var final bool
    30  		for i := 0; i < tt.attempt; i++ {
    31  			final = c.Check("a")
    32  			if !final {
    33  				break
    34  			}
    35  		}
    36  
    37  		if final != tt.e {
    38  			t.Errorf("got: %t wanted: %t", final, tt.e)
    39  		}
    40  	}
    41  }