tests/testthat/test_weather.R

context("linreg")


test_that("weather rejects incorect input", {
  expect_error(weather(as.vector(1)))
})
test_weather<-weather("Linkoping")

test_that("Output works", {
  expect_output(print(test_weather),"Country: Sweden")
 expect_output(print(test_weather),"City: Linkoping")
 expect_output(print(weather("Linköpings university")),"Linköpings university is not found.")
 expect_output(print(test_weather),"Local time:")
 expect_output(print(test_weather),"Temperature:")
 expect_output(print(test_weather),"Wind speed:")
 
})

test_that("Return is a list", {
  expect_equal(class(test_weather), "weather")
  expect_equal(length(test_weather),3)
  expect_equal(test_weather$location$lat,"58.417")
  expect_equal(test_weather$request$type,"City")
})
harjew/lab5G3 documentation built on Nov. 4, 2019, 1:28 p.m.