flightpathr

Tools to analyze aircraft and flight path data.
git clone https://git.eamoncaddigan.net/flightpathr.git
Log | Files | Refs | README | LICENSE

commit d3ff4809f196e6834cf5cc82707feda3e710d363
parent f624ff46dfbe3f66a1d7caedef663f4bf65df726
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Wed, 21 Sep 2016 13:18:16 -0400

More tests for createTrajectory(). Probably enough for now.

Diffstat:
Mtests/testthat/test_createTrajectory.R | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/tests/testthat/test_createTrajectory.R b/tests/testthat/test_createTrajectory.R @@ -26,3 +26,22 @@ test_that("Bearing and groundspeed calculations are correct", { expect_equal(trajectory$bearing[1:(timeSec-1)], bearing(trajectoryMat[1:(timeSec-1), ], trajectoryMat[2:timeSec, ])) }) + +test_that("Input types are checked", { + expect_error(createTrajectory(paste(trajectoryMat[, "lon"]), trajectoryMat[, "lat"]), + "\"longitude\" must be a numeric vector") + expect_error(createTrajectory(trajectoryMat[, "lon"], paste(trajectoryMat[, "lat"])), + "\"latitude\" must be a numeric vector") + expect_error(createTrajectory(trajectoryMat[, "lon"], trajectoryMat[, "lat"], paste(rep(2500, timeSec))), + "\"altitude\" must be a numeric vector") +}) + +test_that("Input lengths are checked", { + expect_error(createTrajectory(trajectoryMat[, "lon"], trajectoryMat[1, "lat"]), + paste("Vector \"latitude\" has length = 1, expected length =", timeSec)) + # Altitude can have length of 1 or timeSec, otherwise there should be an error + expect_error(createTrajectory(trajectoryMat[, "lon"], trajectoryMat[, "lat"], rep(2500, 2)), + paste("Vector \"altitude\" has length = 2, expected length =", timeSec)) + expect_equal(createTrajectory(trajectoryMat[, "lon"], trajectoryMat[, "lat"], 2500)$altitude, + rep(2500, timeSec)) +})