1 #include <string> 2 #include "Mongoose_IO.hpp" 3 #include "Mongoose_Test.hpp" 4 5 using namespace Mongoose; 6 runIOTest(const std::string & inputFile,bool validGraph)7int runIOTest(const std::string &inputFile, bool validGraph) 8 { 9 LogTest("Running I/O Test on " << inputFile); 10 11 Graph *G = read_graph(inputFile); 12 13 if (validGraph) 14 { 15 assert(G != NULL); // A valid graph should not be null 16 assert(G->n > 0); // A valid graph should have 17 assert(G->nz >= 0); // At least 1 edge 18 assert(G->p != NULL); // Column pointers should not be null 19 assert(G->i != NULL); // Row numbers should not be null 20 G->~Graph(); 21 } 22 else 23 { 24 assert(G == NULL); 25 } 26 27 // Also try with C-style string 28 Graph *G2 = read_graph(inputFile.c_str()); 29 30 if (validGraph) 31 { 32 assert(G2 != NULL); // A valid graph should not be null 33 assert(G2->n > 0); // A valid graph should have 34 assert(G2->nz >= 0); // At least 1 edge 35 assert(G2->p != NULL); // Column pointers should not be null 36 assert(G2->i != NULL); // Row numbers should not be null 37 G2->~Graph(); 38 } 39 else 40 { 41 assert(G2 == NULL); 42 } 43 44 LogTest("I/O Test Completed Successfully"); 45 46 return EXIT_SUCCESS; 47 }