library(testthat) describe("temperature()", { it("generates output", { expect_match(temperature("celcius", 0), "273.15 kelvin or 32 farenheit") expect_match(temperature("c", 100), "373.15 kelvin or 212 farenheit") # Fahrenheit to Celsius and Kelvin expect_match(temperature("farenheit", 32), "0 celcius or 273.15 kelvin") expect_match(temperature("f", 212), "100 celcius or 373.15 kelvin") # Kelvin to Celsius and Fahrenheit expect_match(temperature("kelvin", 273.15), "0 celcius or 32 farenheit") expect_match(temperature("k", 373.15), "100 celcius or 212 farenheit") }) it("handles edge cases", { # Absolute zero in Celsius should convert correctly expect_match(temperature("c", -273.15), "0 kelvin or -459.67 farenheit") # Absolute zero in Fahrenheit should convert correctly expect_match(temperature("f", -459.67), "-273.15 celcius or 0 kelvin") # Absolute zero in Kelvin should convert correctly expect_match(temperature("k", 0), "-273.15 celcius or -459.67 farenheit") }) it("generates error when input is invalid", { # Test for NA value expect_error(temperature("c", NA), "Input is NA") # Test for non-numeric input expect_error(temperature("c", "thirty"), "Enter numeric input") # Test for invalid unit input expect_error(temperature("invalid_unit", 100), "Enter valid input") }) })