# 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/>.

#  willow_cutting_yield

library(testthat)

# Test 1: Check that the object is a tibble/data.frame and has 6 columns
test_that("willow_cutting_yield is a tibble data.frame with 6 columns", {
  expect_s3_class(willow_cutting_yield, "tbl_df")
  expect_s3_class(willow_cutting_yield, "tbl")
  expect_s3_class(willow_cutting_yield, "data.frame")
  expect_equal(ncol(willow_cutting_yield), 6)
  expect_equal(length(willow_cutting_yield), 6)
})

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

# Test 3: Validate column names
test_that("willow_cutting_yield has correct column names", {
  expect_named(
    willow_cutting_yield,
    c("ID", "Block", "Plot", "Type", "Size", "Yield")
  )
})

# Test 4: Check data types
test_that("willow_cutting_yield has correct data types", {
  expect_s3_class(willow_cutting_yield$ID, "factor")
  expect_equal(nlevels(willow_cutting_yield$ID), 25)
  expect_s3_class(willow_cutting_yield$Block, "factor")
  expect_equal(nlevels(willow_cutting_yield$Block), 5)
  expect_s3_class(willow_cutting_yield$Plot, "factor")
  expect_equal(nlevels(willow_cutting_yield$Plot), 5)
  expect_s3_class(willow_cutting_yield$Type, "factor")
  expect_equal(nlevels(willow_cutting_yield$Type), 5)
  expect_s3_class(willow_cutting_yield$Size, "factor")
  expect_equal(nlevels(willow_cutting_yield$Size), 3)
  expect_type(willow_cutting_yield$Yield, "double")
})
