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

# red_wine_quality

library(testthat)

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

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

# Test 3: Validate column names
test_that("red_wine_quality has correct column names", {
  expect_named(
    red_wine_quality,
    c("fixed_acidity", "volatile_acidity", "citric_acid", "residual_sugar",
      "chlorides", "free_sulfur_dioxide", "total_sulfur_dioxide", "density",
      "pH", "sulphates", "alcohol", "quality")
  )
})

# Test 4: Check data types
test_that("red_wine_quality has correct data types", {
  expect_type(red_wine_quality$fixed_acidity, "double")
  expect_type(red_wine_quality$volatile_acidity, "double")
  expect_type(red_wine_quality$citric_acid, "double")
  expect_type(red_wine_quality$residual_sugar, "double")
  expect_type(red_wine_quality$chlorides, "double")
  expect_type(red_wine_quality$free_sulfur_dioxide, "double")
  expect_type(red_wine_quality$total_sulfur_dioxide, "double")
  expect_type(red_wine_quality$density, "double")
  expect_type(red_wine_quality$pH, "double")
  expect_type(red_wine_quality$sulphates, "double")
  expect_type(red_wine_quality$alcohol, "double")
  expect_type(red_wine_quality$quality, "integer")
})
