library(testthat) library(data.table) library(DTwrappers2) # Preparing the mock data table 'grouped.means' similar to what dt.mean.numerics would generate grouped.means <- data.table( Species = c("setosa", "versicolor", "virginica"), Sepal.Length = c(5.006, 5.936, 6.588), Sepal.Width = c(3.428, 2.770, 2.974) ) # Ensure the data table is available in the environment assign("grouped.means", grouped.means, envir = globalenv()) describe("Functionality of dt.round.numerics", { it("correctly rounds the numeric values to specified digits", { rounded_values <- dt.round.numerics(dt.name = "grouped.means", digits = 2) expected_values <- data.table( Species = c("setosa", "versicolor", "virginica"), Sepal.Length = c(5.01, 5.94, 6.59), Sepal.Width = c(3.43, 2.77, 2.97) ) expect_equal(rounded_values, expected_values, info = "The rounded values should match the expected results") }) })