tests/testthat/test-italian_football.R

# sportsR - A Comprehensive Collection of Sports and Athletics Datasets
# Version 0.1.0
# 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/>.

# italian_football


library(testthat)

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

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

# Test 3: Validate column names
test_that("italian_football has correct column names", {
  expect_named(
    italian_football,
    c("Date", "Season", "home", "visitor", "FT", "hgoal", "vgoal", "tier")
  )
})

# Test 4: Check data types
test_that("italian_football has correct data types", {
  expect_s3_class(italian_football$Date, "Date")
  expect_type(italian_football$Date, "double")
  expect_type(italian_football$Season, "double")
  expect_type(italian_football$home, "character")
  expect_type(italian_football$visitor, "character")
  expect_type(italian_football$FT, "character")
  expect_type(italian_football$hgoal, "integer")
  expect_type(italian_football$vgoal, "integer")
  expect_type(italian_football$tier, "double")
})

Try the sportsR package in your browser

Any scripts or data that you put into this service are public.

sportsR documentation built on Aug. 27, 2026, 1:08 a.m.