1 2## Copyright (C) 2019 Dirk Eddelbuettel 3## 4## This file is part of Rcpp. 5## 6## Rcpp is free software: you can redistribute it and/or modify it 7## under the terms of the GNU General Public License as published by 8## the Free Software Foundation, either version 2 of the License, or 9## (at your option) any later version. 10## 11## Rcpp is distributed in the hope that it will be useful, but 12## WITHOUT ANY WARRANTY; without even the implied warranty of 13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14## GNU General Public License for more details. 15## 16## You should have received a copy of the GNU General Public License 17## along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 18 19if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.") 20 21Rcpp::sourceCpp("cpp/rcppversion.cpp") 22 23## we take packageVersion, make it a character variable, split it by dots and turn it to ints 24## note that v could now be a three or four element vector depending on what the package version is 25pv <- packageVersion("Rcpp") 26pvstr <- as.character(pv) 27v <- as.integer(unlist(strsplit(pvstr, "\\."))) 28 29## construct a release string from the first three elements, ie "1.0.3" from 1.0.3.1 30relstr <- as.character(as.package_version(paste(v[1:3], collapse="."))) 31 32## call C++ function returning list of six values, three each for 'release' and 'dev' version 33res <- checkVersion(v) 34 35 36## basic check: is the #defined version equal to the computed version (issue #1014) 37expect_equal(res$cur_ver, res$def_ver, info="current computed version equal defined version") 38 39## basic check: is the #defined string version equal to the computed string version (adjusting for rel) 40expect_equal(relstr, res$def_str, info="current computed version equal defined dev string") 41 42## additional checks if we are a dev version 43if (length(v) >= 4) { 44 expect_equal(res$cur_dev_ver, res$def_dev_ver, info="current computed dev version greater equal defined dev version") 45} 46 47if (length(v) <= 4) { 48 ## basic check: is #defined string version equal to computed string 49 expect_equal(pvstr, res$def_dev_str, info="current computed version equal defined dev string") 50} 51