ronantakizawa/codereview-bench huggingface dataset:
Repository: grpc/grpc-go
File: test/end2end_test.go (Go)

Code before:
		return te.cc, nil
	}
	opts, scheme := te.configDial()
	dw := &dialerWrapper{}
	// overwrite the dialer before
	opts = append(opts, grpc.WithDialer(dw.dialer))
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("NewClient(%q) = %v", scheme+te.srvAddr, err)
	}
	return te.cc, dw
}

func (te *test) clientConn(opts ...grpc.DialOption) *grpc.ClientConn {
	if te.cc != nil {
		return te.cc
	}
	var scheme string
	opts, scheme = te.configDial(opts...)
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("grpc.NewClient() failed(%q) = %v", scheme+te.srvAddr, err)
	}
	te.cc.Connect()
	return te.cc
}

func (te *test) declareLogNoise(phrases ...string) {
	te.restoreLogs = declareLogNoise(te.t, phrases...)
}

func (te *test) withServerTester(fn func(st *serverTester)) {
	c, err := te.e.dialer(te.srvAddr, 10*time.Second)
	if err != nil {
		te.t.Fatal(err)
	}
	defer c.Close()
	if te.e.security == "tls" {
		c = tls.Client(c, &tls.Config{
			InsecureSkipVerify: true,
			NextProtos:         []string{http2.NextProtoTLS},
		})
	}
	st := newServerTesterFromConn(te.t, c)
	st.greet()
	fn(st)
}

type lazyConn struct {

Review comment (suggestion):
Not actionable: Normally I would suggest moving the `Connect()` call to the calling functions because most of the callers wouldn't need it as they're making RPCs. In this case, there are 116 references, so we can keep the existing behaviour. 

Code after:
		return te.cc, nil
	}
	opts, scheme := te.configDial()
	dw := &dialerWrapper{}
	// overwrite the dialer before
	opts = append(opts, grpc.WithDialer(dw.dialer))
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("NewClient(%q) = %v", scheme+te.srvAddr, err)
	}
	return te.cc, dw
}

func (te *test) clientConn(opts ...grpc.DialOption) *grpc.ClientConn {
	if te.cc != nil {
		return te.cc
	}
	var scheme string
	opts, scheme = te.configDial(opts...)
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("grpc.NewClient(%q) failed: %v", scheme+te.srvAddr, err)
	}
	te.cc.Connect()
	return te.cc
}

func (te *test) declareLogNoise(phrases ...string) {
	te.restoreLogs = declareLogNoise(te.t, phrases...)
}

func (te *test) withServerTester(fn func(st *serverTester)) {
	c, err := te.e.dialer(te.srvAddr, 10*time.Second)
	if err != nil {
		te.t.Fatal(err)
	}
	defer c.Close()
	if te.e.security == "tls" {
		c = tls.Client(c, &tls.Config{
			InsecureSkipVerify: true,
			NextProtos:         []string{http2.NextProtoTLS},
		})
	}
	st := newServerTesterFromConn(te.t, c)
	st.greet()
	fn(st)
}

type lazyConn struct {
Repository: grpc/grpc-go
File: test/end2end_test.go (Go)

Code before:
func (te *test) clientConnWithConnControl() (*grpc.ClientConn, *dialerWrapper) {
	if te.cc != nil {
		return te.cc, nil
	}
	opts, scheme := te.configDial()
	dw := &dialerWrapper{}
	// overwrite the dialer before
	opts = append(opts, grpc.WithDialer(dw.dialer))
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("NewClient(%q) = %v", scheme+te.srvAddr, err)
	}
	return te.cc, dw
}

func (te *test) clientConn(opts ...grpc.DialOption) *grpc.ClientConn {
	if te.cc != nil {
		return te.cc
	}
	var scheme string
	opts, scheme = te.configDial(opts...)
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("grpc.NewClient() failed(%q) = %v", scheme+te.srvAddr, err)
	}
	te.cc.Connect()
	return te.cc
}

