Skip to content

Commit 6ef6e14

Browse files
committed
Cleaned up the test suite.
- Consolidated parallel option into the same parse/write RDS functions. - Report and test the versions and encoding for RDA and RDS parsers. - Added some missing standard C++ headers, namespaced std::size_t.
1 parent 17be03d commit 6ef6e14

20 files changed

Lines changed: 290 additions & 347 deletions

‎tests/DESCRIPTION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ LinkingTo: Rcpp
1414
SystemRequirements: C++17
1515
License: GPL-3
1616
RoxygenNote: 7.3.3
17+
Encoding: UTF-8

‎tests/NAMESPACE‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(inspect)
4-
export(parallel_parse)
5-
export(parallel_write)
6-
export(parse)
74
export(parse_length)
8-
export(parse_preamble)
95
export(parse_rda)
6+
export(parse_rds)
107
export(parse_single_string)
11-
export(write)
128
export(write_rda)
9+
export(write_rds)
1310
importFrom(Rcpp,sourceCpp)
1411
useDynLib(rds2cpp)

‎tests/R/RcppExports.R‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

44
#' @export
5-
parse <- function(file_name) {
6-
.Call('_rds2cpp_parse', PACKAGE = 'rds2cpp', file_name)
7-
}
8-
9-
#' @export
10-
parallel_parse <- function(file_name) {
11-
.Call('_rds2cpp_parallel_parse', PACKAGE = 'rds2cpp', file_name)
5+
parse_rds <- function(file_name, parallel) {
6+
.Call('_rds2cpp_parse_rds', PACKAGE = 'rds2cpp', file_name, parallel)
127
}
138

149
#' @export
@@ -27,18 +22,8 @@ parse_single_string <- function(raw) {
2722
}
2823

2924
#' @export
30-
parse_preamble <- function(file_name) {
31-
.Call('_rds2cpp_parse_preamble', PACKAGE = 'rds2cpp', file_name)
32-
}
33-
34-
#' @export
35-
write <- function(x, file_name) {
36-
.Call('_rds2cpp_write', PACKAGE = 'rds2cpp', x, file_name)
37-
}
38-
39-
#' @export
40-
parallel_write <- function(x, file_name) {
41-
.Call('_rds2cpp_parallel_write', PACKAGE = 'rds2cpp', x, file_name)
25+
write_rds <- function(x, file_name, parallel) {
26+
.Call('_rds2cpp_write_rds', PACKAGE = 'rds2cpp', x, file_name, parallel)
4227
}
4328

4429
#' @export

‎tests/src/RcppExports.cpp‎

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,14 @@ Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
1010
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
1111
#endif
1212

13-
// parse
14-
Rcpp::RObject parse(std::string file_name);
15-
RcppExport SEXP _rds2cpp_parse(SEXP file_nameSEXP) {
13+
// parse_rds
14+
Rcpp::RObject parse_rds(std::string file_name, bool parallel);
15+
RcppExport SEXP _rds2cpp_parse_rds(SEXP file_nameSEXP, SEXP parallelSEXP) {
1616
BEGIN_RCPP
1717
Rcpp::RObject rcpp_result_gen;
1818
Rcpp::traits::input_parameter< std::string >::type file_name(file_nameSEXP);
19-
rcpp_result_gen = Rcpp::wrap(parse(file_name));
20-
return rcpp_result_gen;
21-
END_RCPP
22-
}
23-
// parallel_parse
24-
Rcpp::RObject parallel_parse(std::string file_name);
25-
RcppExport SEXP _rds2cpp_parallel_parse(SEXP file_nameSEXP) {
26-
BEGIN_RCPP
27-
Rcpp::RObject rcpp_result_gen;
28-
Rcpp::traits::input_parameter< std::string >::type file_name(file_nameSEXP);
29-
rcpp_result_gen = Rcpp::wrap(parallel_parse(file_name));
19+
Rcpp::traits::input_parameter< bool >::type parallel(parallelSEXP);
20+
rcpp_result_gen = Rcpp::wrap(parse_rds(file_name, parallel));
3021
return rcpp_result_gen;
3122
END_RCPP
3223
}
@@ -61,35 +52,15 @@ BEGIN_RCPP
6152
return rcpp_result_gen;
6253
END_RCPP
6354
}
64-
// parse_preamble
65-
Rcpp::List parse_preamble(std::string file_name);
66-
RcppExport SEXP _rds2cpp_parse_preamble(SEXP file_nameSEXP) {
67-
BEGIN_RCPP
68-
Rcpp::RObject rcpp_result_gen;
69-
Rcpp::traits::input_parameter< std::string >::type file_name(file_nameSEXP);
70-
rcpp_result_gen = Rcpp::wrap(parse_preamble(file_name));
71-
return rcpp_result_gen;
72-
END_RCPP
73-
}
74-
// write
75-
Rcpp::RObject write(Rcpp::RObject x, std::string file_name);
76-
RcppExport SEXP _rds2cpp_write(SEXP xSEXP, SEXP file_nameSEXP) {
77-
BEGIN_RCPP
78-
Rcpp::RObject rcpp_result_gen;
79-
Rcpp::traits::input_parameter< Rcpp::RObject >::type x(xSEXP);
80-
Rcpp::traits::input_parameter< std::string >::type file_name(file_nameSEXP);
81-
rcpp_result_gen = Rcpp::wrap(write(x, file_name));
82-
return rcpp_result_gen;
83-
END_RCPP
84-
}
85-
// parallel_write
86-
Rcpp::RObject parallel_write(Rcpp::RObject x, std::string file_name);
87-
RcppExport SEXP _rds2cpp_parallel_write(SEXP xSEXP, SEXP file_nameSEXP) {
55+
// write_rds
56+
Rcpp::RObject write_rds(Rcpp::RObject x, std::string file_name, bool parallel);
57+
RcppExport SEXP _rds2cpp_write_rds(SEXP xSEXP, SEXP file_nameSEXP, SEXP parallelSEXP) {
8858
BEGIN_RCPP
8959
Rcpp::RObject rcpp_result_gen;
9060
Rcpp::traits::input_parameter< Rcpp::RObject >::type x(xSEXP);
9161
Rcpp::traits::input_parameter< std::string >::type file_name(file_nameSEXP);
92-
rcpp_result_gen = Rcpp::wrap(parallel_write(x, file_name));
62+
Rcpp::traits::input_parameter< bool >::type parallel(parallelSEXP);
63+
rcpp_result_gen = Rcpp::wrap(write_rds(x, file_name, parallel));
9364
return rcpp_result_gen;
9465
END_RCPP
9566
}
@@ -107,14 +78,11 @@ END_RCPP
10778
}
10879

10980
static const R_CallMethodDef CallEntries[] = {
110-
{"_rds2cpp_parse", (DL_FUNC) &_rds2cpp_parse, 1},
111-
{"_rds2cpp_parallel_parse", (DL_FUNC) &_rds2cpp_parallel_parse, 1},
81+
{"_rds2cpp_parse_rds", (DL_FUNC) &_rds2cpp_parse_rds, 2},
11282
{"_rds2cpp_parse_rda", (DL_FUNC) &_rds2cpp_parse_rda, 2},
11383
{"_rds2cpp_parse_length", (DL_FUNC) &_rds2cpp_parse_length, 1},
11484
{"_rds2cpp_parse_single_string", (DL_FUNC) &_rds2cpp_parse_single_string, 1},
115-
{"_rds2cpp_parse_preamble", (DL_FUNC) &_rds2cpp_parse_preamble, 1},
116-
{"_rds2cpp_write", (DL_FUNC) &_rds2cpp_write, 2},
117-
{"_rds2cpp_parallel_write", (DL_FUNC) &_rds2cpp_parallel_write, 2},
85+
{"_rds2cpp_write_rds", (DL_FUNC) &_rds2cpp_write_rds, 3},
11886
{"_rds2cpp_write_rda", (DL_FUNC) &_rds2cpp_write_rda, 3},
11987
{NULL, NULL, 0}
12088
};

0 commit comments

Comments
 (0)