-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.reader.r
More file actions
38 lines (30 loc) · 920 Bytes
/
Copy pathtest.reader.r
File metadata and controls
38 lines (30 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
source('Project/source_paths.r')
source(get_reader_file_path())
library(testthat)
library(readr)
auth_df = read_auth()
test_that('Should have 203years + 1 column', {
expect_equal(length(auth_df), 204)
})
test_that('Should have 30288ids', {
expect_equal(length(auth_df[, 1]), 30288)
})
test_that('Should throw a warning', {
expect_warning({
get_auth_by_year(auth_df, 1799)
})
expect_warning({
get_auth_by_year(auth_df, 2003)
})
})
test_that('Should match authorities for year 2002', {
auth_value_case_id_5 = 2.913e-05
auth_value_case_id_30288 = 0
authority_vector = get_auth_by_year(auth_df, 2002)
expect_equal(auth_value_case_id_5, authority_vector[5])
expect_equal(auth_value_case_id_30288, authority_vector[30288])
})
test_that('Should match authorities for year 2001', {
authority_vector = get_auth_by_year(auth_df, 2001)
expect_equal(is.na( authority_vector[30288]),TRUE)
})