func (te *test) declareLogNoise(phrases ...string) {
	te.restoreLogs = declareLogNoise(te.t, phrases...)
}

func (te *test) withServerTester(fn func(st *serverTester)) {
	c, err := te.e.dialer(te.srvAddr, 10*time.Second)
	if err != nil {
		te.t.Fatal(err)
	}
	defer c.Close()
	if te.e.security == "tls" {
		c = tls.Client(c, &tls.Config{
			InsecureSkipVerify: true,
			NextProtos:         []string{http2.NextProtoTLS},
		})
	}
	st := newServerTesterFromConn(te.t, c)
	st.greet()
	fn(st)
}

Review comment (bug):
```suggestion
		te.t.Fatalf("grpc.NewClient(%q) failed: %v", scheme+te.srvAddr, err)
```

Code after:
func (te *test) clientConnWithConnControl() (*grpc.ClientConn, *dialerWrapper) {
	if te.cc != nil {
		return te.cc, nil
	}
	opts, scheme := te.configDial()
	dw := &dialerWrapper{}
	// overwrite the dialer before
	opts = append(opts, grpc.WithDialer(dw.dialer))
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("NewClient(%q) = %v", scheme+te.srvAddr, err)
	}
	return te.cc, dw
}

func (te *test) clientConn(opts ...grpc.DialOption) *grpc.ClientConn {
	if te.cc != nil {
		return te.cc
	}
	var scheme string
	opts, scheme = te.configDial(opts...)
	var err error
	te.cc, err = grpc.NewClient(scheme+te.srvAddr, opts...)
	if err != nil {
		te.t.Fatalf("grpc.NewClient(%q) failed: %v", scheme+te.srvAddr, err)
	}
	te.cc.Connect()
	return te.cc
}

func (te *test) declareLogNoise(phrases ...string) {
	te.restoreLogs = declareLogNoise(te.t, phrases...)
}

func (te *test) withServerTester(fn func(st *serverTester)) {
	c, err := te.e.dialer(te.srvAddr, 10*time.Second)
	if err != nil {
		te.t.Fatal(err)
	}
	defer c.Close()
	if te.e.security == "tls" {
		c = tls.Client(c, &tls.Config{
			InsecureSkipVerify: true,
			NextProtos:         []string{http2.NextProtoTLS},
		})
	}
	st := newServerTesterFromConn(te.t, c)
	st.greet()
	fn(st)
}
Repository: grpc/grpc-go
File: internal/resolver/delegatingresolver/delegatingresolver.go (Go)

Code before:
	wcc := &wrappingClientConn{
		stateListener: r.updateProxyResolverState,
		parent:        r,
	}
	return proxyBuilder.Build(proxyTarget, wcc, opts)
}

func (r *delegatingResolver) ResolveNow(o resolver.ResolveNowOptions) {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.ResolveNow(o)
	r.proxyResolver.ResolveNow(o)
}

func (r *delegatingResolver) Close() {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.Close()
	r.targetResolver = nil

	r.proxyResolver.Close()
	r.proxyResolver = nil
}

// parseDialTarget returns the network and address to pass to dialer.
func parseDialTarget(target string) (string, string) {
	net := "tcp"
	m1 := strings.Index(target, ":")
	m2 := strings.Index(target, ":/")
	// handle unix:addr which will fail with url.Parse
	if m1 >= 0 && m2 < 0 {
		if n := target[0:m1]; n == "unix" {
			return n, target[m1+1:]
		}
	}
	if m2 >= 0 {
		t, err := url.Parse(target)
		if err != nil {
			return net, target
		}
		scheme := t.Scheme
		addr := t.Path
		if scheme == "unix" {
			if addr == "" {
				addr = t.Host
			}
			return scheme, addr
		}
	}
	return net, target
}

Review comment (suggestion):
This should probably be exposed from its current location in `internal` instead of being copy/pasted here.

Code after:
}

func (r *delegatingResolver) ResolveNow(o resolver.ResolveNowOptions) {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.ResolveNow(o)
	r.proxyResolver.ResolveNow(o)
}

