edge-cases

Unit testing code that does date processing based on today's date

When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries. In our code we always get the current date deep down in our classes using DateTime.Now (.NET, in our case). How can you unit test such code? Is this where Dependency Injection ...

How should centenarian date of birth fields be handled?

"A centenarian is a person who has attained the age of 100 years or more." - Wikipedia There are several ways to prompt a user for Date of Birth, but let's say we've chosen the drop down method. How would you handle the oldest selectable date? Do you pick an arbitrary year (such as 1875) and populate to present? Or, do you consult so...

Multi-dimensional array edge/border conditions

Hi, I'm iterating over a 3 dimensional array (which is an image with 3 values for each pixel) to apply a 3x3 filter to each pixel as follows: //For each value on the image for (i=0;i<3*width*height;i++){ //For each filter value for (j=0;j<9;j++){ if (notOutsideEdgesCondition){ *(**(outArray)+i)+= *(**(pix...

C#: Edge Cases when removing a subset of a day from a TimeSpan on a daily basis

I'm trying to determine a TimeSpan (eg., time between logout and login), but with the caveat that a part of each day shouldn't be counted (eg., don't count the time between 7PM and 7AM on a given day). Removing that time from full days is easy enough, but what's the best way to check for parts of a day (eg., user logs out at 6PM and log...