tests/testthat/test-boxscore.R

context("kbodatamining")

test_that("batter_boxscore work", {
  lee_boxscore <- batter_boxscore(hanhwa_batter_2018,"이용규")
  expect_equal(nrow(lee_boxscore),1)
  expect_equal(ncol(lee_boxscore),29)
  lee_boxscore_2018 <- batter_boxscore(hanhwa_batter_2018,"이용규",yearly=2018)
  expect_equal(nrow(lee_boxscore_2018),1)
  expect_equal(ncol(lee_boxscore_2018),29)
  lee_boxscore_2018_05 <- batter_boxscore(hanhwa_batter_2018,"이용규",yearly=2018,monthly = "05")
  expect_equal(nrow(lee_boxscore_2018_05),1)
  expect_equal(ncol(lee_boxscore_2018_05),29)
  team_boxscore <- team_batter_boxscore(hanhwa_batter_2018,"한화")
  expect_equal(nrow(team_boxscore),1)
  expect_equal(ncol(team_boxscore),27)
})

test_that("pitcher_boxscore work", {
  jung_boxscore <- pitcher_boxscore(hanhwa_pitcher_2018,"정우람")
  expect_equal(nrow(jung_boxscore),1)
  expect_equal(ncol(jung_boxscore),29)
  jung_boxscore_2018 <- pitcher_boxscore(hanhwa_pitcher_2018,"정우람",yearly=2018)
  expect_equal(nrow(jung_boxscore_2018),1)
  expect_equal(ncol(jung_boxscore_2018),29)
  jung_boxscore_2018_05 <- pitcher_boxscore(hanhwa_pitcher_2018,"정우람",yearly=2018,monthly = "05")
  expect_equal(nrow(jung_boxscore_2018_05),1)
  expect_equal(ncol(jung_boxscore_2018_05),29)
  team_boxscore <- team_pitcher_boxscore(hanhwa_pitcher_2018,"한화")
  expect_equal(nrow(team_boxscore),1)
  expect_equal(ncol(team_boxscore),27)
  })
choosunsick/kbodatamining documentation built on May 18, 2019, 1:30 p.m.