Skip to content

Commit

Permalink
work in progress to drop list item that is NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Jul 27, 2018
1 parent 40fd517 commit 13f3fec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rmatio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ write_elmt(const SEXP elmt,
SEXP class_name;

if (Rf_isNull(elmt))
return 1;
return 0;

switch (TYPEOF(elmt)) {
case CHARSXP:
Expand Down
37 changes: 37 additions & 0 deletions tests/lists.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## rmatio, a R interface to the C library matio, MAT File I/O Library.
## Copyright (C) 2013-2018 Stefan Widgren
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## rmatio is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.

library("rmatio")

## For debugging
sessionInfo()

##
## NULL: case-1
##
filename <- tempfile(fileext = ".mat")
n1 <- list(x = 1, y = 2, z = NULL)
write.mat(n1, filename = filename, compression = FALSE, version = c("MAT5"))
stopifnot(identical(read.mat(filename), list(x = 1, y = 2)))
unlink(filename)

## Run the same test with compression
if(rmatio:::have.zlib()) {
filename <- tempfile(fileext = ".mat")
write.mat(n1, filename = filename, compression = TRUE, version = c("MAT5"))
stopifnot(identical(read.mat(filename), list(x = 1, y = 2)))
unlink(filename)
}

0 comments on commit 13f3fec

Please sign in to comment.