Homework 22: Tests
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 JUnit-style test methods for each of the following (one method per test, please) (1 point each):
- length()is correct for empty strings
- length()is correct for non-empty strings
- toUpperCase()works correctly
- indexOf(String str)works correctly when- stris not found
- indexOf(String str, int fromIndex)works correctly when- stris located both before and after- fromIndex(that is, set- fromIndexsuch that the index of the second occurrence of- stris what you expect to be found)
Use "yellow submarine yellow" as the non-empty String object in each relevant test, and "yellow" as the substring (str) to search for with indexOf.