func (r *delegatingResolver) Close() {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.Close()
	r.targetResolver = nil

	r.proxyResolver.Close()
	r.proxyResolver = nil
}

func networkTypeFromAddr(addr resolver.Address) string {
	networkType, ok := networktype.Get(addr)
	if !ok {
		networkType, _ = transport.ParseDialTarget(addr.Addr)
	}
	return networkType
}

func isTCPAddressPresent(state *resolver.State) bool {
	for _, addr := range state.Addresses {
		if networkType := networkTypeFromAddr(addr); networkType == "tcp" {
			return true
		}
	}
	for _, endpoint := range state.Endpoints {
		for _, addr := range endpoint.Addresses {
			if networktype := networkTypeFromAddr(addr); networktype == "tcp" {
				return true
			}
		}
	}
	return false
}

// updateClientConnStateLocked constructs a combined list of addresses by
// pairing each proxy address with every target address of type TCP. For each
// pair, it creates a new [resolver.Address] using the proxy address and
// attaches the corresponding target address and user info as attributes. Target
// addresses that are not of type TCP are appended to the list as-is. The
// function returns nil if either resolver has not yet provided an update, and
// returns the result of ClientConn.UpdateState once both resolvers have
// provided at least one update.
Repository: grpc/grpc-go
File: internal/resolver/delegatingresolver/delegatingresolver.go (Go)

Code before:
	wcc := &wrappingClientConn{
		stateListener: r.updateProxyResolverState,
		parent:        r,
	}
	return proxyBuilder.Build(proxyTarget, wcc, opts)
}

func (r *delegatingResolver) ResolveNow(o resolver.ResolveNowOptions) {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.ResolveNow(o)
	r.proxyResolver.ResolveNow(o)

}

func (r *delegatingResolver) Close() {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.Close()
	r.targetResolver = nil

	r.proxyResolver.Close()
	r.proxyResolver = nil
}

func networkTypeFromAddr(addr resolver.Address) (string, resolver.Address) {
	networkType, ok := networktype.Get(addr)
	if !ok {
		networkType, addr.Addr = transport.ParseDialTarget(addr.Addr)
	}
	return networkType, addr
}

func tcpAddressPresent(state *resolver.State) bool {
	for _, addr := range state.Addresses {
		if networkType, _ := networkTypeFromAddr(addr); networkType == "tcp" {
			return true
		}
	}
	for _, endpoint := range state.Endpoints {
		for _, addr := range endpoint.Addresses {
			if networktype, _ := networkTypeFromAddr(addr); networktype == "tcp" {
				return true
			}
		}
	}
	return false
}

// updateClientConnStateLocked constructs a combined list of addresses by
// pairing each proxy address with every target address of type TCP. For each

Review comment (suggestion):
I think the second return value of type `resolver.Address` should be removed. It's the same as the input param.

Code after:
	proxyTarget := resolver.Target{URL: url}
	wcc := &wrappingClientConn{
		stateListener: r.updateProxyResolverState,
		parent:        r,
	}
	return proxyBuilder.Build(proxyTarget, wcc, opts)
}

func (r *delegatingResolver) ResolveNow(o resolver.ResolveNowOptions) {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.ResolveNow(o)
	r.proxyResolver.ResolveNow(o)
}

func (r *delegatingResolver) Close() {
	r.childMu.Lock()
	defer r.childMu.Unlock()
	r.targetResolver.Close()
	r.targetResolver = nil

	r.proxyResolver.Close()
	r.proxyResolver = nil
}

func networkTypeFromAddr(addr resolver.Address) string {
	networkType, ok := networktype.Get(addr)
	if !ok {
		networkType, _ = transport.ParseDialTarget(addr.Addr)
	}
	return networkType
}

func isTCPAddressPresent(state *resolver.State) bool {
	for _, addr := range state.Addresses {
		if networkType := networkTypeFromAddr(addr); networkType == "tcp" {
			return true
		}
	}
	for _, endpoint := range state.Endpoints {
		for _, addr := range endpoint.Addresses {
			if networktype := networkTypeFromAddr(addr); networktype == "tcp" {
				return true
			}
		}
	}
	return false
}

