1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
//------------------------------------------------------------------------------
// Mongoose/Tests/Mongoose_UnitTest_IO_exe.cpp
//------------------------------------------------------------------------------
// Mongoose Graph Partitioning Library, Copyright (C) 2017-2018,
// Scott P. Kolodziej, Nuri S. Yeralan, Timothy A. Davis, William W. Hager
// Mongoose is licensed under Version 3 of the GNU General Public License.
// Mongoose is also available under other licenses; contact authors for details.
// SPDX-License-Identifier: GPL-3.0-only
//------------------------------------------------------------------------------
#include "Mongoose_Test.hpp"
#include "Mongoose_IO.hpp"
#include "Mongoose_Sanitize.hpp"
using namespace Mongoose;
#undef LOG_ERROR
#undef LOG_WARN
#undef LOG_INFO
#undef LOG_TEST
#define LOG_ERROR 1
#define LOG_WARN 1
#define LOG_INFO 0
#define LOG_TEST 1
int main(int argn, char** argv)
{
(void)argn; // Unused variable
(void)argv; // Unused variable
SuiteSparse_start();
// Set Logger to report all messages and turn off timing info
Logger::setDebugLevel(All);
Logger::setTimingFlag(false);
Graph *G;
// Nonexistent file
G = read_graph("../Tests/Matrix/no_such_file.mtx");
assert (G == NULL);
// Bad header
G = read_graph("../Tests/Matrix/bad_header.mtx");
assert (G == NULL);
// Bad matrix type
G = read_graph("../Tests/Matrix/bad_matrix_type.mtx");
assert (G == NULL);
// Bad dimensions
G = read_graph("../Tests/Matrix/bad_dimensions.mtx");
assert (G == NULL);
// Rectangular matrix
G = read_graph("../Tests/Matrix/Trec4.mtx");
assert (G == NULL);
// C-style string filename
MM_typecode matcode;
std::string filename = "../Matrix/bcspwr01.mtx";
cs *M = read_matrix(filename, matcode);
assert(M != NULL);
cs *binaryM = sanitizeMatrix(M, true, true);
for (Int j = 0; j < M->nz; j++)
{
assert(binaryM->x[j] == 0 || binaryM->x[j] == 1);
}
SuiteSparse_free(M);
SuiteSparse_finish();
return 0;
}
|