Exercise

Testing for equality

You can use expect_equal(), expect_equivalent() and expect_identical() in order to test whether the output of a function is as expected.

These three functions all have slightly different functionality:

  • expect_identical() checks that the values, attributes, and type of both objects are the same.
  • expect_equal() checks that the values, and attributes of both objects are the same. You can adjust how strict expect_equal() is by adjusting the tolerance parameter.
  • expect_equivalent() checks that the values, of both objects are the same.

Instructions

100 XP
  • Update the first test below so that the test passes; do this by adjusting the tolerance parameter.
  • Write a test comparing expected_result and result which does not produce an error.