3 ms·
That's not entirely fair - you haven't tested the branches or statements inside the sin function. However, even if the sin function is already tested elsewhere
by amouat 15y ago
That's not entirely fair - you haven't tested the branches or statements inside the sin function.
However, even if the sin function is already tested elsewhere, you will still need further testing to ensure that you are calling it correctly (e.g. not confusing degrees and radians).
EDIT: Yes, I read it wrong - clearly need coffee...
- Someone 15y agoThe original poster gave an implementation of sin(), not a unit test. That implementation has no branches in the source and, for any decent compiler, will not have any branches on the machine, either.
- wpietri 15y agoPerhaps you need to read it a little more closely? For the given function, he has indeed tested all the branches and statements.
- colomon 15y agoAlso, it's the simplest thing that can possibly work! (And for very small values of x is also the best possible implementation.)
- stephencanon 15y agoEven better: it's a correctly-rounded implementation for nearly half of the input space!
- deleted 15y ago[deleted]