Test cases with boundary values

A code exercise of about 15 minutes: read the statement, solve «Test cases with boundary values» in the browser and get a review like in a real interview.

Code · 15 min
Loading…

Statement

A shop charges shipping by weight with shippingCost(kg): over 0 and up to 1 kg → 499 cents; over 1 and up to 5 kg → 799; over 5 and up to 30 kg → 1299. A weight of 0 or less, over 30 kg, or not a number returns null. Don't write the function: write shippingCases(), which returns at most 12 cases { kg, expected }. The tests check that your cases are right and that they catch versions of the function with typical bugs (for example a < where a <= belonged).