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

# coffee_composition


library(testthat)

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

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

# Test 3: Validate column names
test_that("coffee_composition has correct column names", {
  expect_named(
    coffee_composition,
    c("Variety", "Country", "Water", "Bean Weight", "Extract Yield",
      "ph Value", "Free Acid", "Mineral Content", "Fat", "Caffine",
      "Trigonelline", "Chlorogenic Acid", "Neochlorogenic Acid",
      "Isochlorogenic Acid")
  )
})

# Test 4: Check data types
test_that("coffee_composition has correct data types", {
  expect_s3_class(coffee_composition$Variety, "factor")
  expect_equal(nlevels(coffee_composition$Variety), 2)
  expect_s3_class(coffee_composition$Country, "factor")
  expect_equal(nlevels(coffee_composition$Country), 29)
  expect_type(coffee_composition$Water, "double")
  expect_type(coffee_composition$`Bean Weight`, "double")
  expect_type(coffee_composition$`Extract Yield`, "double")
  expect_type(coffee_composition$`ph Value`, "double")
  expect_type(coffee_composition$`Free Acid`, "double")
  expect_type(coffee_composition$`Mineral Content`, "double")
  expect_type(coffee_composition$Fat, "double")
  expect_type(coffee_composition$Caffine, "double")
  expect_type(coffee_composition$Trigonelline, "double")
  expect_type(coffee_composition$`Chlorogenic Acid`, "double")
  expect_type(coffee_composition$`Neochlorogenic Acid`, "double")
  expect_type(coffee_composition$`Isochlorogenic Acid`, "double")
})

