Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.
Write a single concise, correct, and well-formed test method for each of the following requirements. Remember the decorator (@Test
), and use the appropriate assertion (which should be one of assertEquals
, assertTrue
, or assertFalse
). Please look at the tests in the projects and notes if you’re not sure what they should look like. (1 point each)
- Test the
toUpperCase
method ofString
on the string"AsDf"
. - Test the
isDigit
method ofCharacter
on each of the characters'A'
,'&'
, and'2'
. (Use three assertions, all in one method.) - Test the
max
method ofMath
(in other words, testMath.max
) on twoint
arguments of your choice. - Test the
min
method ofMath
on the same arguments you used in the previous test.
An example that might help: Suppose I asked you to test whether the contains
method of String
correctly locates the string "fun"
within the string "functional"
. Your code could be as simple as:
@Test
public void testContains() {
assertTrue("functional".contains("fun"));
}
Note that each of your test methods will have no arguments (parameters) – the “arguments” that 3 and 4 above refer to are the arguments to the max
and min
methods that you’re testing, not to the test methods itself. Just pick two numbers and hardcode them.
Finally, if you’re not sure what any of the above do: Look them up in the Java API (usually, searching for “classname java se 8” will find it), and/or test them in Eclipse.