File: prop_arg.go

package info (click to toggle)
golang-github-leanovate-gopter 0.2.9%2Bgit20210201.bbbf00e-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 696 kB
  • sloc: makefile: 37
file content (36 lines) | stat: -rw-r--r-- 947 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
package gopter

import (
	"fmt"
	"strings"
)

// PropArg contains information about the specific values for a certain property check.
// This is mostly used for reporting when a property has falsified.
type PropArg struct {
	Arg              interface{}
	ArgFormatted     string
	OrigArg          interface{}
	OrigArgFormatted string
	Label            string
	Shrinks          int
}

func (p *PropArg) String() string {
	return fmt.Sprintf("%v", p.Arg)
}

// PropArgs is a list of PropArg.
type PropArgs []*PropArg

// NewPropArg creates a new PropArg.
func NewPropArg(genResult *GenResult, shrinks int, value interface{}, valueFormated string, origValue interface{}, origValueFormated string) *PropArg {
	return &PropArg{
		Label:            strings.Join(genResult.Labels, ", "),
		Arg:              value,
		ArgFormatted:     valueFormated,
		OrigArg:          origValue,
		OrigArgFormatted: origValueFormated,
		Shrinks:          shrinks,
	}
}