PageRenderTime 92ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/inst/tests/test-is-empty-scalar.R

https://bitbucket.org/fmark/assertive
R | 98 lines | 76 code | 22 blank | 0 comment | 0 complexity | a0d1f2cb9e1b46c22ee083ff4e4608d9 MD5 | raw file
  1. test.is_empty.empty_vector.returns_true <- function()
  2. {
  3. checkTrue(is_empty(numeric()))
  4. }
  5. test.is_empty.empty_list.returns_true <- function()
  6. {
  7. checkTrue(is_empty(list()))
  8. }
  9. test.is_empty.null.returns_true <- function()
  10. {
  11. checkTrue(is_empty(NULL))
  12. }
  13. test.is_empty.non_empty_vector.returns_false <- function()
  14. {
  15. checkTrue(!is_empty(1))
  16. }
  17. test.is_empty_model.an_empty_model.returns_true <- function()
  18. {
  19. checkTrue(is_empty_model(lm(y ~ 0, data.frame(y = 1:5))))
  20. }
  21. test.is_empty_model.a_model_with_intercept.returns_false <- function()
  22. {
  23. checkTrue(!is_empty_model(lm(y ~ 1, data.frame(y = 1:5))))
  24. }
  25. test.is_empty_model.a_model_with_factors.returns_false <- function()
  26. {
  27. checkTrue(!is_empty_model(lm(y ~ x + 0, data.frame(y = 1:5, x = 1:5))))
  28. }
  29. test.is_empty_model.not_a_model.returns_false <- function()
  30. {
  31. checkTrue(!is_empty_model(1:10))
  32. }
  33. test.is_non_empty.non_empty_vector.returns_true <- function()
  34. {
  35. checkTrue(is_non_empty(1))
  36. }
  37. test.is_non_empty.empty_vector.returns_false <- function()
  38. {
  39. checkTrue(!is_non_empty(numeric()))
  40. }
  41. test.is_non_empty.empty_list.returns_false <- function()
  42. {
  43. checkTrue(!is_non_empty(list()))
  44. }
  45. test.is_non_empty.null.returns_false <- function()
  46. {
  47. checkTrue(!is_non_empty(NULL))
  48. }
  49. test.is_non_empty_model.a_model_with_intercept.returns_true <- function()
  50. {
  51. checkTrue(is_non_empty_model(lm(y ~ 1, data.frame(y = 1:5))))
  52. }
  53. test.is_non_empty_model.a_model_with_factors.returns_true <- function()
  54. {
  55. checkTrue(is_non_empty_model(lm(y ~ x + 0, data.frame(y = 1:5, x = 1:5))))
  56. }
  57. test.is_non_empty_model.an_empty_model.returns_false <- function()
  58. {
  59. checkTrue(!is_non_empty_model(lm(y ~ 0, data.frame(y = 1:5))))
  60. }
  61. test.is_non_empty_model.not_a_model.returns_false <- function()
  62. {
  63. checkTrue(!is_non_empty_model(1:10))
  64. }
  65. test.is_scalar.a_scalar.returns_true <- function()
  66. {
  67. checkTrue(is_scalar(1))
  68. }
  69. test.is_scalar.a_vector.returns_false <- function()
  70. {
  71. checkTrue(!is_scalar(1:2))
  72. }
  73. test.is_scalar.empty.returns_false <- function()
  74. {
  75. checkTrue(!is_scalar(numeric()))
  76. }