From 4050d7cca8036179f372cdb1cb27a0dd388d3c48 Mon Sep 17 00:00:00 2001 From: Joan Massich Date: Wed, 3 Apr 2019 16:47:01 +0200 Subject: [PATCH] libmatio: improve test (#38454) --- Formula/libmatio.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Formula/libmatio.rb b/Formula/libmatio.rb index b0cea79c53..6517a58a07 100644 --- a/Formula/libmatio.rb +++ b/Formula/libmatio.rb @@ -37,11 +37,28 @@ class Libmatio < Formula (testpath/"mat.c").write <<~'EOS' #include #include + + size_t dims[2] = {5, 5}; + double data[25] = {0.0, }; + mat_t *mat; + matvar_t *matvar; + int main(int argc, char **argv) { - mat_t *matfp; - if (!(matfp = Mat_Open(argv[1], MAT_ACC_RDONLY))) + if (!(mat = Mat_Open(argv[1], MAT_ACC_RDONLY))) abort(); - Mat_Close(matfp); + Mat_Close(mat); + + mat = Mat_CreateVer("test_writenan.mat", NULL, MAT_FT_DEFAULT); + if (mat) { + matvar = Mat_VarCreate("foo", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, + dims, data, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(mat, matvar, MAT_COMPRESSION_NONE); + Mat_VarFree(matvar); + Mat_Close(mat); + } else { + abort(); + } + mat = Mat_CreateVer("foo", NULL, MAT_FT_MAT73); return EXIT_SUCCESS; } EOS