The reconcile package is used for DOM reconcilation in Isomorphic Go web applications.

flow_test.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.
  4. package http2
  5. import "testing"
  6. func TestFlow(t *testing.T) {
  7. var st flow
  8. var conn flow
  9. st.add(3)
  10. conn.add(2)
  11. if got, want := st.available(), int32(3); got != want {
  12. t.Errorf("available = %d; want %d", got, want)
  13. }
  14. st.setConnFlow(&conn)
  15. if got, want := st.available(), int32(2); got != want {
  16. t.Errorf("after parent setup, available = %d; want %d", got, want)
  17. }
  18. st.take(2)
  19. if got, want := conn.available(), int32(0); got != want {
  20. t.Errorf("after taking 2, conn = %d; want %d", got, want)
  21. }
  22. if got, want := st.available(), int32(0); got != want {
  23. t.Errorf("after taking 2, stream = %d; want %d", got, want)
  24. }
  25. }
  26. func TestFlowAdd(t *testing.T) {
  27. var f flow
  28. if !f.add(1) {
  29. t.Fatal("failed to add 1")
  30. }
  31. if !f.add(-1) {
  32. t.Fatal("failed to add -1")
  33. }
  34. if got, want := f.available(), int32(0); got != want {
  35. t.Fatalf("size = %d; want %d", got, want)
  36. }
  37. if !f.add(1<<31 - 1) {
  38. t.Fatal("failed to add 2^31-1")
  39. }
  40. if got, want := f.available(), int32(1<<31-1); got != want {
  41. t.Fatalf("size = %d; want %d", got, want)
  42. }
  43. if f.add(1) {
  44. t.Fatal("adding 1 to max shouldn't be allowed")
  45. }
  46. }