1. values outside given bounds, like what the sqrt() runtime function does:
It is able able to return NaN or +INFINITY and sets errno=EDOM (unix only).
2. validate output for known value sets, with extremely large/small or postivie/negative values
3. Deliberately try to break the code - if it expects numeric data feed it text instead of numbers, for example. In all cases it should simply return an error, not crash.
It should NOT exit. Whether or not an exit is called depends on the rules of operation of the program, not on an individual function.
Consider reading 'The Pragmatic Programmer' - it explains how functions (algorithms) are supposed to behave when users are trying to feed them data.
First thank you for the good answer :p
secondly i want to ask you something:
if I have an algorithm that solves questions with order of arithmetic operations than my input values can be very long, so I am trying to input something extreme small like:(0+0) or something extreme long and big like:
(2+4*(7/9-(6+7)+(789-9900)+6788-9/(45-998))) and then if my algorithm solves this inputs then I can conclude that my algorithm solves all the inputs i will give him?(and after i will try to input him string and it will not crash)
There is something called formal programming or something similar that enables you to state post and preconditions allowing you to "prove" that your code does what you say it does (might have been called formal method)...
This is probably what I was thinking about... http://en.wikipedia.org/wiki/Formal_method