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

# warriors_2016

library(testthat)

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

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

# Test 3: Validate column names
test_that("warriors_2016 has correct column names", {
  expect_named(
    warriors_2016,
    c("Game", "Date", "Location", "Opp", "Win", "Points", "OppPoints",
      "FG", "FGA", "FG3", "FG3A", "FT", "FTA", "Rebounds", "OffReb",
      "Assists", "Steals", "Blocks", "Turnovers", "Fouls", "OppFG",
      "OppFGA", "OppFG3", "OppFG3A", "OppFT", "OppFTA", "OppRebounds",
      "OppOffReb", "OppAssists", "OppSteals", "OppBlocks", "OppTurnovers", "OppFouls")
  )
})

# Test 4: Check data types
test_that("warriors_2016 has correct data types", {
  expect_type(warriors_2016$Game, "integer")

  expect_s3_class(warriors_2016$Date, "factor")
  expect_type(warriors_2016$Date, "integer")
  expect_equal(nlevels(warriors_2016$Date), 82)

  expect_s3_class(warriors_2016$Location, "factor")
  expect_type(warriors_2016$Location, "integer")
  expect_equal(nlevels(warriors_2016$Location), 2)

  expect_s3_class(warriors_2016$Opp, "factor")
  expect_type(warriors_2016$Opp, "integer")
  expect_equal(nlevels(warriors_2016$Opp), 29)

  expect_s3_class(warriors_2016$Win, "factor")
  expect_type(warriors_2016$Win, "integer")
  expect_equal(nlevels(warriors_2016$Win), 2)

  expect_type(warriors_2016$Points, "integer")
  expect_type(warriors_2016$OppPoints, "integer")
  expect_type(warriors_2016$FG, "integer")
  expect_type(warriors_2016$FGA, "integer")
  expect_type(warriors_2016$FG3, "integer")
  expect_type(warriors_2016$FG3A, "integer")
  expect_type(warriors_2016$FT, "integer")
  expect_type(warriors_2016$FTA, "integer")
  expect_type(warriors_2016$Rebounds, "integer")
  expect_type(warriors_2016$OffReb, "integer")
  expect_type(warriors_2016$Assists, "integer")
  expect_type(warriors_2016$Steals, "integer")
  expect_type(warriors_2016$Blocks, "integer")
  expect_type(warriors_2016$Turnovers, "integer")
  expect_type(warriors_2016$Fouls, "integer")
  expect_type(warriors_2016$OppFG, "integer")
  expect_type(warriors_2016$OppFGA, "integer")
  expect_type(warriors_2016$OppFG3, "integer")
  expect_type(warriors_2016$OppFG3A, "integer")
  expect_type(warriors_2016$OppFT, "integer")
  expect_type(warriors_2016$OppFTA, "integer")
  expect_type(warriors_2016$OppRebounds, "integer")
  expect_type(warriors_2016$OppOffReb, "integer")
  expect_type(warriors_2016$OppAssists, "integer")
  expect_type(warriors_2016$OppSteals, "integer")
  expect_type(warriors_2016$OppBlocks, "integer")
  expect_type(warriors_2016$OppTurnovers, "integer")
  expect_type(warriors_2016$OppFouls, "integer")
})

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.