aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/content_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-07 21:25:05 +0200
committerJakob Unterwurzacher2015-09-07 21:25:05 +0200
commitb65882985dd7aa3ea7ae76c49d592ff30b353a8b (patch)
treeb66ef37e2b7ef015dfa6f0e96be7e10633d596e9 /cryptfs/content_test.go
parentaf0ae03db23f845dbcf8a6738057222ce7986bd8 (diff)
Add tests for name encryption and byte range splitting
Diffstat (limited to 'cryptfs/content_test.go')
-rw-r--r--cryptfs/content_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/cryptfs/content_test.go b/cryptfs/content_test.go
new file mode 100644
index 0000000..1900818
--- /dev/null
+++ b/cryptfs/content_test.go
@@ -0,0 +1,34 @@
+package cryptfs
+
+import (
+ "testing"
+ "fmt"
+)
+
+type testRange struct {
+ offset uint64
+ length uint64
+}
+
+func TestSplitRange(t *testing.T) {
+ var ranges []testRange
+
+ ranges = append(ranges, testRange{0, 70000},
+ testRange{0, 10},
+ testRange{234, 6511},
+ testRange{65444, 54},
+ testRange{6654, 8945})
+
+ var key [16]byte
+ f := NewCryptFS(key, true)
+
+ for _, r := range(ranges) {
+ parts := f.SplitRange(r.offset, r.length)
+ for _, p := range(parts) {
+ if p.Length > DEFAULT_PLAINBS || p.Offset >= DEFAULT_PLAINBS {
+ fmt.Printf("Test fail: n=%d, length=%d, offset=%d\n", p.BlockNo, p.Length, p.Offset)
+ t.Fail()
+ }
+ }
+ }
+}