Let's say I am implementing something simple like searching a sorted list/array. The function (in c#) would look similar to:
static int FindIndex(int sortedList, int i);
I could implement and test this in terms of functionality, but for obvious reasons I would usually prefer a binary search over a linear search or something intentionally stupid.
So my question is: Should we attempt to write tests that gaurantee performance in terms of algorithmic complexity and if so, how?
I have started making arguments on both sides of the "should you" part of this question, but I'd like to see what people say without my arguments to prompt them.
In terms of "how", that gets very interesting:) You could see parameterizing the comparison operator and having a test whose comparison operator counts comparisons or something like that. But just because you can doesn't mean you should...
Has anyone else considered this (probably)? Thanks.