I used TDD to develop a class that in one part looks like this
class A
{
public:
// methods, members, stuff
private:
std::vector<int> vectorA;
std::vector<int> vectorB;
bool isAbove(double lowerBound)
{
double x = (double)vectorA.size() / vectorB.size();
return x > lowerBound;
}
// more methods, members, stuff
};
All tests pass even if vectorB.size()
is actually 0
when isAbove()
is called - no exception thrown. It doesn't matter if I build with debug infos or not. However debugging showed that x
is -nan(ind)
when compared to lowerBound
(as you may have expected).
I use VS2015 with VS2013 (v120) toolset. ideone.com produces the same result.
Should I check for vectorB.size() == 0
before calculating x
although (by the process of TDD) this isn't needed?