// updateClientConnStateLocked constructs a combined list of addresses by
// pairing each proxy address with every target address of type TCP. For each
Repository: grpc/grpc-go
File: xds/internal/balancer/ringhash/e2e/ringhash_balancer_test.go (Go)

Code before:
	}
	r.UpdateState(resolver.State{
		Endpoints: endpoints,
	})
	client := testgrpc.NewTestServiceClient(cc)

	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()

	// Intercept all connection attempts to the backends.
	var holds []*testutils.Hold
	for i := 0; i < len(backends); i++ {
		holds = append(holds, blockingDialer.Hold(backends[i]))
	}

	wg := sync.WaitGroup{}
	wg.Add(1)
	go func() {
		// Send 1 RPC and make sure this triggers at most 1 connection attempt.
		_, err := client.EmptyCall(ctx, &testpb.Empty{})
		if err != nil {
			t.Errorf("EmptyCall(): got %v, want success", err)
		}
		wg.Done()
	}()
	testutils.AwaitState(ctx, t, cc, connectivity.Connecting)

	// Wait for at least one connection attempt.
	nConn := 0
	for nConn == 0 {
		if ctx.Err() != nil {
			t.Fatal("Test timed out waiting for a connection attempt")
		}
		for _, hold := range holds {
			if hold.IsStarted() {
				nConn++
			}
		}
	}
	if wantMaxConn := 1; nConn > wantMaxConn {
		t.Fatalf("Got %d connection attempts, want at most %d", nConn, wantMaxConn)
	}

	// Do a second RPC. Since there should already be a SubChannel in
	// Connecting state, this should not trigger a connection attempt.
	wg.Add(1)
	go func() {
		_, err := client.EmptyCall(ctx, &testpb.Empty{})
		if err != nil {
			t.Errorf("EmptyCall(): got %v, want success", err)
		}

Review comment (suggestion):
Pickfirst will report `CONNECTING` as soon as it is created. It doesn't wait for a subchannel to report `CONNECTING`. That's the reason this check wasn't sufficient. Should we remove it? The check for 1 connection attempt below seems to be sufficient.

Code after:
	}
	r.UpdateState(resolver.State{
		Endpoints: endpoints,
	})
	client := testgrpc.NewTestServiceClient(cc)

	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()

	// Intercept all connection attempts to the backends.
	var holds []*testutils.Hold
	for i := 0; i < len(backends); i++ {
		holds = append(holds, blockingDialer.Hold(backends[i]))
	}

	wg := sync.WaitGroup{}
	wg.Add(1)
	go func() {
		// Send 1 RPC and make sure this triggers at most 1 connection attempt.
		_, err := client.EmptyCall(ctx, &testpb.Empty{})
		if err != nil {
			t.Errorf("EmptyCall(): got %v, want success", err)
		}
		wg.Done()
	}()

	// Wait for at least one connection attempt.
	nConn := 0
	for nConn == 0 {
		if ctx.Err() != nil {
			t.Fatal("Test timed out waiting for a connection attempt")
		}
		time.Sleep(1 * time.Millisecond)
		for _, hold := range holds {
			if hold.IsStarted() {
				nConn++
			}
		}
	}
	if wantMaxConn := 1; nConn > wantMaxConn {
		t.Fatalf("Got %d connection attempts, want at most %d", nConn, wantMaxConn)
	}

	// Do a second RPC. Since there should already be a SubChannel in
	// Connecting state, this should not trigger a connection attempt.
	wg.Add(1)
	go func() {
		_, err := client.EmptyCall(ctx, &testpb.Empty{})
		if err != nil {
			t.Errorf("EmptyCall(): got %v, want success", err)
		}
Repository: grpc/grpc-go
File: xds/internal/clients/config.go (Go)

Code before:
	// Locality is the location of the application including region, zone,
	// sub-zone.
	Locality Locality
	// Metadata provides additional context about the application by associating
	// arbitrary key-value pairs with it.
	Metadata any
	// UserAgentName is the user agent name of application.
	UserAgentName string
	// UserAgentVersion is the user agent version of application.
	UserAgentVersion string
}

