diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake
index e0589f46..c543c057 100644
--- a/CMakeLists_files.cmake
+++ b/CMakeLists_files.cmake
@@ -137,6 +137,8 @@ list (APPEND MAIN_SOURCE_FILES
# find tests -name '*.cpp' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_SOURCE_FILES
tests/test_dgbasis.cpp
+ tests/test_cartgrid.cpp
+ tests/test_cubic.cpp
tests/test_nonuniformtablelinear.cpp
tests/test_sparsevector.cpp
tests/test_sparsetable.cpp
@@ -150,6 +152,7 @@ list (APPEND TEST_SOURCE_FILES
tests/test_param.cpp
tests/test_blackoilfluid.cpp
tests/test_shadow.cpp
+ tests/test_units.cpp
)
# originally generated with the command:
diff --git a/tests/not-unit/README.txt b/tests/not-unit/README.txt
new file mode 100644
index 00000000..c812efb4
--- /dev/null
+++ b/tests/not-unit/README.txt
@@ -0,0 +1 @@
+These files are not actively maintained. Do not expect them to compile and run.
diff --git a/tests/not-unit/bo_resprop_test.cpp b/tests/not-unit/bo_resprop_test.cpp
index 3f41e455..98a25306 100644
--- a/tests/not-unit/bo_resprop_test.cpp
+++ b/tests/not-unit/bo_resprop_test.cpp
@@ -17,12 +17,11 @@
along with OPM. If not, see .
*/
-
#include "config.h"
#include
-#include
-#include
+#include
+#include
#include
#include
diff --git a/tests/not-unit/pvt_test.cpp b/tests/not-unit/pvt_test.cpp
index 1f41de5d..59f02f49 100644
--- a/tests/not-unit/pvt_test.cpp
+++ b/tests/not-unit/pvt_test.cpp
@@ -21,10 +21,9 @@
#include "config.h"
#endif // HAVE_CONFIG_H
-
#include
-#include
-#include
+#include
+#include
#include
#include
diff --git a/tests/not-unit/relperm_test.cpp b/tests/not-unit/relperm_test.cpp
index ed6aeb8e..14a90ecf 100644
--- a/tests/not-unit/relperm_test.cpp
+++ b/tests/not-unit/relperm_test.cpp
@@ -23,8 +23,8 @@
#endif // HAVE_CONFIG_H
#include
-#include
-#include
+#include
+#include
#include
#include
diff --git a/tests/not-unit/test_agmg.cpp b/tests/not-unit/test_agmg.cpp
index 747a38fd..f6489f7e 100644
--- a/tests/not-unit/test_agmg.cpp
+++ b/tests/not-unit/test_agmg.cpp
@@ -108,9 +108,7 @@ int main()
// Create solver for SPD system.
Opm::LinearSolverAGMG linsolve(100, 1e-9, true);
-
- Opm::LinearSolverInterface::LinearSolverReport
- rpt = linsolve.solve(A.get(), & b[0], & x[0]);
+ linsolve.solve(A.get(), & b[0], & x[0]);
double e = 0.0;
for (std::size_t i = 0; i < m; ++i) {
diff --git a/tests/not-unit/test_cfs_tpfa.c b/tests/not-unit/test_cfs_tpfa.c
index 3116c4bf..c3cdfab0 100644
--- a/tests/not-unit/test_cfs_tpfa.c
+++ b/tests/not-unit/test_cfs_tpfa.c
@@ -7,7 +7,6 @@
#include
#include
-#include
#include
diff --git a/tests/not-unit/test_ert.cpp b/tests/not-unit/test_ert.cpp
index 019639ce..9b9bd37c 100644
--- a/tests/not-unit/test_ert.cpp
+++ b/tests/not-unit/test_ert.cpp
@@ -19,7 +19,7 @@
#include "config.h"
-#include
+#include
#include
#include
#include
diff --git a/tests/not-unit/test_jacsys.cpp b/tests/not-unit/test_jacsys.cpp
index 99d9b350..0fb70c7c 100644
--- a/tests/not-unit/test_jacsys.cpp
+++ b/tests/not-unit/test_jacsys.cpp
@@ -79,7 +79,7 @@ main() {
#endif
#if 0
-#include
+#include
//using namespace Opm::LinAlgSupport;
using namespace Opm::ImplicitTransportDefault;
@@ -104,9 +104,9 @@ main() {
#if 1
#include
-#include
-#include
-#include
+#include
+#include
+#include
using namespace Opm::ImplicitTransportDefault;
diff --git a/tests/not-unit/test_read_grid.c b/tests/not-unit/test_read_grid.c
index 5300bae5..74b68ca2 100644
--- a/tests/not-unit/test_read_grid.c
+++ b/tests/not-unit/test_read_grid.c
@@ -16,7 +16,7 @@ main(void)
struct UnstructuredGrid *G1, *G2;
G1 = read_grid("cart_grid_2d.txt");
- G2 = create_grid_cart2d(2, 2);
+ G2 = create_grid_cart2d(2, 2, 1., 1.);
destroy_grid(G2);
destroy_grid(G1);
diff --git a/tests/not-unit/test_read_vag.cpp b/tests/not-unit/test_read_vag.cpp
index 0149c107..6d115b3d 100644
--- a/tests/not-unit/test_read_vag.cpp
+++ b/tests/not-unit/test_read_vag.cpp
@@ -36,14 +36,14 @@
#include
#include
#include
-#include
+#include
#include
//#include "../config.h"
/* test reading of vag grid format */
int main(int argc, char** argv)
{
using namespace std;
- using namespace OPM;
+ using namespace Opm;
std::string filename;
if (argc == 2) {
filename = argv[1];
diff --git a/tests/not-unit/test_readpolymer.cpp b/tests/not-unit/test_readpolymer.cpp
index b58b848f..f62c96fa 100644
--- a/tests/not-unit/test_readpolymer.cpp
+++ b/tests/not-unit/test_readpolymer.cpp
@@ -14,7 +14,7 @@
#include "config.h"
#endif
-#include
+#include
// Test program for reading Eclipse Polymer keywords.
diff --git a/tests/not-unit/test_writeVtkData.cpp b/tests/not-unit/test_writeVtkData.cpp
index 3103b80f..afbe7028 100644
--- a/tests/not-unit/test_writeVtkData.cpp
+++ b/tests/not-unit/test_writeVtkData.cpp
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include
+#include
#include
#include
diff --git a/tests/not-unit/test_cartgrid.cpp b/tests/test_cartgrid.cpp
similarity index 57%
rename from tests/not-unit/test_cartgrid.cpp
rename to tests/test_cartgrid.cpp
index 3e96b6f1..77fe5449 100644
--- a/tests/not-unit/test_cartgrid.cpp
+++ b/tests/test_cartgrid.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
+ Portions Copyright 2013 Uni Research AS.
This file is part of the Open Porous Media project (OPM).
@@ -17,25 +18,41 @@
along with OPM. If not, see .
*/
-
#include "config.h"
+
+/* --- Boost.Test boilerplate --- */
+#if HAVE_DYNAMIC_BOOST_TEST
+#define BOOST_TEST_DYN_LINK
+#endif
+
+#define NVERBOSE // Suppress own messages when throw()ing
+
+#define BOOST_TEST_MODULE CartGridTest
+#include
+#include
+
+/* --- our own headers --- */
#include
#include
-#include
+#include
-int main(void)
+BOOST_AUTO_TEST_SUITE ()
+
+BOOST_AUTO_TEST_CASE (facenumbers)
{
- using namespace std;
- struct UnstructuredGrid *g = create_grid_cart2d(2, 2);
+ int faces[] = { 0, 6, 1, 8,
+ 1, 7, 2, 9,
+ 3, 8, 4, 10,
+ 4, 9, 5, 11 };
+ struct UnstructuredGrid *g = create_grid_cart2d(2, 2, 1., 1.);
int i;
int k;
for (i = 0; i < g->number_of_cells; ++i) {
- fprintf(stderr, "%d: ", i);
for (k = g->cell_facepos[i]; k < g->cell_facepos[i + 1]; ++k) {
- fprintf(stderr, "%d ", g->cell_faces[k]);
+ BOOST_REQUIRE_EQUAL (g->cell_faces[k], faces[k]);
}
- fprintf(stderr, "\n");
}
destroy_grid(g);
- return 0;
}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/not-unit/monotcubicinterpolator_test.cpp b/tests/test_cubic.cpp
similarity index 62%
rename from tests/not-unit/monotcubicinterpolator_test.cpp
rename to tests/test_cubic.cpp
index 752477d7..ecbb3f68 100644
--- a/tests/not-unit/monotcubicinterpolator_test.cpp
+++ b/tests/test_cubic.cpp
@@ -16,6 +16,7 @@
/*
Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
Copyright 2009, 2010 Statoil ASA.
+ Portions Copyright 2013 Uni Research AS.
This file is part of The Open Reservoir Simulator Project (OpenRS).
@@ -34,9 +35,25 @@
*/
#include "config.h"
-#include
-int main()
+/* --- Boost.Test boilerplate --- */
+#if HAVE_DYNAMIC_BOOST_TEST
+#define BOOST_TEST_DYN_LINK
+#endif
+
+#define NVERBOSE // Suppress own messages when throw()ing
+
+#define BOOST_TEST_MODULE CubicTest
+#include
+#include
+
+/* --- our own headers --- */
+#include
+using namespace Opm;
+
+BOOST_AUTO_TEST_SUITE ()
+
+BOOST_AUTO_TEST_CASE (cubic)
{
const int num_v = 3;
double xv[num_v] = {0.0, 1.0, 2.0};
@@ -44,11 +61,13 @@ int main()
std::vector x(xv, xv + num_v);
std::vector f(fv, fv + num_v);
MonotCubicInterpolator interp(x, f);
- interp.evaluate(-1.0);
- interp.evaluate(0.0);
- interp.evaluate(0.0001);
- interp.evaluate(0.5);
- interp.evaluate(1.0);
- interp.evaluate(2.0);
- interp.evaluate(4.0);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(-1.0), 10., 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(0.0), 10., 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(0.0001), 10.0011, 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(0.5), 17.375, 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(1.0), 21., 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(2.0), 2., 0.00001);
+ BOOST_REQUIRE_CLOSE (interp.evaluate(4.0), 2., 0.00001);
}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/not-unit/unit_test.cpp b/tests/test_units.cpp
similarity index 60%
rename from tests/not-unit/unit_test.cpp
rename to tests/test_units.cpp
index 66b60d18..37adbaae 100644
--- a/tests/not-unit/unit_test.cpp
+++ b/tests/test_units.cpp
@@ -34,6 +34,18 @@
*/
#include "config.h"
+/* --- Boost.Test boilerplate --- */
+#if HAVE_DYNAMIC_BOOST_TEST
+#define BOOST_TEST_DYN_LINK
+#endif
+
+#define NVERBOSE // Suppress own messages when throw()ing
+
+#define BOOST_TEST_MODULE UnitsTest
+#include
+#include
+
+/* --- our own headers --- */
#include
#include
#include
@@ -46,34 +58,31 @@
using namespace Opm::prefix;
using namespace Opm::unit;
-int main()
+BOOST_AUTO_TEST_SUITE ()
+
+BOOST_AUTO_TEST_CASE (units)
{
- std::cout << "m = " << meter << '\n';
- std::cout << "kg = " << kilogram << '\n';
- std::cout << "s = " << second << '\n';
+ BOOST_REQUIRE_EQUAL (meter, 1);
+ BOOST_REQUIRE_EQUAL (kilogram, 1);
+ BOOST_REQUIRE_EQUAL (second, 1);
- std::cout << "mD = " << milli*darcy << '\n';
- std::cout << "MD = " << mega*darcy << '\n';
+ BOOST_REQUIRE_CLOSE (milli*darcy, 9.86923667e-16, 0.01);
+ BOOST_REQUIRE_CLOSE (mega*darcy, 9.86923e-7, 0.01);
+ BOOST_REQUIRE_CLOSE (convert::to(mega*darcy, milli*darcy), 1e9, 0.01);
- std::cout << "MD = " << convert::to(mega*darcy, milli*darcy) << " mD\n";
-
- std::cout << "1 bar = " << convert::to(convert::from(1.0, barsa), psia) << " psi\n";
-
- std::cout << "1 atm = " << convert::to(1*atm, barsa) << " bar\n";
+ BOOST_REQUIRE_CLOSE (convert::to(convert::from(1.0, barsa), psia), 14.5038, 0.01);
+ BOOST_REQUIRE_CLOSE (convert::to(1*atm, barsa), 1.01325, 0.01);
std::vector flux(10, 10000*cubic(meter)/year);
-
- std::cout << "flux = [";
- std::copy(flux.begin(), flux.end(),
- std::ostream_iterator(std::cout, " "));
- std::cout << "\b] (m^3/s)\n";
+ for (int i = 0; i < 10; ++i) {
+ BOOST_REQUIRE_CLOSE (flux[i], 3.17098e-4, 0.01);
+ }
std::transform(flux.begin(), flux.end(), flux.begin(),
boost::bind(convert::to, _1, cubic(meter)/year));
- std::cout << " = [";
- std::copy(flux.begin(), flux.end(),
- std::ostream_iterator(std::cout, " "));
- std::cout << "\b] (m^3/year)\n";
-
- return 0;
+ for (int i = 0; i < 10; ++i) {
+ BOOST_REQUIRE_CLOSE (flux[i], 1e4, 0.01);
+ }
}
+
+BOOST_AUTO_TEST_SUITE_END()