tests/testthat/test-english_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/>.

# english_football

library(testthat)

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

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

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

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

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.