// Locality represents the location of the xDS client application.
type Locality struct {
	// Region is the region of the xDS client application.
	Region string
	// Zone is the area within a region.
	Zone string
	// SubZone is the further subdivision within a zone.
	SubZone string
}

// MetricsReporter is used by the XDSClient to report metrics. Metric can be of
// any type.
//
// For example: see xdsclient/internal/test_metrics_reporter.go
type MetricsReporter interface {
	// ReportMetric reports a metric.
	ReportMetric(any)
}


Review comment (suggestion):
Documentation shouldn't link to internal test code.

If an example is needed, we can add a `clients_examples_test.go` and put an example there.  Otherwise, just text documentation should normally be fine.

Code after:
	// Locality is the location of the application including region, zone,
	// sub-zone.
	Locality Locality
	// Metadata provides additional context about the application by associating
	// arbitrary key-value pairs with it.
	Metadata any
	// UserAgentName is the user agent name of application.
	UserAgentName string
	// UserAgentVersion is the user agent version of application.
	UserAgentVersion string
}

// Locality represents the location of the xDS client application.
type Locality struct {
	// Region is the region of the xDS client application.
	Region string
	// Zone is the area within a region.
	Zone string
	// SubZone is the further subdivision within a zone.
	SubZone string
}

// MetricsReporter is used by the XDSClient to report metrics.
type MetricsReporter interface {
	// ReportMetric reports a metric. The metric will be one of the predefined
	// set of types depending on the client (XDSClient or LRSClient).
	//
	// Each client will produce different metrics. Please see the client's
	// documentation for a list of possible metrics events.
	ReportMetric(metric any)
}
Repository: grpc/grpc-go
File: xds/internal/clients/config.go (Go)

Code before:
	// Cluster is the name of the cluster the application belongs to.
	Cluster string
	// Locality is the location of the application including region, zone,
	// sub-zone.
	Locality Locality
	// Metadata provides additional context about the application by associating
	// arbitrary key-value pairs with it.
	Metadata any
	// UserAgentName is the user agent name of application.
	UserAgentName string
	// UserAgentVersion is the user agent version of application.
	UserAgentVersion string
}

// Locality represents the location of the xDS client application.
type Locality struct {
	// Region is the region of the xDS client application.
	Region string
	// Zone is the area within a region.
	Zone string
	// SubZone is the further subdivision within a zone.
	SubZone string
}

// MetricsReporter is used by the XDSClient to report metrics. Metric can be of
// any type.
//
// For example: see xdsclient/internal/test_metrics_reporter.go
type MetricsReporter interface {
	// ReportMetric reports a metric.
	ReportMetric(any)
}


Review comment (suggestion):
> Metric can be of any type.

Not really. The metric will be one of a predefined set of types depending on the client.  This should explain that each client will produce different metrics and to see that client's documentation for a list of possible metrics events.

Code after:
	// Cluster is the name of the cluster the application belongs to.
	Cluster string
	// Locality is the location of the application including region, zone,
	// sub-zone.
	Locality Locality
	// Metadata provides additional context about the application by associating
	// arbitrary key-value pairs with it.
	Metadata any
	// UserAgentName is the user agent name of application.
	UserAgentName string
	// UserAgentVersion is the user agent version of application.
	UserAgentVersion string
}

// Locality represents the location of the xDS client application.
type Locality struct {
	// Region is the region of the xDS client application.
	Region string
	// Zone is the area within a region.
	Zone string
	// SubZone is the further subdivision within a zone.
	SubZone string
}

// MetricsReporter is used by the XDSClient to report metrics.
type MetricsReporter interface {
	// ReportMetric reports a metric. The metric will be one of the predefined
	// set of types depending on the client (XDSClient or LRSClient).
	//
	// Each client will produce different metrics. Please see the client's
	// documentation for a list of possible metrics events.
	ReportMetric(metric any)
}
Repository: grpc/grpc-go
File: internal/transport/http_util_test.go (Go)

