diff options
Diffstat (limited to 'utils/merkletrie/internal/fsnoder/new_test.go')
-rw-r--r-- | utils/merkletrie/internal/fsnoder/new_test.go | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/utils/merkletrie/internal/fsnoder/new_test.go b/utils/merkletrie/internal/fsnoder/new_test.go index 3e209a9..20f028b 100644 --- a/utils/merkletrie/internal/fsnoder/new_test.go +++ b/utils/merkletrie/internal/fsnoder/new_test.go @@ -40,15 +40,8 @@ func (s *FSNoderSuite) TestUnnamedInnerFails(c *C) { c.Assert(err, Not(IsNil)) } -func (s *FSNoderSuite) TestMalformedInnerName(c *C) { - _, err := New("(ab<>)") - c.Assert(err, Not(IsNil)) -} - func (s *FSNoderSuite) TestMalformedFile(c *C) { - _, err := New("(a<12>)") - c.Assert(err, Not(IsNil)) - _, err = New("(4<>)") + _, err := New("(4<>)") c.Assert(err, Not(IsNil)) _, err = New("(4<1>)") c.Assert(err, Not(IsNil)) @@ -66,13 +59,11 @@ func (s *FSNoderSuite) TestMalformedFile(c *C) { _, err = decodeFile([]byte("a<1?")) c.Assert(err, Not(IsNil)) - _, err = decodeEmptyFile([]byte("a<1>")) + _, err = decodeFile([]byte("a?>")) c.Assert(err, Not(IsNil)) - _, err = decodeEmptyFile([]byte("a?>")) + _, err = decodeFile([]byte("1<>")) c.Assert(err, Not(IsNil)) - _, err = decodeEmptyFile([]byte("1<>")) - c.Assert(err, Not(IsNil)) - _, err = decodeEmptyFile([]byte("a<?")) + _, err = decodeFile([]byte("a<?")) c.Assert(err, Not(IsNil)) } @@ -211,6 +202,32 @@ func (s *FSNoderSuite) TestDirWithEmtpyFileSameName(c *C) { check(c, input, expected) } +func (s *FSNoderSuite) TestDirWithFileLongContents(c *C) { + input := "(A(a<12>))" + + a1, err := newFile("a", "12") + c.Assert(err, IsNil) + A, err := newDir("A", []noder.Noder{a1}) + c.Assert(err, IsNil) + expected, err := newDir("", []noder.Noder{A}) + c.Assert(err, IsNil) + + check(c, input, expected) +} + +func (s *FSNoderSuite) TestDirWithFileLongName(c *C) { + input := "(A(abc<12>))" + + a1, err := newFile("abc", "12") + c.Assert(err, IsNil) + A, err := newDir("A", []noder.Noder{a1}) + c.Assert(err, IsNil) + expected, err := newDir("", []noder.Noder{A}) + c.Assert(err, IsNil) + + check(c, input, expected) +} + func (s *FSNoderSuite) TestDirWithFile(c *C) { input := "(A(a<1>))" |