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

# rice_wheat_production

library(testthat)

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

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

# Test 3: Validate column names
test_that("rice_wheat_production has correct column names", {
  expect_named(
    rice_wheat_production,
    c("Food", "Year", "Area", "Production", "Yield", "Irrigated")
  )
})

# Test 4: Check data types
test_that("rice_wheat_production has correct data types", {
  expect_s3_class(rice_wheat_production$Food, "factor")
  expect_equal(nlevels(rice_wheat_production$Food), 2)
  expect_s3_class(rice_wheat_production$Year, "factor")
  expect_equal(nlevels(rice_wheat_production$Year), 55)
  expect_type(rice_wheat_production$Area, "double")
  expect_type(rice_wheat_production$Production, "double")
  expect_type(rice_wheat_production$Yield, "integer")
  expect_s3_class(rice_wheat_production$Irrigated, "factor")
  expect_equal(nlevels(rice_wheat_production$Irrigated), 86)
})