Code before:
 * limitations under the License.
 *
 */

package transport

import (
	"errors"
	"fmt"
	"io"
	"math"
	"net"
	"reflect"
	"testing"
	"time"
)

func (s) TestDecodeTimeout(t *testing.T) {
	for _, test := range []struct {
		// input
		s string
		// output
		d   time.Duration
		err error
	}{
		{"0S", 0, nil},
		{"00000000S", 0, nil},
		{"00000001n", time.Nanosecond, nil},
		{"10u", time.Microsecond * 10, nil},
		{"00000010m", time.Millisecond * 10, nil},
		{"1234S", time.Second * 1234, nil},
		{"00000001M", time.Minute, nil},
		{"09999999S", time.Second * 9999999, nil},
		{"99999999S", time.Second * 99999999, nil},
		{"99999999M", time.Minute * 99999999, nil},
		{"2562047H", time.Hour * 2562047, nil},
		{"2562048H", time.Duration(math.MaxInt64), nil},
		{"99999999H", time.Duration(math.MaxInt64), nil},
		{"-1S", 0, fmt.Errorf("strconv.ParseUint: parsing %q: invalid syntax", "-1")},
		{"1234x", 0, fmt.Errorf("transport: timeout unit is not recognized: %q", "1234x")},
		{"1234s", 0, fmt.Errorf("transport: timeout unit is not recognized: %q", "1234s")},
		{"1234", 0, fmt.Errorf("transport: timeout unit is not recognized: %q", "1234")},
		{"1", 0, fmt.Errorf("transport: timeout string is too short: %q", "1")},
		{"", 0, fmt.Errorf("transport: timeout string is too short: %q", "")},
		{"9a1S", 0, fmt.Errorf("strconv.ParseUint: parsing %q: invalid syntax", "9a1")},
		{"000000000S", 0, fmt.Errorf("transport: timeout string is too long: %q", "000000000S")},
	} {
		d, err := decodeTimeout(test.s)
		if d != test.d || fmt.Sprint(err) != fmt.Sprint(test.err) {
			t.Errorf("timeoutDecode(%q) = %d, %v, want %d, %v", test.s, int64(d), err, int64(test.d), test.err)
		}

Review comment (suggestion):
The [spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests) mentions that `TimeoutValue` should be a positive integer. So this should ideally return an error on validation.

Code after:
 * limitations under the License.
 *
 */

package transport

import (
	"errors"
	"fmt"
	"io"
	"math"
	"net"
	"reflect"
	"testing"
	"time"
)

func (s) TestDecodeTimeout(t *testing.T) {
	for _, test := range []struct {
		// input
		s string
		// output
		d       time.Duration
		wantErr bool
	}{

		{"00000001n", time.Nanosecond, false},
		{"10u", time.Microsecond * 10, false},
		{"00000010m", time.Millisecond * 10, false},
		{"1234S", time.Second * 1234, false},
		{"00000001M", time.Minute, false},
		{"09999999S", time.Second * 9999999, false},
		{"99999999S", time.Second * 99999999, false},
		{"99999999M", time.Minute * 99999999, false},
		{"2562047H", time.Hour * 2562047, false},
		{"2562048H", time.Duration(math.MaxInt64), false},
		{"99999999H", time.Duration(math.MaxInt64), false},
		{"-1S", 0, true},
		{"1234x", 0, true},
		{"1234s", 0, true},
		{"1234", 0, true},
		{"1", 0, true},
		{"", 0, true},
		{"9a1S", 0, true},
		{"0S", 0, true}, // PROTOCOL-HTTP2.md requires positive integers
		{"00000000S", 0, true},
		{"000000000S", 0, true},
	} {
		d, err := decodeTimeout(test.s)
		gotErr := err != nil
		if d != test.d || gotErr != test.wantErr {