Skip to content

Commit 81a9c46

Browse files
authored
Merge pull request #311 from petertseng/triangle-json
triangle: Add JSON test data
2 parents d88ae65 + 301ca2f commit 81a9c46

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

triangle.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"#": [
3+
"Pursuant to discussion in #202,",
4+
"we have decided NOT to test triangles where all side lengths are positive but a + b = c.",
5+
"e.g: (2, 4, 2, Isosceles), (1, 3, 4, Scalene).",
6+
"It's true that the triangle inequality admits such triangles.",
7+
"These triangles have zero area, however.",
8+
"They're degenerate triangles with all three vertices collinear.",
9+
"(In contrast, we will test (0, 0, 0, Illegal), as it is a point).",
10+
11+
"The expectation are given as strings,",
12+
"but your language may use the appropriate representations.",
13+
"For example, enums, variants, or tagged unions all are viable candidates.",
14+
15+
"Your track may choose to have the 'illegal' result be another member of the enum/variant/union/etc.,",
16+
"or instead to signal an error/exception/etc. on an illegal triangle.",
17+
18+
"If appropriate for your track, you'll need to ensure that no pair of expected values are equal.",
19+
"Otherwise, an implementation that always returns a constant value may falsely pass the tests.",
20+
"See https://github.com/exercism/xgo/pull/208"
21+
],
22+
"cases": [
23+
{
24+
"description": "equilateral triangle has all sides equal",
25+
"sides": [2, 2, 2],
26+
"expected": "equilateral"
27+
},
28+
{
29+
"description": "larger equilateral triangle",
30+
"sides": [10, 10, 10],
31+
"expected": "equilateral"
32+
},
33+
{
34+
"description": "isosceles triangle with last two sides equal",
35+
"sides": [3, 4, 4],
36+
"expected": "isosceles"
37+
},
38+
{
39+
"description": "isosceles triangle with first two sides equal",
40+
"sides": [4, 4, 3],
41+
"expected": "isosceles"
42+
},
43+
{
44+
"description": "isosceles triangle with first and last sides equal",
45+
"sides": [4, 3, 4],
46+
"expected": "isosceles"
47+
},
48+
{
49+
"description": "isosceles triangle with unequal side larger than equal sides",
50+
"sides": [4, 7, 4],
51+
"expected": "isosceles"
52+
},
53+
{
54+
"description": "scalene triangle has no equal sides",
55+
"sides": [3, 4, 5],
56+
"expected": "scalene"
57+
},
58+
{
59+
"description": "larger scalene triangle",
60+
"sides": [10, 11, 12],
61+
"expected": "scalene"
62+
},
63+
{
64+
"description": "scalene triangle with sides in descending order",
65+
"sides": [5, 4, 2],
66+
"expected": "scalene"
67+
},
68+
{
69+
"#": "Your track may choose to skip this test and deal only with integers if appropriate",
70+
"description": "small scalene triangle with floating point values",
71+
"sides": [0.4, 0.6, 0.3],
72+
"expected": "scalene"
73+
},
74+
{
75+
"description": "a triangle violating the triangle inequality is illegal",
76+
"sides": [7, 3, 2],
77+
"expected": "illegal"
78+
},
79+
{
80+
"description": "two sides equal, but still violates triangle inequality",
81+
"sides": [1, 1, 3],
82+
"expected": "illegal"
83+
},
84+
{
85+
"description": "triangles with all sides zero are illegal",
86+
"sides": [0, 0, 0],
87+
"expected": "illegal"
88+
}
89+
]
90+
}

0 commit comments

Comments
 (0)