diff options
Diffstat (limited to 'lib/structure_helpers_test.go')
-rw-r--r-- | lib/structure_helpers_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/structure_helpers_test.go b/lib/structure_helpers_test.go new file mode 100644 index 00000000..f670735c --- /dev/null +++ b/lib/structure_helpers_test.go @@ -0,0 +1,46 @@ +package lib_test + +import ( + "testing" + + "git.sr.ht/~rjarry/aerc/lib" + "git.sr.ht/~rjarry/aerc/models" +) + +func TestLib_FindAllNonMultipart(t *testing.T) { + + testStructure := &models.BodyStructure{ + MIMEType: "multipart", + Parts: []*models.BodyStructure{ + &models.BodyStructure{}, + &models.BodyStructure{ + MIMEType: "multipart", + Parts: []*models.BodyStructure{ + &models.BodyStructure{}, + &models.BodyStructure{}, + }, + }, + &models.BodyStructure{}, + }, + } + + expected := [][]int{ + []int{1}, + []int{2, 1}, + []int{2, 2}, + []int{3}, + } + + parts := lib.FindAllNonMultipart(testStructure, nil, nil) + + if len(expected) != len(parts) { + t.Errorf("incorrect dimensions; expected: %v, got: %v", expected, parts) + } + + for i := 0; i < len(parts); i++ { + if !lib.EqualParts(expected[i], parts[i]) { + t.Errorf("incorrect values; expected: %v, got: %v", expected[i], parts[i]) + } + } + +} |