tests/testthat/test-arithmetic_strictness.R

context("test-arithmentic_strictness.R")

ratings       <- read.csv(file=here("datasets/small.csv"), header = FALSE, sep = ",")
rating_matrix <- data.matrix(ratings)

test_that("doc means are being calculated correctly", {
  subject <- arithmetic_strictness_env(rating_matrix)$doc_means
  expect_equal(subject, rbind(2.50, 1.75, 1.25)[, 1])
})

test_that("global mean is being calculated correctly", {
  subject <- arithmetic_strictness_env(rating_matrix)$arithmetic_mean_of_all_documents
  expect_equal(round(subject, digits = 2), 1.83)
})

test_that("strictness vector is being calculated correctly", {
  subject <- arithmetic_strictness_env(rating_matrix)$arithmetic_strictness_vector
  rounded <- subject %>% round(digits = 2) %>% as.matrix %>% t

  rounded %>% print
  cbind(0.46, 0.92, 1.83, 5.5000000) %>% print
  expect_equal(rounded, cbind(0.46, 0.92, 1.83, 5.5000000)[1,])
})
neumanrq/fairreviewers documentation built on May 24, 2019, 5:06 a.m.