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