Do you use constants from the implementation in your test cases?

Viewed 17182

Let's say you have some code like this (in a made-up langague, since it does not matter for this question):

constant float PI = 3.14;
float getPi() 
{ 
   return PI;
}

Would you test it like this:

testPiIs3point14()
{
   // Test using literal in test case
   AssertEquals( getPi(), 3.14 );
}

Or like this:

testPiIs3Point14()
{
   // Test using constant from implementation in test case
   AssertEquals( getPi(), PI );
}

In other words, do you use constants from your system under test in your test cases? Or is this considered an implementation detail?

7 Answers
Related