@@ -12,14 +12,32 @@ test_that("is_selected handles selections correctly", {
12
12
expect_equal(is_selected(split_options(c(" " , " 14" , " 4" , " 4,6,8" )), " 1" ),
13
13
c(NA , FALSE , FALSE , FALSE ))
14
14
15
- expect_equal(is_selected(split_options(c(" 1" , " 15" , " 14" , NA )), " 14" ),
16
- c(FALSE , FALSE , TRUE , FALSE ))
15
+ expect_equal(is_selected(split_options(c(" 1" , " 15" , " 14" , NA , " " )), " 14" ),
16
+ c(FALSE , FALSE , TRUE , NA , NA ))
17
17
18
18
expect_equal(is_selected(split_options(c(" 4,54" , " 3,6,2,54" , " 5,4,45" )),
19
19
" 54" ),
20
20
c(TRUE , TRUE , FALSE ))
21
21
})
22
22
23
+ test_that(" activities items correctly coded" , {
24
+ input_data <- data.frame (
25
+ C13 = c(NA , " 1,2,4" , " 3" , " " , " 6" , " 2,4" )
26
+ )
27
+
28
+ out <- code_activities(input_data )
29
+
30
+ # expected result
31
+ input_data $ a_work_outside_home_1d <- c(NA , TRUE , FALSE , NA , FALSE , FALSE )
32
+ input_data $ a_shop_1d <- c(NA , TRUE , FALSE , NA , FALSE , TRUE )
33
+ input_data $ a_restaurant_1d <- c(NA , FALSE , TRUE , NA , FALSE , FALSE )
34
+ input_data $ a_spent_time_1d <- c(NA , TRUE , FALSE , NA , FALSE , TRUE )
35
+ input_data $ a_large_event_1d <- c(NA , FALSE , FALSE , NA , FALSE , FALSE )
36
+ input_data $ a_public_transit_1d <- c(NA , FALSE , FALSE , NA , TRUE , FALSE )
37
+
38
+ expect_equal(out , input_data )
39
+ })
40
+
23
41
test_that(" mask items correctly coded" , {
24
42
input_data <- data.frame (
25
43
C14 = c(NA , 1 , 3 , 6 , 2 , 4 ),
0 commit comments