Convert an example into a test
Unit tests are crucial for verifying the behavior of individual components in the unitConverter package. They help catch bugs and errors early, providing a safety net during code modification. Additionally, unit tests facilitate collaboration among developers and maintain code quality.
In this exercise, you will be given a code example from the unitConverter package. Converting examples into unit tests is a common first step in creating them. Successfully defining the expectation function is an important piece in unit test creation.
The testthat package and the unitConverter package at this point in development have been loaded for you.
이 연습은 강의의 일부입니다
Developing R Packages
연습 안내
- Review the
dist_converter()example. - Turn the given example into a unit test checking for similarity.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Review the example
dist_converter(100, unit_from = "meters", unit_to = "feet")
# Convert the example to a unit test comparing sameness
___