check_rcpp: Parse cpp files with embedded R

check_rcppR Documentation

Parse cpp files with embedded R

Description

Extracts the embedded R and Cpp portions from a cpp file.

Usage

check_embedded_r(state)

check_cpp(state)

Arguments

state

An exercise state, as returned by ex().

Value

A child state.

Examples

## Not run: 
# Example solution cpp
#include <Rcpp.h>
using namespace Rcpp ;

// [[Rcpp::export]]
int answer(){
  return 42 ;
}

/*** R
x <- answer()
x
*/

# SCT
ex() %>% check_cpp(.) %>% check_code(., "return//s+42//s+;")
ex() %>% check_embedded_r(.) %>% check_function("answer") %>% check_result()


## End(Not run)


datacamp/testwhat.ext documentation built on Aug. 26, 2022, 4:12 p.m.