构造下述三角形问题的弱健壮的等价类测试用例。
三角形问题:输入三个不超过100的正整数作为三角形的三条边,判断三角形是等边三角形、等腰不等边三角形、完全不等边三角形还是不能构成三角形。
三角形的三条边记位 S = { a , b , c } S=\{a,b,c\} S={a,b,c},则划分弱健壮性的等价类如下所示
(1) S ⊆ N ∗ S \subseteq \N^{*} S⊆N∗
(2) S ⊆ Z − N ∗ S \subseteq \Z - \N^{*} S⊆Z−N∗
(3) ∀ s ∈ S , s ∈ [ 1 , 100 ] \forall s \in S,s\in[1,100] ∀s∈S,s∈[1,100]
(4) ∃ s ∈ S , s ∈ ( − ∞ , 1 ) ∪ ( 100 , + ∞ ) \exist s \in S, s \in (-\infty,1) \cup (100, +\infty) ∃s∈S,s∈(−∞,1)∪(100,+∞)
(5) a = b = c a=b=c a=b=c
(6) ∃ x 1 ∈ S , ∃ x 2 ∈ S − { x 1 } , x 3 ∈ S − { x 1 , x 2 } , ( x 1 ≠ x 3 ) ∧ ( x 1 = x 2 ) \exist \ x_1 \in S, \ \exist x_2 \in S-\{x_1\}, x_3 \in S-\{x_1, x_2\},(x_1 \neq x_3) \wedge (x_1=x_2) ∃ x1∈S, ∃x2∈S−{x1},x3∈S−{x1,x2},(x1̸=x3)∧(x1=x2)
(7) a ≠ b ≠ c a \neq b \neq c a̸=b̸=c
(8) ( a + b < = c ) ∨ ( a + c < = b ) ∨ ( b + c < = a ) (a+b<=c) \vee (a+c<=b) \vee (b+c<=a) (a+b<=c)∨(a+c<=b)∨(b+c<=a)
输入条件 | 有效等价类 | 无效等价类 |
---|---|---|
输入为正整数 | (1) | (2) |
输入的值不超过100 | (3) | (1) |
等边三角形 | (5) | (6),(7),(8) |
等腰不等边三角形 | (6) | (5),(7),(8) |
完全不等边三角形 | (7) | (5),(6),(8) |
不能构成三角形 | (8) | (5),(6),(7) |
Test Case | a | b | c | Expected Output |
---|---|---|---|---|
WN1 | 5 | 5 | 5 | Equilateral |
WN2 | 5 | 5 | 4 | Isosceles |
WN3 | 3 | 4 | 5 | Scalene |
WN4 | 1 | 1 | 2 | Not a triangle |
WR5 | -1 | 5 | 5 | Value of a is out of range |
WR6 | 5 | -1 | 5 | Value of b is out of range |
WR7 | 5 | 5 | -1 | Value of c is out of range |
WR8 | 101 | 5 | 5 | Value of a is out of range |
WR9 | 5 | 101 | 5 | Value of b is out of range |
WR10 | 5 | 5 | 101 | Value of c is out of range |
WR11 | 5.1 | 5 | 5 | Value of a is not int |
WR12 | 5 | 5.1 | 5 | Value of b is not int |
WR13 | 5 | 5 | 5.1 | Value of c is not int |