test_that("fourierdf returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fourierdf(y) expect_s3_class(res, "fourierdf") expect_true(is.numeric(res$statistic)) expect_true(is.finite(res$statistic)) expect_true(res$k >= 1 && res$k <= 5) expect_true(res$p >= 0) expect_length(res$cv, 3) expect_named(res$cv, c("1%", "5%", "10%")) expect_true(res$cv["1%"] < res$cv["5%"]) }) test_that("fouriergls returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fouriergls(y) expect_s3_class(res, "fouriergls") expect_true(is.finite(res$statistic)) expect_true(is.finite(res$cbar)) expect_length(res$cv, 3) }) test_that("fourierkpss returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fourierkpss(y) expect_s3_class(res, "fourierkpss") expect_true(is.finite(res$statistic)) expect_true(res$statistic > 0) # KPSS statistic is always positive expect_length(res$cv, 3) }) test_that("fourierlm returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fourierlm(y) expect_s3_class(res, "fourierlm") expect_true(is.finite(res$statistic)) expect_length(res$cv, 3) }) test_that("fourierfffff returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fourierfffff(y) expect_s3_class(res, "fourierfffff") expect_true(is.finite(res$statistic)) expect_true(res$kfr >= 0.1 && res$kfr <= 2.0) expect_length(res$cv, 3) }) test_that("print methods produce output without error", { set.seed(42) y <- cumsum(rnorm(80)) expect_output(print(fourierdf(y))) expect_output(print(fouriergls(y))) expect_output(print(fourierkpss(y))) expect_output(print(fourierlm(y))) expect_output(print(fourierfffff(y))) }) test_that("model=1 (no trend) works for all tests", { set.seed(1) y <- cumsum(rnorm(80)) expect_s3_class(fourierdf(y, model = 1), "fourierdf") expect_s3_class(fouriergls(y, model = 1), "fouriergls") expect_s3_class(fourierkpss(y, model = 1), "fourierkpss") expect_s3_class(fourierfffff(y, model = 1), "fourierfffff") }) test_that("fourierall runs all 6 tests", { set.seed(99) y <- cumsum(rnorm(80)) res <- suppressMessages(fourierall(y)) expect_named(res, c("lm", "adf", "gls", "kpss", "fffff", "dfdf")) }) test_that("fourierdfdf returns expected structure", { set.seed(42) y <- cumsum(rnorm(100)) res <- fourierdfdf(y) expect_s3_class(res, "fourierdfdf") expect_true(is.numeric(res$statistic)) expect_true(res$ks >= 1 && res$ks <= 3) expect_true(res$kc >= 1 && res$kc <= 3) expect_length(res$cv, 3) expect_named(res$cv, c("1%", "5%", "10%")) expect_output(print(res)) }) test_that("fourierdfdf bootstrap works", { set.seed(7) y <- cumsum(rnorm(60)) res <- fourierdfdf(y, bootstrap = TRUE, breps = 50) expect_s3_class(res, "fourierdfdf") expect_false(is.null(res$bcv)) expect_length(res$bcv, 3) expect_named(res$bcv, c("1%", "5%", "10%")) expect_true(res$bcv["1%"] < res$bcv["5%"]) })