Adds preconditions checks similar to what is available in Guava

As requested, here are the preconditions checks and accompanying tests. Will migrate our code to use these once accepted.
Let's nest all function-specific groups under a parent group "check" for better readability of test results.