File: attr_test.go

package info (click to toggle)
golang-github-mmcloughlin-avo 0.0~git20200523.4439b6b-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,304 kB
  • sloc: xml: 71,029; asm: 13,138; sh: 179; makefile: 35
file content (44 lines) | stat: -rw-r--r-- 974 bytes parent folder | download
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 attr

import "testing"

func TestAttributeAsm(t *testing.T) {
	cases := []struct {
		Attribute Attribute
		Expect    string
	}{
		{0, "0"},
		{32768, "32768"},
		{1, "NOPROF"},
		{DUPOK, "DUPOK"},
		{RODATA | NOSPLIT, "NOSPLIT|RODATA"},
		{WRAPPER | 16384 | NOPTR, "NOPTR|WRAPPER|16384"},
		{NEEDCTXT + NOFRAME + TLSBSS, "NEEDCTXT|TLSBSS|NOFRAME"},
		{REFLECTMETHOD, "REFLECTMETHOD"},
		{TOPFRAME, "TOPFRAME"},
	}
	for _, c := range cases {
		got := c.Attribute.Asm()
		if got != c.Expect {
			t.Errorf("Attribute(%d).Asm() = %#v; expect %#v", c.Attribute, got, c.Expect)
		}
	}
}

func TestAttributeContainsTextFlags(t *testing.T) {
	cases := []struct {
		Attribute Attribute
		Expect    bool
	}{
		{0, false},
		{32768, false},
		{1, true},
		{DUPOK, true},
		{WRAPPER | 16384 | NOPTR, true},
	}
	for _, c := range cases {
		if c.Attribute.ContainsTextFlags() != c.Expect {
			t.Errorf("%s: ContainsTextFlags() expected %#v", c.Attribute.Asm(), c.Expect)
		}
	}
}