-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4404a8
commit 210f446
Showing
13 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
context("Test suite for hts_prep_data function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
|
||
test_that("hts_prep_data should return counts and units", { | ||
|
||
results = hts_prep_data(summarize_var = 'age', variables_dt = variable_list, data = test_data) | ||
|
||
expect_is(results, "list", info = "hts_prep_data should return a list") | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
context("Test suite for hts_prep_triprate function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_prep_triprate should return counts and units", { | ||
|
||
results = hts_prep_triprate(summarize_by = 'age', variables_dt = variable_list, hts_data = test_data) | ||
|
||
expect_is(results, "list", info = "hts_prep_triprate should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
context("Test suite for hts_remove_missing_data function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_remove_missing_data should return counts and units", { | ||
|
||
results = hts_remove_missing_data(hts_data = test_data, summarize_var = 'speed_mph', variables_dt = variable_list) | ||
|
||
expect_is(results, "list", info = "hts_remove_missing_data should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
context("Test suite for hts_remove_outliers function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_remove_outliers should return counts and units", { | ||
|
||
results = hts_remove_outliers(var_dt = test_data$trip, numvar = 'speed_mph') | ||
|
||
expect_is(results, "list", info = "hts_remove_outliers should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
context("Test suite for hts_summary function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_summary should return counts and units", { | ||
|
||
results = hts_summary( | ||
test_data, | ||
summarize_var = 'race', | ||
variables_dt = variable_list) | ||
|
||
expect_is(results, "list", info = "hts_summary should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
context("Test suite for hts_summary_cat function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_summary_cat should return counts and units", { | ||
|
||
results = hts_summary_cat( | ||
prepped_dt = test_data$person, | ||
summarize_var = 'age', | ||
variable_list = variable_list) | ||
|
||
expect_is(results, "list", info = "hts_summary_cat should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
context("Test suite for hts_summary_num function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_summary_num should return counts and units", { | ||
|
||
results = hts_summary_num( | ||
prepped_dt = test_data$trip, | ||
summarize_var = 'speed_mph') | ||
|
||
expect_is(results, "list", info = "hts_summary_num should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
context("Test suite for hts_to_so function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
library(srvyr) | ||
|
||
|
||
test_that("hts_to_so should return counts and units", { | ||
|
||
results = hts_to_so(test_data$day) | ||
|
||
expect_is(results, "survey.design", info = "hts_to_so should return a list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
context("Test suite for hts_trip_vehid function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
# Sample trip_table and vehicle_table for testing | ||
trip_ex = data.table( | ||
hh_id = sample(1:10, size = 30, replace = TRUE), | ||
trip_id = 1:30, | ||
mode_type = sample(1:2, size = 30, replace = TRUE), | ||
mode_1 = sample(1, size = 30, replace = TRUE)) | ||
|
||
vehicle_ex = data.table( | ||
hh_id = sample(1:10, size = 30, replace = TRUE), | ||
vehicle_id = 1:30) | ||
|
||
values_ex = data.table( | ||
variable = c(rep('mode_type', 2), ('mode_1')), | ||
value = c(1,2,1), | ||
value_label = c('Vehicle', 'Walk', 'Car') | ||
) | ||
|
||
|
||
test_that("hts_trip_vehid should create vehicle_id correctly", { | ||
|
||
results = hts_trip_vehid(trip_table = trip_ex, | ||
vehicle_table = vehicle_ex, | ||
vehicle_mode_type = 'Vehicle', | ||
values_dt = values_ex) | ||
|
||
expect_is(results, "data.table", info = "hts_trip_vehid should return a data.table object") | ||
|
||
expect_true("vehicle_id" %in% names(results), info = "Results should include 'vehicle_id' column") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
context("factorize_df") | ||
library(tmrtools) | ||
library(travelSurveyTools) | ||
library(data.table) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
context("Test suite for hts_melt_vars function") | ||
|
||
# Load necessary libraries and setup environment | ||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
variable_list = variable_list | ||
|
||
sample_dt = test_data$person | ||
|
||
test_that("hts_melt_vars should melt variables correctly", { | ||
|
||
results = hts_melt_vars(shared_name = 'race', wide_dt = sample_dt) | ||
|
||
# Check if the result is a data.table | ||
expect_is(results, "data.table", | ||
info = "hts_melt_vars should return a data.table") | ||
|
||
|
||
# expect_equal(2 * 2, 4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
context("Test suite for hts_prep_byvar function") | ||
|
||
library(testthat) | ||
library(data.table) | ||
|
||
|
||
test_that("hts_prep_byvar should prepare data by variable correctly", { | ||
|
||
results = hts_prep_byvar(summarize_by = "age", variables_dt = variable_list, hts_data = test_data) | ||
|
||
expect_is(results, "data.table", | ||
info = "hts_prep_byvar should return a data.table") | ||
|
||
# expect_equal() | ||
}) |