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