generated from extendr/helloextendr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-import_export.R
68 lines (48 loc) · 1.67 KB
/
test-import_export.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
test_that("export rust-polars data-frame to r-polars", {
skip_if_not_installed("polars")
rdf_actual = export_as_rpolars_df()
rdf_expected = polars::pl$DataFrame(
names = c("a", "b", "c"),
values = c(1L, 2L, 6L),
values_nulls = c(1L,NA,3L)
)
expect_identical(
rdf_actual$to_list(),
rdf_expected$to_list()
)
})
test_that("import rpolars dataframe to rust and print", {
skip_if_not_installed("polars")
rdf_expected = polars::pl$DataFrame(
names = c("a", "b", "c"),
values = c(1L, 2L, 6L),
values_nulls = c(1L,NA,3L)
)
lines = capture.output(invisible(import_rpolars_df_and_print(rdf_expected)))
expected_lines = capture.output(rdf_expected)
expect_identical(lines[1],"this df was imported to rust side:")
expect_identical(lines[-1],expected_lines)
})
test_that("import rpolars dataframe to rust and print", {
skip_if_not_installed("polars")
rdf_expected = polars::pl$DataFrame(
names = c("a", "b", "c"),
values = c(1L, 2L, 6L),
values_nulls = c(1L,NA,3L)
)
lines = capture.output(invisible(import_rpolars_df_and_print(rdf_expected)))
expected_lines = capture.output(rdf_expected)
expect_identical(lines[1],"this df was imported to rust side:")
#this will not hold if two polars versions print in different styles
#expect_identical(lines[-1],expected_lines)
})
test_that("round trip conversion", {
skip_if_not_installed("polars")
rdf_expected = polars::pl$DataFrame(
names = c("a", "b", "c"),
values = c(1L, 2L, 6L),
values_nulls = c(1L,NA,3L)
)
rdf_actual = test_round_trip(rdf_expected)
expect_identical(rdf_actual$to_list(), rdf_expected$to_list())
})