c++ - boost unit test fails with error - unknown location(0): fatal error in "MyCheckTest": -


i'm trying run unit test using boost gives me error when run test -> " unknown location(0): fatal error in "mychecktest":"

error not mention line test failing.. i'm not able figure out , hence sharing code:

// function.hpp

#pragma once  #include <boost/archive/text_oarchive.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/serialization.hpp> #include <boost/serialization/access.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/export.hpp>  struct function {     std::string id, name;    private:     friend class boost::serialization::access;     template<class archive>         void serialize(archive &ar, const unsigned int /*version*/)         {             ar & id;             ar & name;         }       public:     function(void);     typedef int parameter_strings;     function(const parameter_strings & parms) { }      virtual ~function(void); };  boost_class_export_key(function); 

// function.cpp

#include "functions.hpp"  function::~function() {    std::cout<< " destructor called \n"; }  function::function() {    std::cout<<" constructor called \n"; }  boost_class_export_implement(function); boost_class_implementation(function, boost::serialization::object_serializable); boost_class_tracking(function, boost::serialization::track_never); 

// maintest.cpp

#define boost_test_main  #include <boost/test/unit_test.hpp> #include "functions.hpp" #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp>   void set_data(function *c1) {    c1->id= "sheena";    c1->name="kurian"; }  void check_data(function *m1,function *m2) {    boost_check(m1->id==m2->id);    boost_check(m1->name==m2->name);     boost_check(m1->id.size() == m2->id.size());    boost_check(m1->name.size() == m2->name.size()); }  boost_auto_test_case(mychecktest) {    boost::archive::text_oarchive ao(std::cout);     function c;    set_data(&c);     const function & oc=c;     ao & oc;  // serialize     std::stringstream ss;     boost::archive::text_iarchive ia(ss);     function d;    ia >> d; // deserialize     check_data(&c,&d); // comparing data  } 

in maintest.cpp file, i'm trying test , gives me error message shown below:

running 1 test case... 1>  22 serialization::archive 10 constructor called  1>   7 sheena 7 kurian destructor called  1>   1>  unknown location(0): fatal error in "mychecktest": std::exception: invalid signature 1>   1>  test suite "master test suite" failed with: 1>    1 assertion out of 1 failed 1>    1 test case out of 1 failed 1>    1 test case out of 1 aborted 

don't know why giving fatal error mychecktest. if typo mistake or header file missing please let me know.

atleast should give error simialr stated below :

maintest.cpp(10): error in "my_test": check m1->id == m2->id failed. 1 failure detected in test suite "mychecktest"


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -