github.com/leanovate/gopter@v0.2.9/prop_result_test.go (about) 1 package gopter_test 2 3 import ( 4 "testing" 5 6 "github.com/leanovate/gopter" 7 ) 8 9 func TestPropResult(t *testing.T) { 10 result := &gopter.PropResult{Status: gopter.PropProof} 11 if !result.Success() || result.Status.String() != "PROOF" { 12 t.Errorf("Invalid status: %#v", result) 13 } 14 other := &gopter.PropResult{Status: gopter.PropTrue} 15 if !result.And(other).Success() || result.And(other).Status.String() != "TRUE" { 16 t.Errorf("Invalid combined state: %#v", result.And(other)) 17 } 18 if !other.And(result).Success() || other.And(result).Status.String() != "TRUE" { 19 t.Errorf("Invalid combined state: %#v", other.And(result)) 20 } 21 22 result = &gopter.PropResult{Status: gopter.PropTrue} 23 if !result.Success() || result.Status.String() != "TRUE" { 24 t.Errorf("Invalid status: %#v", result) 25 } 26 if !result.And(other).Success() || result.And(other).Status.String() != "TRUE" { 27 t.Errorf("Invalid combined state: %#v", result.And(other)) 28 } 29 if !other.And(result).Success() || other.And(result).Status.String() != "TRUE" { 30 t.Errorf("Invalid combined state: %#v", other.And(result)) 31 } 32 33 result = &gopter.PropResult{Status: gopter.PropFalse} 34 if result.Success() || result.Status.String() != "FALSE" { 35 t.Errorf("Invalid status: %#v", result) 36 } 37 if result.And(other) != result { 38 t.Errorf("Invalid combined state: %#v", result.And(other)) 39 } 40 if other.And(result) != result { 41 t.Errorf("Invalid combined state: %#v", other.And(result)) 42 } 43 44 result = &gopter.PropResult{Status: gopter.PropUndecided} 45 if result.Success() || result.Status.String() != "UNDECIDED" { 46 t.Errorf("Invalid status: %#v", result) 47 } 48 if result.And(other) != result { 49 t.Errorf("Invalid combined state: %#v", result.And(other)) 50 } 51 if other.And(result) != result { 52 t.Errorf("Invalid combined state: %#v", other.And(result)) 53 } 54 55 result = &gopter.PropResult{Status: gopter.PropError} 56 if result.Success() || result.Status.String() != "ERROR" { 57 t.Errorf("Invalid status: %#v", result) 58 } 59 if result.And(other) != result { 60 t.Errorf("Invalid combined state: %#v", result.And(other)) 61 } 62 if other.And(result) != result { 63 t.Errorf("Invalid combined state: %#v", other.And(result)) 64 } 65 } 66 67 func TestNewPropResult(t *testing.T) { 68 trueResult := gopter.NewPropResult(true, "label") 69 if trueResult.Status != gopter.PropTrue || trueResult.Labels[0] != "label" { 70 t.Errorf("Invalid trueResult: %#v", trueResult) 71 } 72 falseResult := gopter.NewPropResult(false, "label") 73 if falseResult.Status != gopter.PropFalse || falseResult.Labels[0] != "label" { 74 t.Errorf("Invalid falseResult: %#v", falseResult) 75 } 76 }