File: primitive_type_test.go

package info (click to toggle)
golang-github-zclconf-go-cty 1.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,464 kB
  • sloc: makefile: 2
file content (39 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (2)
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
package cty

import (
	"fmt"
	"testing"
)

func TestTypeIsPrimitiveType(t *testing.T) {
	tests := []struct {
		Type Type
		Want bool
	}{
		{String, true},
		{Number, true},
		{Bool, true},
		{DynamicPseudoType, false},
		{List(String), false},

		// Make sure our primitive constants are correctly constructed
		{True.Type(), true},
		{False.Type(), true},
		{Zero.Type(), true},
		{PositiveInfinity.Type(), true},
		{NegativeInfinity.Type(), true},
	}

	for i, test := range tests {
		t.Run(fmt.Sprintf("%d %#v", i, test.Type), func(t *testing.T) {
			got := test.Type.IsPrimitiveType()
			if got != test.Want {
				t.Errorf(
					"wrong result\ntype: %#v\ngot:  %#v\nwant: %#v",
					test.Type,
					test.Want, got,
				)
			}
		})
	}
}