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

#  idn_rice_farms


library(testthat)

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

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

# Test 3: Validate column names
test_that("idn_rice_farms has correct column names", {
  expect_named(
    idn_rice_farms,
    c("id", "size", "status", "varieties", "bimas", "seed", "urea",
      "phosphate", "pesticide", "pseed", "purea", "pphosph",
      "hiredlabor", "famlabor", "totlabor", "wage", "goutput",
      "noutput", "price", "region")
  )
})

# Test 4: Check data types
test_that("idn_rice_farms has correct data types", {
  expect_type(idn_rice_farms$id, "integer")
  expect_type(idn_rice_farms$size, "double")
  expect_s3_class(idn_rice_farms$status, "factor")
  expect_equal(nlevels(idn_rice_farms$status), 3)
  expect_s3_class(idn_rice_farms$varieties, "factor")
  expect_equal(nlevels(idn_rice_farms$varieties), 3)
  expect_s3_class(idn_rice_farms$bimas, "factor")
  expect_equal(nlevels(idn_rice_farms$bimas), 3)
  expect_type(idn_rice_farms$seed, "integer")
  expect_type(idn_rice_farms$urea, "integer")
  expect_type(idn_rice_farms$phosphate, "integer")
  expect_type(idn_rice_farms$pesticide, "integer")
  expect_type(idn_rice_farms$pseed, "double")
  expect_type(idn_rice_farms$purea, "double")
  expect_type(idn_rice_farms$pphosph, "double")
  expect_type(idn_rice_farms$hiredlabor, "integer")
  expect_type(idn_rice_farms$famlabor, "integer")
  expect_type(idn_rice_farms$totlabor, "integer")
  expect_type(idn_rice_farms$wage, "double")
  expect_type(idn_rice_farms$goutput, "integer")
  expect_type(idn_rice_farms$noutput, "integer")
  expect_type(idn_rice_farms$price, "double")
  expect_s3_class(idn_rice_farms$region, "factor")
  expect_equal(nlevels(idn_rice_farms$region), 6)
})
