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

# hawaii_tree_growth

library(testthat)

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

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

# Test 3: Validate column names
test_that("hawaii_tree_growth has correct column names", {
  expect_named(
    hawaii_tree_growth,
    c("tree.code", "dbh", "toth", "crown.area", "comp.ind",
      "cai.1986", "cai.1987", "cai.1988")
  )
})

# Test 4: Check data types
test_that("hawaii_tree_growth has correct data types", {
  expect_s3_class(hawaii_tree_growth$tree.code, "factor")
  expect_equal(nlevels(hawaii_tree_growth$tree.code), 63)
  expect_type(hawaii_tree_growth$dbh, "double")
  expect_type(hawaii_tree_growth$toth, "double")
  expect_type(hawaii_tree_growth$crown.area, "double")
  expect_type(hawaii_tree_growth$comp.ind, "double")
  expect_type(hawaii_tree_growth$cai.1986, "double")
  expect_type(hawaii_tree_growth$cai.1987, "double")
  expect_type(hawaii_tree_growth$cai.1988, "double")
})
