Debian Codegraph @

lib/structure_helpers_test.go

raw
1 package lib_test
2
3 import (
4 "testing"
5
6 "git.sr.ht/~rjarry/aerc/lib"
7 "git.sr.ht/~rjarry/aerc/models"
8 )
9
10 func TestLib_FindAllNonMultipart(t *testing.T) {
11 testStructure := &models.BodyStructure{
12 MIMEType: "multipart",
13 Parts: []*models.BodyStructure{
14 {},
15 {
16 MIMEType: "multipart",
17 Parts: []*models.BodyStructure{
18 {},
19 {},
20 },
21 },
22 {},
23 },
24 }
25
26 expected := [][]int{
27 {1},
28 {2, 1},
29 {2, 2},
30 {3},
31 }
32
33 parts := lib.FindAllNonMultipart(testStructure, nil, nil)
34
35 if len(expected) != len(parts) {
36 t.Errorf("incorrect dimensions; expected: %v, got: %v", expected, parts)
37 }
38
39 for i := range parts {
40 if !lib.EqualParts(expected[i], parts[i]) {
41 t.Errorf("incorrect values; expected: %v, got: %v", expected[i], parts[i])
42 }
43 }
44 }