Skip to content

Commit

Permalink
Added tested addJunk func
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsnew committed Mar 20, 2013
1 parent c4c5fc7 commit 097410a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tfh/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,12 @@ func trimDecryptedFile(file []byte, numToTrim int) (trimFile []byte) {
trimFile = file[:len(file)-numToTrim]
return
}

func addJunk(bs ([][]byte), numBytes int) (newBs [][]byte) {
newBs = bs[:]
for i := 0; i < numBytes; i++ {
junk := makeRandKey(numBytes)
newBs = append(newBs, junk)
}
return
}
19 changes: 19 additions & 0 deletions tfh/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,22 @@ func TestPadFile(t *testing.T) {
}
}
}

func TestaddJunk(t *testing.T) {
bs := make([][]byte, 2)
bs[0] = []byte{1, 2}
bs[1] = []byte{3}
newBs := addJunk(bs, 2)
if len(newBs) != 4 {
t.Fail()
return
}
for i, b := range bs {
for j, b2 := range b {
if uint(b2) != uint(newBs[i][j]) {
t.Fail()
return
}
}
}
}

0 comments on commit 097410a

Please sign in to comment.