Skip to content

Commit 43a6d84

Browse files
authored
Merge pull request #1036 from RcppCore/feature/more_nocov
more nocov
2 parents 1e6bf21 + 84dd399 commit 43a6d84

File tree

5 files changed

+54
-46
lines changed

5 files changed

+54
-46
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2019-12-14 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/date.cpp: A few more #nocov tage
4+
5+
2019-12-13 Dirk Eddelbuettel <[email protected]>
6+
7+
* src/api.cpp: A few more #nocov tags
8+
* src/attributes.cpp: Idem
9+
* src/barrier.cpp: Idem
10+
111
2019-12-08 Dirk Eddelbuettel <[email protected]>
212

313
* tests/tinytest.R: Turn verbose tests on in dev and on Travis

src/api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// api.cpp: Rcpp R/C++ interface class library -- Rcpp api
44
//
5-
// Copyright (C) 2012 - 2016 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2012 - 2019 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -82,7 +82,7 @@ namespace Rcpp {
8282
}
8383

8484
// [[Rcpp::register]]
85-
unsigned long beginSuspendRNGSynchronization() {
85+
unsigned long beginSuspendRNGSynchronization() {// #nocov start
8686
++rngSynchronizationSuspended;
8787
return rngSynchronizationSuspended;
8888
}
@@ -91,7 +91,7 @@ namespace Rcpp {
9191
unsigned long endSuspendRNGSynchronization() {
9292
--rngSynchronizationSuspended;
9393
return rngSynchronizationSuspended;
94-
}
94+
} // #nocov end
9595

9696
// [[Rcpp::register]]
9797
char* get_string_buffer() {

src/attributes.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ namespace attributes {
957957
parseSourceDependencies(sourceFile, &dependencies);
958958

959959
// remove main source file
960-
dependencies.erase(std::remove(dependencies.begin(),
960+
dependencies.erase(std::remove(dependencies.begin(), // #nocov
961961
dependencies.end(),
962962
FileInfo(sourceFile)),
963963
dependencies.end());
@@ -1263,9 +1263,9 @@ namespace attributes {
12631263
// check for a match
12641264
Rcpp::CharacterVector match = initMatches[i];
12651265
if (match.size() > 0) {
1266-
hasPackageInit_ = true;
1266+
hasPackageInit_ = true; // #nocov start
12671267
break;
1268-
}
1268+
} // #nocov end
12691269
}
12701270

12711271
// Parse embedded R
@@ -1285,9 +1285,9 @@ namespace attributes {
12851285
SourceFileAttributesParser parser(dependency, packageName, false);
12861286

12871287
// copy to base attributes (if it's a new attribute)
1288-
for (SourceFileAttributesParser::const_iterator
1288+
for (SourceFileAttributesParser::const_iterator // #nocov start
12891289
it = parser.begin(); it != parser.end(); ++it) {
1290-
if (std::find(attributes_.begin(), // #nocov start
1290+
if (std::find(attributes_.begin(),
12911291
attributes_.end(),
12921292
*it) == attributes_.end()) {
12931293
attributes_.push_back(*it); // #nocov end
@@ -1454,8 +1454,8 @@ namespace attributes {
14541454
beginParenLoc == std::string::npos ||
14551455
endParenLoc < beginParenLoc) {
14561456

1457-
rcppExportNoFunctionFoundWarning(lineNumber);
1458-
return Function();
1457+
rcppExportNoFunctionFoundWarning(lineNumber); // #nocov
1458+
return Function(); // #nocov
14591459
}
14601460

14611461
// Find the type and name by scanning backwards for the whitespace that
@@ -1510,7 +1510,7 @@ namespace attributes {
15101510
trimWhitespace(&arg);
15111511
if (arg.empty()) {
15121512
// we don't warn here because the compilation will fail anyway
1513-
continue;
1513+
continue; // #nocov
15141514
}
15151515

15161516
// If the argument has an = within it then it has a default value
@@ -1656,12 +1656,12 @@ namespace attributes {
16561656
case '>':
16571657
templateCount--;
16581658
break;
1659-
case '(':
1660-
parenCount++; // #nocov
1661-
break; // #nocov
1659+
case '(': // #nocov start
1660+
parenCount++;
1661+
break;
16621662
case ')':
1663-
parenCount--; // #nocov
1664-
break; // #nocov
1663+
parenCount--;
1664+
break; // #nocov end
16651665
}
16661666
}
16671667
}
@@ -2445,12 +2445,12 @@ namespace attributes {
24452445
ostr() << "invisible("; // #nocov
24462446
ostr() << ".Call(";
24472447
if (!registration_)
2448-
ostr() << "'";
2448+
ostr() << "'"; // #nocov
24492449
else
24502450
ostr() << "`";
24512451
ostr() << packageCppPrefix() << "_" << function.name();
24522452
if (!registration_)
2453-
ostr() << "', " << "PACKAGE = '" << package() << "'";
2453+
ostr() << "', " << "PACKAGE = '" << package() << "'"; // #nocov
24542454
else
24552455
ostr() << "`";
24562456

@@ -2972,7 +2972,7 @@ namespace attributes {
29722972

29732973
// skip empty case
29742974
if (pStr->empty())
2975-
return;
2975+
return; // #nocov
29762976

29772977
// trim right
29782978
std::string::size_type pos = pStr->find_last_not_of(kWhitespaceChars);
@@ -3572,14 +3572,14 @@ BEGIN_RCPP
35723572
// don't process RcppExports.cpp
35733573
std::string cppFile = cppFiles[i];
35743574
if (endsWith(cppFile, "RcppExports.cpp"))
3575-
continue;
3575+
continue; // #nocov
35763576

35773577
// parse file
35783578
SourceFileAttributesParser attributes(cppFile, packageName, false);
35793579

35803580
// note if we found a package init function
35813581
if (!hasPackageInit && attributes.hasPackageInit())
3582-
hasPackageInit = true;
3582+
hasPackageInit = true; // #nocov
35833583

35843584
// continue if no generator output
35853585
if (!attributes.hasGeneratorOutput())
@@ -3618,7 +3618,7 @@ BEGIN_RCPP
36183618
depends.begin(), depends.end(),
36193619
std::back_inserter(diff));
36203620
if (!diff.empty()) {
3621-
std::string msg =
3621+
std::string msg = // #nocov start
36223622
"The following packages are referenced using Rcpp::depends "
36233623
"attributes however are not listed in the Depends, Imports or "
36243624
"LinkingTo fields of the package DESCRIPTION file: ";
@@ -3633,7 +3633,7 @@ BEGIN_RCPP
36333633
// verbose output
36343634
if (verbose) {
36353635
for (size_t i=0; i<updated.size(); i++)
3636-
Rcpp::Rcout << updated[i] << " updated." << std::endl;
3636+
Rcpp::Rcout << updated[i] << " updated." << std::endl; // #nocov end
36373637
}
36383638

36393639
// return files updated

src/barrier.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// barrier.cpp: Rcpp R/C++ interface class library -- write barrier
44
//
5-
// Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -29,7 +29,7 @@
2929
#include <Rcpp/protection/Shield.h>
3030

3131
// [[Rcpp::register]]
32-
SEXP get_string_elt(SEXP x, R_xlen_t i) {
32+
SEXP get_string_elt(SEXP x, R_xlen_t i) { // #nocov start
3333
return STRING_ELT(x, i);
3434
}
3535

@@ -65,7 +65,7 @@ void set_vector_elt(SEXP x, R_xlen_t i, SEXP value) {
6565

6666
// [[Rcpp::register]]
6767
SEXP* get_vector_ptr(SEXP x) {
68-
return VECTOR_PTR(x);
68+
return VECTOR_PTR(x); // #nocov end
6969
}
7070

7171
// [[Rcpp::register]]
@@ -153,7 +153,7 @@ SEXP init_Rcpp_cache() {
153153
}
154154

155155
// [[Rcpp::register]]
156-
SEXP reset_current_error() {
156+
SEXP reset_current_error() { // #nocov start
157157
SEXP cache = get_rcpp_cache();
158158

159159
// error occured
@@ -189,7 +189,7 @@ SEXP rcpp_error_recorder(SEXP e) {
189189

190190
// [[Rcpp::register]]
191191
SEXP rcpp_get_current_error() {
192-
return VECTOR_ELT(get_rcpp_cache(), 2);
192+
return VECTOR_ELT(get_rcpp_cache(), 2); // #nocov end
193193
}
194194

195195
// [[Rcpp::register]]
@@ -206,4 +206,3 @@ int* get_cache(int m) {
206206
std::fill(res, res+m, 0);
207207
return res;
208208
}
209-

src/date.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2-
// jedit: :folding=explicit:
1+
32
//
43
// Date.cpp: Rcpp R/C++ interface class library -- Date type
54
//
6-
// Copyright (C) 2010 - 2016 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
76
//
87
// The mktime00() as well as the gmtime_() replacement function are
98
// Copyright (C) 2000 - 2010 The R Development Core Team.
@@ -85,11 +84,11 @@ namespace Rcpp {
8584
year0 = year_base + tm.tm_year;
8685
/* safety check for unbounded loops */
8786
if (year0 > 3000) {
88-
excess = (int)(year0/2000) - 1;
87+
excess = (int)(year0/2000) - 1; // #nocov start
8988
year0 -= excess * 2000;
9089
} else if (year0 < 0) {
9190
excess = -1 - (int)(-year0/2000);
92-
year0 -= excess * 2000;
91+
year0 -= excess * 2000; // #nocov end
9392
}
9493

9594
for(i = 0; i < tm.tm_mon; i++) day += days_in_month[i];
@@ -461,12 +460,12 @@ struct tzhead {
461460
** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
462461
*/
463462
if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
464-
return TRUE;
463+
return TRUE; // #nocov
465464
*ip += j;
466465
return FALSE;
467466
}
468467

469-
static int increment_overflow_time(time_t *tp, int_fast32_t j) {
468+
static int increment_overflow_time(time_t *tp, int_fast32_t j) { // #nocov start
470469
/*
471470
** This is like
472471
** 'if (! (time_t_min <= *tp + j && *tp + j <= time_t_max)) ...',
@@ -477,10 +476,10 @@ struct tzhead {
477476
: *tp <= time_t_max - j))
478477
return TRUE;
479478
*tp += j;
480-
return FALSE;
479+
return FALSE;
481480
}
482481

483-
static int_fast32_t detzcode(const char *const codep) { // #nocov start
482+
static int_fast32_t detzcode(const char *const codep) {
484483
int_fast32_t result = (codep[0] & 0x80) ? -1 : 0;
485484
for (int i = 0; i < 4; ++i)
486485
result = (result << 8) | (codep[i] & 0xff);
@@ -1241,7 +1240,7 @@ struct tzhead {
12411240
hit = 0;
12421241
i = sp->leapcnt;
12431242
while (--i >= 0) {
1244-
lp = &sp->lsis[i];
1243+
lp = &sp->lsis[i]; // #nocov start
12451244
if (*timep >= lp->ls_trans) {
12461245
if (*timep == lp->ls_trans) {
12471246
hit = ((i == 0 && lp->ls_corr > 0) ||
@@ -1257,7 +1256,7 @@ struct tzhead {
12571256
}
12581257
}
12591258
corr = lp->ls_corr;
1260-
break;
1259+
break; // #nocov end
12611260
}
12621261
}
12631262
y = EPOCH_YEAR;
@@ -1272,13 +1271,13 @@ struct tzhead {
12721271
tdelta = tdays / DAYSPERLYEAR;
12731272
if (! ((! TYPE_SIGNED(time_t) || INT_MIN <= tdelta)
12741273
&& tdelta <= INT_MAX))
1275-
return NULL;
1274+
return NULL; // #nocov
12761275
idelta = (int)tdelta;
12771276
if (idelta == 0)
12781277
idelta = (tdays < 0) ? -1 : 1;
12791278
newy = y;
12801279
if (increment_overflow(&newy, idelta))
1281-
return NULL;
1280+
return NULL; // #nocov
12821281
leapdays = leaps_thru_end_of(newy - 1) -
12831282
leaps_thru_end_of(y - 1);
12841283
tdays -= ((time_t) newy - y) * DAYSPERNYEAR;
@@ -1297,7 +1296,7 @@ struct tzhead {
12971296
*/
12981297
idays = (int)tdays;
12991298
rem += offset - corr;
1300-
while (rem < 0) {
1299+
while (rem < 0) { // #nocov start
13011300
rem += SECSPERDAY;
13021301
--idays;
13031302
}
@@ -1313,14 +1312,14 @@ struct tzhead {
13131312
while (idays >= year_lengths[isleap(y)]) {
13141313
idays -= year_lengths[isleap(y)];
13151314
if (increment_overflow(&y, 1))
1316-
return NULL;
1315+
return NULL; // #nocov end
13171316
}
13181317
// Previously we returned 'year + base', so keep behaviour
13191318
// It seems like R now returns just 'year - 1900' (as libc does)
13201319
// But better for continuity to do as before
13211320
tmp->tm_year = y + TM_YEAR_BASE;
13221321
if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE))
1323-
return NULL;
1322+
return NULL; // #nocov
13241323
tmp->tm_yday = idays;
13251324
/*
13261325
** The "extra" mods below avoid overflow problems.
@@ -1333,7 +1332,7 @@ struct tzhead {
13331332
idays;
13341333
tmp->tm_wday %= DAYSPERWEEK;
13351334
if (tmp->tm_wday < 0)
1336-
tmp->tm_wday += DAYSPERWEEK;
1335+
tmp->tm_wday += DAYSPERWEEK; // #nocov
13371336
tmp->tm_hour = (int) (rem / SECSPERHOUR);
13381337
rem %= SECSPERHOUR;
13391338
tmp->tm_min = (int) (rem / SECSPERMIN);

0 commit comments

Comments
 (0)