1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 func TestFlow(t *testing.T) {
15 if got, want := st.available(), int32(3); got != want {
16 t.Errorf("available = %d; want %d", got, want)
19 if got, want := st.available(), int32(2); got != want {
20 t.Errorf("after parent setup, available = %d; want %d", got, want)
24 if got, want := conn.available(), int32(0); got != want {
25 t.Errorf("after taking 2, conn = %d; want %d", got, want)
27 if got, want := st.available(), int32(0); got != want {
28 t.Errorf("after taking 2, stream = %d; want %d", got, want)
32 func TestFlowAdd(t *testing.T) {
35 t.Fatal("failed to add 1")
38 t.Fatal("failed to add -1")
40 if got, want := f.available(), int32(0); got != want {
41 t.Fatalf("size = %d; want %d", got, want)
43 if !f.add(1<<31 - 1) {
44 t.Fatal("failed to add 2^31-1")
46 if got, want := f.available(), int32(1<<31-1); got != want {
47 t.Fatalf("size = %d; want %d", got, want)
50 t.Fatal("adding 1 to max shouldn't be allowed")