[cig-commits] r13185 - in cs/cigma/trunk: src tests/libcigma

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:12:10 PDT 2008


Author: luis
Date: 2008-10-29 15:12:09 -0700 (Wed, 29 Oct 2008)
New Revision: 13185

Modified:
   cs/cigma/trunk/src/io_text_reader.cpp
   cs/cigma/trunk/tests/libcigma/ReaderTest.cpp
Log:
Test fixture for reader

Modified: cs/cigma/trunk/src/io_text_reader.cpp
===================================================================
--- cs/cigma/trunk/src/io_text_reader.cpp	2008-10-29 22:12:08 UTC (rev 13184)
+++ cs/cigma/trunk/src/io_text_reader.cpp	2008-10-29 22:12:09 UTC (rev 13185)
@@ -49,6 +49,7 @@
 
 // ----------------------------------------------------------------------------
 
+// XXX: rethink this method (usage is awkward...see unit tests)
 static FILE *get_fp(const char *loc, FILE *default_fp)
 {
     FILE *fp = default_fp;

Modified: cs/cigma/trunk/tests/libcigma/ReaderTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/ReaderTest.cpp	2008-10-29 22:12:08 UTC (rev 13184)
+++ cs/cigma/trunk/tests/libcigma/ReaderTest.cpp	2008-10-29 22:12:09 UTC (rev 13185)
@@ -28,6 +28,27 @@
 
 void ReaderTest::test_text_reader()
 {
+    int status;
     TextReader reader;
+
     CPPUNIT_ASSERT_EQUAL(reader.getReaderType(), FileReader::TEXT_FILE_READER);
+
+    status = reader.open("tests/data/brick1/brick1_connect.dat");
+    CPPUNIT_ASSERT_EQUAL(0, status);
+
+    int nel,ndofs;
+    int *connect;
+    status = reader.getConnectivity("", &connect, &nel, &ndofs);
+    CPPUNIT_ASSERT_EQUAL(0, status);
+
+    CPPUNIT_ASSERT_EQUAL(8, nel);
+    CPPUNIT_ASSERT_EQUAL(8, ndofs);
+
+    CPPUNIT_ASSERT_EQUAL(10, connect[8*1+5]);
+    CPPUNIT_ASSERT_EQUAL(17, connect[8*3+6]);
+    CPPUNIT_ASSERT_EQUAL(24, connect[8*7+7]);
+
+    status = reader.close();
+    delete [] connect;
 }
+



More information about the CIG-COMMITS mailing list