File: prop_result_test.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 (76 lines) | stat: -rw-r--r-- 2,566 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package gopter_test

import (
	"testing"

	"github.com/leanovate/gopter"
)

func TestPropResult(t *testing.T) {
	result := &gopter.PropResult{Status: gopter.PropProof}
	if !result.Success() || result.Status.String() != "PROOF" {
		t.Errorf("Invalid status: %#v", result)
	}
	other := &gopter.PropResult{Status: gopter.PropTrue}
	if !result.And(other).Success() || result.And(other).Status.String() != "TRUE" {
		t.Errorf("Invalid combined state: %#v", result.And(other))
	}
	if !other.And(result).Success() || other.And(result).Status.String() != "TRUE" {
		t.Errorf("Invalid combined state: %#v", other.And(result))
	}

	result = &gopter.PropResult{Status: gopter.PropTrue}
	if !result.Success() || result.Status.String() != "TRUE" {
		t.Errorf("Invalid status: %#v", result)
	}
	if !result.And(other).Success() || result.And(other).Status.String() != "TRUE" {
		t.Errorf("Invalid combined state: %#v", result.And(other))
	}
	if !other.And(result).Success() || other.And(result).Status.String() != "TRUE" {
		t.Errorf("Invalid combined state: %#v", other.And(result))
	}

	result = &gopter.PropResult{Status: gopter.PropFalse}
	if result.Success() || result.Status.String() != "FALSE" {
		t.Errorf("Invalid status: %#v", result)
	}
	if result.And(other) != result {
		t.Errorf("Invalid combined state: %#v", result.And(other))
	}
	if other.And(result) != result {
		t.Errorf("Invalid combined state: %#v", other.And(result))
	}

	result = &gopter.PropResult{Status: gopter.PropUndecided}
	if result.Success() || result.Status.String() != "UNDECIDED" {
		t.Errorf("Invalid status: %#v", result)
	}
	if result.And(other) != result {
		t.Errorf("Invalid combined state: %#v", result.And(other))
	}
	if other.And(result) != result {
		t.Errorf("Invalid combined state: %#v", other.And(result))
	}

	result = &gopter.PropResult{Status: gopter.PropError}
	if result.Success() || result.Status.String() != "ERROR" {
		t.Errorf("Invalid status: %#v", result)
	}
	if result.And(other) != result {
		t.Errorf("Invalid combined state: %#v", result.And(other))
	}
	if other.And(result) != result {
		t.Errorf("Invalid combined state: %#v", other.And(result))
	}
}

func TestNewPropResult(t *testing.T) {
	trueResult := gopter.NewPropResult(true, "label")
	if trueResult.Status != gopter.PropTrue || trueResult.Labels[0] != "label" {
		t.Errorf("Invalid trueResult: %#v", trueResult)
	}
	falseResult := gopter.NewPropResult(false, "label")
	if falseResult.Status != gopter.PropFalse || falseResult.Labels[0] != "label" {
		t.Errorf("Invalid falseResult: %#v", falseResult)
	}
}