Skip to content

Commit

Permalink
test_equivalence instead of test_equal
Browse files Browse the repository at this point in the history
When comparing different tables, sometimes despite the tables being identical,
test_equal still returns false. Use test_equivalence instead.
  • Loading branch information
cchristiansen committed Jul 27, 2023
1 parent fe7c642 commit 421bf99
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions reconnect_compliance/tests/test_create_reconnection_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ testthat::test_that("Categorising a circuit with 5s data, and just a breif ramp
ramp_rate_change_resource_limit_threshold = -0.1)


testthat::expect_equal(calculated_results, expected_results, tolerance = 1e-4)
testthat::expect_equivalence(calculated_results, expected_results, tolerance = 1e-4)
})


Expand Down Expand Up @@ -82,7 +82,7 @@ testthat::test_that("Categorising a circuit with 5s data, sustained ramp rate vi
ramp_threshold_for_non_compliance = 0.3,
ramp_rate_change_resource_limit_threshold = -0.1)

testthat::expect_equal(calculated_results, expected_results, tolerance = 1e-4)
testthat::expect_equivalence(calculated_results, expected_results, tolerance = 1e-4)
})


Expand Down Expand Up @@ -120,7 +120,7 @@ testthat::test_that("Categorising a circuit with 60s data, no ramp rate violatio
ramp_threshold_for_non_compliance = 0.3,
ramp_rate_change_resource_limit_threshold = -0.1)

testthat::expect_equal(calculated_results, expected_results, tolerance = 1e-4)
testthat::expect_equivalence(calculated_results, expected_results, tolerance = 1e-4)
})


Expand Down Expand Up @@ -159,5 +159,5 @@ testthat::test_that("Categorising a circuit with 5s data, sustained ramp rate vi
ramp_rate_change_resource_limit_threshold = -0.1)


testthat::expect_equal(calculated_results, expected_results, tolerance = 1e-4)
})
testthat::expect_equivalence(calculated_results, expected_results, tolerance = 1e-4)
})
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ testthat::test_that("Calculating reconnection times works",{
calculated_reconnection_times <- calculate_reconnection_times(normalised_power, event_time,
disconnect_threshold = 0.05, reconnect_threshold = 0.95)

testthat::expect_equal(calculated_reconnection_times, expected_reconnection_times, tolerance = 1e-4)
})
testthat::expect_equivalence(calculated_reconnection_times, expected_reconnection_times, tolerance = 1e-4)
})
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testthat::test_that("group_disconnections_by_manufacturer",{
circuit_summary <- load_test_file(circuit_summary)
expected_output <- load_test_file(expected_output)
output <- group_disconnections_by_manufacturer(circuit_summary)
testthat::expect_equal(output, expected_output, tolerance = 1e-4)
testthat::expect_equivalence(output, expected_output, tolerance = 1e-4)
})

testthat::test_that("join_circuit_summary_and_cer_manufacturer_data",{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testthat::test_that("group_disconnections_by_manufacturer",{
circuit_summary <- load_test_file(circuit_summary)
expected_output <- load_test_file(expected_output)
output <- group_disconnections_by_manufacturer(circuit_summary, exclude_ufls_circuits = TRUE)
testthat::expect_equal(output, expected_output, tolerance = 1e-4)
testthat::expect_equivalence(output, expected_output, tolerance = 1e-4)
})

testthat::test_that("get_number_of_ufls_disconnections",{
Expand Down

0 comments on commit 421bf99

Please sign in to comment.