aboutsummaryrefslogtreecommitdiffstats
path: root/lib/structure_helpers_test.go
blob: a63825d913fb296d568a546db57d0bed2d3f0e49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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{
			{},
			{
				MIMEType: "multipart",
				Parts: []*models.BodyStructure{
					{},
					{},
				},
			},
			{},
		},
	}

	expected := [][]int{
		{1},
		{2, 1},
		{2, 2},
		{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])
		}
	}
}