# agridatasets - A Comprehensive Collection of Agricultural and Agronomic Datasets
# Version 0.1.1
# Copyright (C) 2026 Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# wheat_splitsplit


library(testthat)

# Test 1: Check that the object is a data.frame and has 9 columns
test_that("wheat_splitsplit is a data.frame with 9 columns", {
  expect_s3_class(wheat_splitsplit, "data.frame")
  expect_equal(ncol(wheat_splitsplit), 9)
  expect_equal(length(wheat_splitsplit), 9)
})

# Test 2: Check the number of rows
test_that("wheat_splitsplit has 160 rows", {
  expect_equal(nrow(wheat_splitsplit), 160)
})

# Test 3: Validate column names
test_that("wheat_splitsplit has correct column names", {
  expect_named(
    wheat_splitsplit,
    c("row", "col", "yield", "inoc", "trt", "gen", "dry", "dust", "block")
  )
})

# Test 4: Check data types
test_that("wheat_splitsplit has correct data types", {
  expect_type(wheat_splitsplit$row, "integer")
  expect_type(wheat_splitsplit$col, "integer")
  expect_type(wheat_splitsplit$yield, "integer")
  expect_s3_class(wheat_splitsplit$inoc, "factor")
  expect_equal(nlevels(wheat_splitsplit$inoc), 2)
  expect_type(wheat_splitsplit$trt, "integer")
  expect_s3_class(wheat_splitsplit$gen, "factor")
  expect_equal(nlevels(wheat_splitsplit$gen), 2)
  expect_s3_class(wheat_splitsplit$dry, "factor")
  expect_equal(nlevels(wheat_splitsplit$dry), 2)
  expect_s3_class(wheat_splitsplit$dust, "factor")
  expect_equal(nlevels(wheat_splitsplit$dust), 5)
  expect_s3_class(wheat_splitsplit$block, "factor")
  expect_equal(nlevels(wheat_splitsplit$block), 4)
})
