1
0

xor_test.go 655 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2013 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 kcp
  5. import (
  6. "bytes"
  7. "testing"
  8. )
  9. func TestXORBytes(t *testing.T) {
  10. for alignP := 0; alignP < 2; alignP++ {
  11. for alignQ := 0; alignQ < 2; alignQ++ {
  12. for alignD := 0; alignD < 2; alignD++ {
  13. p := make([]byte, 1024)[alignP:]
  14. q := make([]byte, 1024)[alignQ:]
  15. d1 := make([]byte, 1024+alignD)[alignD:]
  16. d2 := make([]byte, 1024+alignD)[alignD:]
  17. xorBytes(d1, p, q)
  18. safeXORBytes(d2, p, q)
  19. if !bytes.Equal(d1, d2) {
  20. t.Error("not equal")
  21. }
  22. }
  23. }
  24. }
  25. }