file_test.go 911 B

1234567891011121314151617181920212223242526272829303132
  1. package mscfb
  2. import (
  3. "testing"
  4. )
  5. func equal(a [][2]int64, b [][2]int64) bool {
  6. if len(a) != len(b) {
  7. return false
  8. }
  9. for i, v := range a {
  10. if v[0] != b[i][0] || v[1] != b[i][1] {
  11. return false
  12. }
  13. }
  14. return true
  15. }
  16. func TestCompress(t *testing.T) {
  17. a := [][2]int64{[2]int64{4608, 1024}, [2]int64{5632, 1024}, [2]int64{6656, 1024}, [2]int64{7680, 1024}, [2]int64{8704, 1024}, [2]int64{9728, 1024}, [2]int64{10752, 512}}
  18. ar := [][2]int64{[2]int64{4608, 6656}}
  19. a = compressChain(a)
  20. if !equal(a, ar) {
  21. t.Errorf("Streams compress fail; Expecting: %v, Got: %v", ar, a)
  22. }
  23. b := [][2]int64{[2]int64{4608, 1024}, [2]int64{6656, 1024}, [2]int64{7680, 1024}, [2]int64{8704, 1024}, [2]int64{10752, 512}}
  24. br := [][2]int64{[2]int64{4608, 1024}, [2]int64{6656, 3072}, [2]int64{10752, 512}}
  25. b = compressChain(b)
  26. if !equal(b, br) {
  27. t.Errorf("Streams compress fail; Expecting: %v, Got: %v", br, b)
  28. }
  29. }