0

I've also already asked this question in Stackoverflow, but I think I would get a better answer here.

I'm testing a triangle problem in PICT. I'm testing if a triangle is an equilateral triangle, an isosceles triangle, or a scalene triangle. The problem is that I never get the equilateral triangle as a result.

Side1:        5,6,7,8,9,10
Side2:        5,6,7,8,9,10
Side3:        5,6,7,8,9,10
Type:         equilateral, isosceles, scalene

IF (([Side1] = [Side2]) OR ([Side2] = [Side3]) OR ([Side3] = [Side1])) THEN [Type] = "isosceles"  ELSE [Type] = "scalene";
IF (([Side1] = [Side2]) AND ([Side2] = [Side3]) AND ([Side3] = [Side1])) THEN [Type] = "equilateral";

But the random thing here is that when I change the last line into

IF (([Side1] = [Side2]) AND ([Side2] = [Side3]) AND ([Side3] = [Side1])) THEN [Type] = "isosceles";

I randomly get values that would result in an equilateral triangle. How can I make sure I also have these values in my correct code?

1

The short answer is that an equilateral triangle is also an isosceles triangle.

Because you have the least restrictive check first, that check will identify all your equilateral triangles as isosceles triangles.

This is a pretty good example of why it's not a good idea to combine multiple checks into a single code routine: you aren't necessarily checking what you think you're checking.

I'd start by checking for equilateral first and see if that gives you the results you're expecting.

3
  • This is not the problem, if I check the code without the last line I wouldn't get values to make an equilateral triangle. If I would check the equilateral first, also no values that would gave the results of equilateral. I even did the check the isosceles with an XOR, still no results of a equilateral. The only way to get values that are equilateral, is for me to change the last line like I did in my example. – Kyra Oct 14 '14 at 11:10
  • @Kyra - this sounds like the logic engine has a few quirks to it. One thing you might try is removing the last condition from the equilateral check, since IF A = B AND B = C THEN A = C (making your third condition redundant - possibly this is confusing the logic engine?) – Kate Paulk Oct 14 '14 at 11:15
  • Also tried that one, confusing thing is that if I would use this code in any other Pairwise testing tool, and alter it to the syntax, it would work. I can't debug PICT, so I don't know exactly how it works, and why I get the results that I get. So kind of hoping that someone here does knows how it works. Like I said, works with other tools, so not really a big problem. But it's bugging me. – Kyra Oct 14 '14 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.