test_that("test SummarisedResult object", { x <- dplyr::tibble( "cdm_name" = "cprd", "result_type" = "summarised_characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_no_error(summarisedResult(x = x)) class <- x |> summarisedResult() |> class() expect_true(all( c("summarised_characteristics", "summarised_result") %in% class )) # check none character x <- dplyr::tibble( "cdm_name" = 1, "result_type" = "summarised_characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_error(summarisedResult(x = x)) #check result_type x <- dplyr::tibble( "cdm_name" = "cprd", "result_type" = "Summarised characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_error(summarisedResult(x = x)) #check wrong columns x <- dplyr::tibble( "package" = "patientProfiles", "package_version" = "0.4.0", "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable" = "age_group", "variable_level" = "10 to 50", "estimate_type" = "count", "estimate" = "5" ) expect_error(summarisedResult(x = x)) # check NA x <- dplyr::tibble( "cdm_name" = "cprd", "result_type" = "summarised_characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = NA_character_, "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_error(summarisedResult(x = x)) # check wrong paired x <- dplyr::tibble( "cdm_name" = "cprd", "result_type" = "summarised_characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex and cohort_name", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male and cohort1", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_error(summarisedResult(x = x)) # check wrong case x <- dplyr::tibble( "cdm_name" = "cprd", "result_type" = "summarised_characteristics", "package_name" = "PatientProfiles", "package_version" = "0.4.0", "group_name" = "sex and cohort_Name", "group_level" = "male and cohort1", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) expect_error(summarisedResult(x = x)) })