/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * MPQCCommandJobUnitTest.cpp * * Created on: Feb 08, 2012 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include // include headers that implement a archive in simple text format #include #include #include #include "MPQCCommandJobUnitTest.hpp" #include "Jobs/MPQCCommandJob.hpp" #include "CodePatterns/Assert.hpp" #include "CodePatterns/Log.hpp" #ifdef HAVE_TESTRUNNER #include "UnitTestMain.hpp" #endif /*HAVE_TESTRUNNER*/ /********************************************** Test classes **************************************/ const std::string resultstring="\ \n\ total scf energy = -37.3479855\n\ \n\ Total Gradient:\n\ 1 H -2.35 -0.54 0.345\n\ 2 H 0.35 -0.54 0.345\n\ \n\ "; // Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( MPQCCommandJobTest ); void MPQCCommandJobTest::setUp() { // Throw assertions ASSERT_DO(Assert::Throw); setVerbosity(3); job = new MPQCCommandJob(std::string("empty"), 1); } void MPQCCommandJobTest::tearDown() { delete job; } /** UnitTest for extractString() */ void MPQCCommandJobTest::extractStringTest() { // prepare result container MPQCData data; data.energy = -37.3479855; std::vector force; std::vector< std::vector > forces; force.push_back(-2.35); force.push_back(-0.54); force.push_back(0.345); data.forces.push_back( force ); force.clear(); force.push_back(0.35); force.push_back(-0.54); force.push_back(0.345); data.forces.push_back( force ); // extract and check FragmentResult::ptr result = job->extractResult(resultstring); std::stringstream returnstream(result->result); // deserialize MPQCData extractedData; boost::archive::text_iarchive ia(returnstream); ia >> extractedData; CPPUNIT_ASSERT( data == extractedData ); }