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

# wta_matches_2019

library(testthat)

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

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

# Test 3: Validate column names
test_that("wta_matches_2019 has correct column names", {
  expect_named(
    wta_matches_2019,
    c("WTA", "Location", "Tournament", "Date", "Tier", "Court", "Surface",
      "Round", "Best.of", "Winner", "Loser", "WRank", "LRank", "WPts",
      "LPts", "W1", "L1", "W2", "L2", "W3", "L3", "Wsets", "Lsets",
      "Comment", "B365W", "B365L", "PSW", "PSL", "MaxW", "MaxL", "AvgW", "AvgL")
  )
})

# Test 4: Check data types
test_that("wta_matches_2019 has correct data types", {
  expect_type(wta_matches_2019$WTA, "integer")
  expect_type(wta_matches_2019$Location, "character")
  expect_type(wta_matches_2019$Tournament, "character")
  expect_type(wta_matches_2019$Date, "character")
  expect_type(wta_matches_2019$Tier, "character")
  expect_type(wta_matches_2019$Court, "character")
  expect_type(wta_matches_2019$Surface, "character")
  expect_type(wta_matches_2019$Round, "character")
  expect_type(wta_matches_2019$Best.of, "integer")
  expect_type(wta_matches_2019$Winner, "character")
  expect_type(wta_matches_2019$Loser, "character")
  expect_type(wta_matches_2019$WRank, "character")
  expect_type(wta_matches_2019$LRank, "character")
  expect_type(wta_matches_2019$WPts, "character")
  expect_type(wta_matches_2019$LPts, "character")
  expect_type(wta_matches_2019$W1, "integer")
  expect_type(wta_matches_2019$L1, "integer")
  expect_type(wta_matches_2019$W2, "integer")
  expect_type(wta_matches_2019$L2, "integer")
  expect_type(wta_matches_2019$W3, "integer")
  expect_type(wta_matches_2019$L3, "integer")
  expect_type(wta_matches_2019$Wsets, "integer")
  expect_type(wta_matches_2019$Lsets, "integer")
  expect_type(wta_matches_2019$Comment, "character")
  expect_type(wta_matches_2019$B365W, "double")
  expect_type(wta_matches_2019$B365L, "double")
  expect_type(wta_matches_2019$PSW, "double")
  expect_type(wta_matches_2019$PSL, "double")
  expect_type(wta_matches_2019$MaxW, "double")
  expect_type(wta_matches_2019$MaxL, "double")
  expect_type(wta_matches_2019$AvgW, "double")
  expect_type(wta_matches_2019$AvgL, "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.