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

# pig_weight_gain


library(testthat)

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

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

# Test 3: Validate column names
test_that("pig_weight_gain has correct column names", {
  expect_named(
    pig_weight_gain,
    c("pen", "treatment", "pig", "sex", "weight1", "weight2",
      "feed", "w0", "g", "h")
  )
})

# Test 4: Check data types
test_that("pig_weight_gain has correct data types", {
  expect_s3_class(pig_weight_gain$pen, "factor")
  expect_equal(nlevels(pig_weight_gain$pen), 5)
  expect_s3_class(pig_weight_gain$treatment, "factor")
  expect_equal(nlevels(pig_weight_gain$treatment), 3)
  expect_type(pig_weight_gain$pig, "integer")
  expect_s3_class(pig_weight_gain$sex, "factor")
  expect_equal(nlevels(pig_weight_gain$sex), 2)
  expect_type(pig_weight_gain$weight1, "double")
  expect_type(pig_weight_gain$weight2, "double")
  expect_type(pig_weight_gain$feed, "double")
  expect_type(pig_weight_gain$w0, "integer")
  expect_type(pig_weight_gain$g, "double")
  expect_type(pig_weight_gain$h, "double")
})



