aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/net/http2/flow_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/net/http2/flow_test.go')
-rw-r--r--vendor/golang.org/x/net/http2/flow_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/golang.org/x/net/http2/flow_test.go b/vendor/golang.org/x/net/http2/flow_test.go
index 859adf5..7ae82c7 100644
--- a/vendor/golang.org/x/net/http2/flow_test.go
+++ b/vendor/golang.org/x/net/http2/flow_test.go
@@ -49,5 +49,39 @@ func TestFlowAdd(t *testing.T) {
if f.add(1) {
t.Fatal("adding 1 to max shouldn't be allowed")
}
+}
+
+func TestFlowAddOverflow(t *testing.T) {
+ var f flow
+ if !f.add(0) {
+ t.Fatal("failed to add 0")
+ }
+ if !f.add(-1) {
+ t.Fatal("failed to add -1")
+ }
+ if !f.add(0) {
+ t.Fatal("failed to add 0")
+ }
+ if !f.add(1) {
+ t.Fatal("failed to add 1")
+ }
+ if !f.add(1) {
+ t.Fatal("failed to add 1")
+ }
+ if !f.add(0) {
+ t.Fatal("failed to add 0")
+ }
+ if !f.add(-3) {
+ t.Fatal("failed to add -3")
+ }
+ if got, want := f.available(), int32(-2); got != want {
+ t.Fatalf("size = %d; want %d", got, want)
+ }
+ if !f.add(1<<31 - 1) {
+ t.Fatal("failed to add 2^31-1")
+ }
+ if got, want := f.available(), int32(1+-3+(1<<31-1)); got != want {
+ t.Fatalf("size = %d; want %d", got, want)
+ }
}