Skip to content

Commit

Permalink
scenario tests for equality
Browse files Browse the repository at this point in the history
  • Loading branch information
Cathal McHale committed Jul 2, 2019
1 parent dd99e33 commit e85e10c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
10 changes: 7 additions & 3 deletions test/Ray.Domain.Test/Tuples/ComparePointsAndVectorsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public sealed class ComparePointsAndVectorsTests : Feature
private Vector4 _tuple = new Vector4(),
_comparisonInstance = new Vector4();

[Given(@"a <- tuple (\d\.\d) (-\d\.\d) (\d\.\d)")]
[Given(@"a = tuple (\d\.\d) (-\d\.\d) (\d\.\d)")]
public void InitializationValues_SetOnTupleInstance(float x, float y, float z)
{
_tuple.X = x;
_tuple.Y = y;
_tuple.Z = z;
}

[And(@"b <- tuple (\d\.\d) (-\d\.\d) (\d\.\d)")]
[And(@"b = tuple (\d\.\d) (-\d\.\d) (\d\.\d)")]
public void InitializationValues_SetOnComparisonInstance(float x, float y, float z)
{
_comparisonInstance.X = x;
Expand All @@ -33,7 +33,11 @@ public void InitializationValues_SetOnTupleInstance(float w)
_tuple.W = w;
}


[And(@"b.w = (\d\.\d)")]
public void InitializationValues_SetOnComparisonInstance(float w)
{
_comparisonInstance.W = w;
}

[Then(@"a.x = (\d\.\d)")]
public void ReadX_VerifyValue(float x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
I want the ability to create tuples (points and vectors)

Background:
Given a <- tuple 4.3 -4.2 3.1
Given a = tuple 4.3 -4.2 3.1

Scenario: A tuple with w=1.0 is a point
And a.w = 1.0
Expand All @@ -23,11 +23,11 @@ Scenario: A tuple with w=0.0 is a vector
And a.IsVector = true

Scenario: Identically initialized tuples are equal
And b <- tuple 4.3 -4.2 3.1
And b = tuple 4.3 -4.2 3.1
Then a = b is true

Scenario: Differently initialized tuples are not equal
And b <- tuple 5.4 -3.3 1.7
And b = tuple 5.4 -3.3 1.7
Then a = b is false

Scenario Outline: A tuple can be a point or a vector
Expand All @@ -44,4 +44,20 @@ Scenario Outline: A tuple can be a point or a vector

Examples: Weighted as Vector
| w | p | v |
| 0.0 | false | true |
| 0.0 | false | true |

Scenario Outline: Tuple equality depends on x, y, z and w
And b = tuple <x> <y> <z>
And b.w = <w>
Then a = b is <e>

Examples: Identical (x, y, z), w varies
| x | y | z | w | e |
| 4.3 | -4.2 | 3.1 | 1.0 | false |
| 4.3 | -4.2 | 3.1 | 0.0 | true |

Examples: Varying (x, y, z), w constant
| x | y | z | w | e |
| 4.3 | -4.2 | 3.1 | 0.0 | true | #first validate +ve expectation
| 3.4 | -2.4 | 1.3 | 0.0 | false |
| 4.3 | -4.2 | 3.2 | 0.0 | false |

0 comments on commit e85e10c

Please sign in to comment.