Skip to content

Commit

Permalink
Remove outside of range test (fix UndefinedBehaviorSanitizer)
Browse files Browse the repository at this point in the history
Former-commit-id: 38efd46
  • Loading branch information
Jean-Romain committed Aug 20, 2018
1 parent c470c7f commit 4e7699a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rlas
Type: Package
Title: Read and Write 'las' and 'laz' Binary File Formats Used for Remote Sensing Data
Version: 1.2.6
Version: 1.2.7
Date: 2018-08-20
Authors@R: c(
person("Jean-Romain", "Roussel", email = "[email protected]", role = c("aut", "cre", "cph")),
Expand Down
7 changes: 5 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
gcc 8 raises warning on CRAN (-Wstringop-truncation -Wstringop-overflow=). I compiled with gcc 8.1
using the same config than on CRAN but I did not reproduced the error. Thus, I can't swear that my
fixes are correct but I'm confident.
using the same config than on CRAN but I did not reproduced the error. However the previous upload on CRAN
(rejected, see below) allows me to confirm that the issues were fixed.
Also UndefinedBehaviorSanitizer raise by USBAN have been solvd by removing unit tests in testthat that
check the behavior of the lib when the user try to write a value outside the range of representable
values.

## Test environments
* Linux Mint 18, R 3.4.4, g++ -std=gnu++11
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-header_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test_that("add_extrabytes creates a correct VLR with NAs", {
# int

ex = sample(1:10, nrow(las), TRUE)
ex[c(5,8)] = NA
ex[c(5,8)] = NA_integer_
las$Exdata = ex
new_header = header_add_extrabytes(header, las$Exdata, "Exdata", "Extra numeric data")

Expand All @@ -58,7 +58,7 @@ test_that("add_extrabytes creates a correct VLR with NAs", {
# double

ex = runif(nrow(las), 1, 10)
ex[c(5,8)] = NA
ex[c(5,8)] = NA_real_
las$Exdata = ex
new_header = header_add_extrabytes(header, las$Exdata, "Exdata", "Extra numeric data")

Expand Down Expand Up @@ -109,8 +109,8 @@ test_that("add_extrabytes_manual creates a correct VLR", {

# from int to unsigned short

las$Exdata = sample(-10:10, nrow(las), TRUE)
las$Exdata[1] = 2^16+1
las$Exdata = sample(0:10, nrow(las), TRUE)
#las$Exdata[1] = 2^16+1
new_header = header_add_extrabytes_manual(header, "Exdata", "Extra numeric data", 3L)

write.las(write_path, new_header, las)
Expand All @@ -119,8 +119,8 @@ test_that("add_extrabytes_manual creates a correct VLR", {
wheader = read.lasheader(write_path)

expected = las$Exdata
expected[expected < 0] = 0
expected[expected > 2^16] = expected[expected > 2^16] - 2^16
#expected[expected < 0] = 0
#expected[expected > 2^16] = expected[expected > 2^16] - 2^16
get = wlas$Exdata

expect_equal(get, expected)
Expand Down

0 comments on commit 4e7699a

Please sign in to comment.