xor_test.go 659 B

1234567891011121314151617181920212223242526272829
  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 cipher
  5. import (
  6. "bytes"
  7. "testing"
  8. )
  9. func TestXOR(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.Compare(d1, d2) != 0 {
  20. t.Error("not equal")
  21. }
  22. }
  23. }
  24. }
  25. }