library(testthat) library(AutoEDA) #========================================================== # pair_plot() #========================================================== test_that("pair_plot returns ggmatrix", { skip_if_not_installed("GGally") p <- pair_plot(iris) expect_s3_class( p, "ggmatrix" ) }) test_that("pair_plot works with numeric-only data", { skip_if_not_installed("GGally") expect_no_error( pair_plot(iris[, 1:4]) ) }) test_that("pair_plot works with tibble", { skip_if_not_installed("GGally") skip_if_not_installed("tibble") dat <- tibble::as_tibble(iris) expect_no_error( pair_plot(dat) ) }) test_that("pair_plot returns ggmatrix for numeric tibble", { skip_if_not_installed("GGally") skip_if_not_installed("tibble") dat <- tibble::as_tibble(iris[, 1:4]) p <- pair_plot(dat) expect_s3_class( p, "ggmatrix" ) }) #========================================================== # Missing values #========================================================== test_that("pair_plot rejects missing values", { skip_if_not_installed("GGally") dat <- iris dat$Sepal.Length[1:10] <- NA expect_error( pair_plot(dat), "Missing values" ) }) #========================================================== # Invalid input #========================================================== test_that("pair_plot rejects non-data.frame", { expect_error( pair_plot(1:10) ) }) test_that("pair_plot rejects NULL", { expect_error( pair_plot(NULL) ) }) test_that("pair_plot rejects empty data.frame", { expect_error( pair_plot(data.frame()) ) }) test_that("pair_plot rejects one numeric variable", { expect_error( pair_plot( data.frame( x = 1:10 ) ) ) }) test_that("pair_plot rejects non-numeric data", { expect_error( pair_plot( data.frame( A = letters[1:10], B = LETTERS[1:10] ) ) ) }) test_that("pair_plot rejects character vector", { expect_error( pair_plot(letters) ) }) test_that("pair_plot rejects list", { expect_error( pair_plot( list( x = 1:10, y = 11:20 ) ) ) }) test_that("pair_plot rejects mixed numeric and character data", { expect_error( pair_plot( data.frame( x = 1:10, y = letters[1:10] ) ) ) }) test_that("pair_plot rejects factor-only data", { expect_error( pair_plot( data.frame( A = factor(letters[1:10]), B = factor(LETTERS[1:10]) ) ) ) })