Exemplo n.º 1
0
 void perform_test_trivial() {
   const bool ab = equivalent(a,b);
   const bool ba = equivalent(b,a);
   switch (ab) {
   case true :
     if (not ba)
       OKLIB_THROW("a ~ b and not b ~ a");
     break;
   case false :
     if (ba)
       OKLIB_THROW("not a ~ b and b ~ a");
     break;
   }
 }
Exemplo n.º 2
0
 void perform_test_trivial() {
   const bool a_eq_b = (a == b);
   const bool a_neq_b = (a != b);
   switch (a_eq_b) {
   case true :
     if (a_neq_b)
       OKLIB_THROW("a == b and a != b");
     break;
   case false :
     if (not a_neq_b)
       OKLIB_THROW("not a == b and not a != b");
     break;
   }
 }
Exemplo n.º 3
0
 void perform_test_trivial() {
   const bool ab = (a == b);
   const bool ba = (b == a);
   switch (ab) {
   case true :
     if (not ba)
       OKLIB_THROW("a == b and not b == a");
     break;
   case false :
     if (ba)
       OKLIB_THROW("not a == b and b == a");
     break;
   }
 }
      void test_result(const std::string& filename, const unsigned int line_count) {

        typedef Result_database_from_file<ParserResult, result_type> result_database;
        typedef typename result_database::database_type database;
        typedef ElementaryAnalysis<database> indexed_database;
        typedef LexicographicalEvaluation<indexed_database, LexicographicalSeriesPolicy<result_type> > lexicographical_evaluation_type;
        typedef typename lexicographical_evaluation_type::size_type size_type;
        typedef typename lexicographical_evaluation_type::number_type number_type;
        typedef typename lexicographical_evaluation_type::map_solver_evaluation_type map_solver_evaluation_type;
        typedef typename lexicographical_evaluation_type::numerics_solver_on_series_type numerics_solver_on_series_type;

        result_database rdb(filename);
        assert(rdb.result_sequence.size() == line_count);
        indexed_database idb(rdb.db);
        lexicographical_evaluation_type lexicographical_evaluation(idb);

        typedef typename indexed_database::map_solver_benchmarks map_solver_benchmarks;
        typedef typename IteratorHandling::IteratorFirst<typename map_solver_benchmarks::const_iterator>::type iterator;
        const map_solver_benchmarks& map_benchmarks(idb.solved_benchmarks());
        const iterator end(map_benchmarks.end());
        for (iterator i(map_benchmarks.begin()); i != end; ++i) { // loop over all solvers
          const Solver& solver(*i);
          
          const map_solver_evaluation_type& map(lexicographical_evaluation.evaluation(solver));
          typedef typename map_solver_evaluation_type::const_iterator iterator;
          typedef typename IteratorHandling::IteratorSecond<iterator>::type iterator_second;
          OKLIB_TEST_EQUAL(OKlib::SetAlgorithms::sum_sizes(iterator_second(map.begin()), iterator_second(map.end())), OKlib::SetAlgorithms::map_value(idb.solved_series(), solver).size());
          size_type sum = 0;
          const iterator& end(map.end());
          for (iterator j(map.begin()); j != end; ++j) {
            typedef typename lexicographical_evaluation_type::map_series_numerics_type map_series_numerics_type;
            const map_series_numerics_type& map(j -> second);

            typedef typename map_series_numerics_type::const_iterator iterator;
            const iterator& end(map.end());
            for (iterator k(map.begin()); k != end; ++k) {
              const numerics_solver_on_series_type& n(k -> second);

              if (n.first <= 0)
                OKLIB_THROW("n.first <= 0, namely n.first = " + boost::lexical_cast<std::string>(n.first));
              sum += n.first;
              if (n.first != 0 and n.second < 0)
                OKLIB_THROW("n.first = " +  boost::lexical_cast<std::string>(n.first) + ", and n.second < 0, namely n.second = " + boost::lexical_cast<std::string>(n.second));
            }
          }
          if (sum != OKlib::SetAlgorithms::map_value(map_benchmarks, solver).size())
            OKLIB_THROW("sum != OKlib::SetAlgorithms::map_value(map_benchmarks, solver).size(), namely sum = " +  boost::lexical_cast<std::string>(sum) + ", while map_value(map_benchmarks, solver).size() = " + boost::lexical_cast<std::string>(OKlib::SetAlgorithms::map_value(map_benchmarks, solver).size()) + "\nContext: solver = " + boost::lexical_cast<std::string>(solver));
        }
                
      }
Exemplo n.º 5
0
 void perform_test_trivial() {
   switch (match) {
   case match_full:
     if (not boost::spirit::parse(test_string.c_str(), parser.parser()).full)
       OKLIB_THROW("String " + test_string + " was not accepted.");
       // ToDo: Using Messages
     break;
   case (match_not_full) :
     if (boost::spirit::parse(test_string.c_str(), parser.parser()).full) {
       OKLIB_THROW("String " + test_string + " was accepted.");
       // ToDo: Using Messages
       break;
     }
   }
 }
Exemplo n.º 6
0
 void perform_test_trivial() {
   if (not info.full) {
     const ParseIterator it(info.stop);
     typedef boost::spirit::file_position position_type;
     const position_type pos(it.get_position());
     OKLIB_THROW("Parse error in file " + pos.file + " at line " + boost::lexical_cast<std::string>(pos.line) + " and column " +  boost::lexical_cast<std::string>(pos.column));
   }
 }
 void perform_test_trivial() {
   Result s;
   typedef ParserResult<Result> Parser;
   Parser p(s);
   {
     typedef std::vector<TupleResult> Vector;
     Vector test_vector;
     add_positive_result_tuples(test_vector);
      for (Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
       std::stringstream test_stream;
       test_stream << *i;
       const std::string test(test_stream.str());
       OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
       if (s.super_series().name() != i -> get<0>().name()) {
         std::stringstream out;
         out << "Super Series is " << s.super_series() << ", and not " << i -> get<0>();
         OKLIB_THROW(out.str());
       }
       if (s.series().name() != i -> get<1>().name()) {
         std::stringstream out;
         out << "Series is " << s.series() << ", and not " << i -> get<1>();
         OKLIB_THROW(out.str());
       }
       if (s.benchmark().name() != i -> get<2>().name()) {
         std::stringstream out;
         out << "Benchmark is " << s.benchmark() << ", and not " << i -> get<2>();
         OKLIB_THROW(out.str());
       }
       if (s.solver().name() != i -> get<3>().name()) {
         std::stringstream out;
         out << "Solver is " << s.solver() << ", and not " << i -> get<3>();
         OKLIB_THROW(out.str());
       }
       if (s.sat_status().result() != i -> get<4>().result()) {
         std::stringstream out;
         out << "Sat_Status is " << s.sat_status() << ", and not " << i -> get<4>();
         OKLIB_THROW(out.str());
       }
       if (s.average().average() != i -> get<5>().average()) {
         std::stringstream out;
         out << "Average is " << s.average() << ", and not " << i -> get<5>();
         OKLIB_THROW(out.str());
       }
       if (s.time_out().time_out() != i -> get<6>().time_out()) {
         std::stringstream out;
         out << "Time_Out is " << s.time_out() << ", and not " << i -> get<6>();
         OKLIB_THROW(out.str());
       }
       if (s != *i) {
         std::stringstream out;
         out << "Result is \"" << s <<"\", and not \"" << *i << "\"";
         OKLIB_THROW(out.str());
       }
     }
   }
 }
Exemplo n.º 8
0
 void perform_test_trivial() {
   const bool ab = (a == b);
   const bool ac = (a == c);
   const bool bc = (b == c);
   const int count_equal = ab + ac + bc;
   if (count_equal == 2)
     OKLIB_THROW("one equality missing");
 }
 void perform_test_trivial() {
   SuperSeries s;
   typedef ParserResultElement<SuperSeries> Parser;
   Parser p(s);
   {
     const std::string test = "abc123ABC";
     OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
     if(s.name() != test)
       OKLIB_THROW("Resulting name is " + s.name() + ", and not " + test);
   }
 }
Exemplo n.º 10
0
 void perform_test_trivial() {
   RandomKSat s;
   typedef ParserResultElement<RandomKSat> Parser;
   Parser p(s);
   {
     typedef typename RandomKSat::natural_number_type natural_number_type;
     typedef std::vector<natural_number_type> Test_vector;
     Test_vector tv;
     tv.push_back(3); tv.push_back(10);
     for (typename Test_vector::const_iterator i = tv.begin(); i != tv.end(); ++i) {
       const natural_number_type k = *i;
       const std::string k_string(boost::lexical_cast<std::string>(k));
       const std::string test = k_string + "SAT";
       OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
       if(s.name() != test)
         OKLIB_THROW("Resulting name is " + s.name() + ", and not " + test);
       if (s.clause_length() != k)
         OKLIB_THROW("Clause length is " + boost::lexical_cast<std::string>(s.clause_length()) + ", and not " + k_string);
     }
   }
 }
Exemplo n.º 11
0
 void perform_test_trivial() {
   RandomKSat_n s;
   typedef ParserResultElement<RandomKSat_n> Parser;
   Parser p(s);
   {
     typedef typename RandomKSat_n::natural_number_type natural_number_type;
     typedef std::pair<std::string, natural_number_type> Pair;
     typedef std::vector<Pair> Vector;
     Vector test_vector;
     test_vector.push_back(Pair("random/MediumSizeBenches/k3-r4.263-v", 300));
     test_vector.push_back(Pair("random/MediumSizeBenches/k3-v7-r4.263-v", 20));
     test_vector.push_back(Pair("random/MediumSizeBenches/k3-v7-r4.263---v", 20));
     for (typename Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
       const natural_number_type n = i -> second;
       const std::string test_n =  boost::lexical_cast<std::string>(n);
       const std::string test = i -> first + test_n;
       OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
       if(s.name() != test)
         OKLIB_THROW("Resulting name is " + s.name() + ", and not " + test);
       if (s.count_variables() != n)
         OKLIB_THROW("Variables count is " + boost::lexical_cast<std::string>(s.count_variables()) + ", and not " + test_n);
     }
   }
 }
Exemplo n.º 12
0
 void perform_test_trivial() {
   TimeOut s;
   typedef ParserResultElement<TimeOut> Parser;
   Parser p(s);
   {
     typedef std::vector<std::string> Vector;
     Vector test_vector;
     test_vector.push_back("0");
     test_vector.push_back("1");
     test_vector.push_back("1200");
     for (Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
       const std::string test = *i;
       typedef typename TimeOut::natural_number_type natural_number_type;
       const natural_number_type time_out = boost::lexical_cast<natural_number_type>(test);
       OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
       if(s.time_out() != time_out)
         OKLIB_THROW("Time_Out is " + boost::lexical_cast<std::string>(s.time_out()) + ", and not " + boost::lexical_cast<std::string>(time_out));
     }
   }
 }
Exemplo n.º 13
0
 void perform_test_trivial() {
   AverageTime s;
   typedef ParserResultElement<AverageTime> Parser;
   Parser p(s);
   {
     typedef std::vector<std::string> Vector;
     Vector test_vector;
     test_vector.push_back("0.0");
     test_vector.push_back("0.1");
     test_vector.push_back("20.2");
     test_vector.push_back("10E3");
     test_vector.push_back("100");
     for (Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
       const std::string test = *i;
       typedef typename AverageTime::floating_point_type floating_point_type;
       const floating_point_type average = boost::lexical_cast<floating_point_type>(test);
       OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
       if(s.average() != average)
         OKLIB_THROW("Average is " + boost::lexical_cast<std::string>(s.average()) + ", and not " + boost::lexical_cast<std::string>(average));
     }
   }
 }
Exemplo n.º 14
0
 void perform_test_trivial() {
     Literal l;
     ParserLiteral p(l);
     {
         typedef std::vector<std::string> Vector;
         Vector test_vector;
         test_vector.push_back("123");
         test_vector.push_back("-456");
         for (Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
             OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<ParserLiteral>(p, *i, ::OKlib::Parser::match_full));
             if (l.l != boost::lexical_cast<int_type>(*i))
                 OKLIB_THROW("Index is " + boost::lexical_cast<std::string>(l.l) + ", and not " + *i);
         }
     }
     {
         typedef std::vector<std::string> Vector;
         Vector test_vector;
         test_vector.push_back("0123");
         test_vector.push_back("+456");
         for (Vector::const_iterator i = test_vector.begin(); i != test_vector.end(); ++i) {
             OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<ParserLiteral>(p, *i, ::OKlib::Parser::match_not_full));
         }
     }
 }
Exemplo n.º 15
0
 void perform_test_trivial() {
   if (not (a == b))
     OKLIB_THROW("not a == b");
 }
Exemplo n.º 16
0
 void perform_test_trivial() {
   if (not (a < c))
     OKLIB_THROW("not a < c");
 }
Exemplo n.º 17
0
 void perform_test_trivial() {
   if (not equivalent(a,a))
     OKLIB_THROW("not a ~ a");
 }
Exemplo n.º 18
0
 void perform_test_trivial() {
   if (++counter == throw_value)
     OKLIB_THROW(boost::lexical_cast<std::string>(counter));
 }
Exemplo n.º 19
0
 void perform_test_trivial() {
   if (not (a == x))
     OKLIB_THROW("not (a == x) after copy construction");
 }
Exemplo n.º 20
0
 void perform_test_trivial() {
   if (equivalent(a,b) and equivalent(b,c) and not equivalent(a,c))
     OKLIB_THROW("a ~ b and b ~ c and not a ~ c");
 }
Exemplo n.º 21
0
 void perform_test_trivial() {
   if (a < b or b < a)
     OKLIB_THROW("a < b or b < a");
 }
Exemplo n.º 22
0
 void perform_test_trivial() {
   x = b;
   if (not (x == b))
     OKLIB_THROW("not (x == b) after assignment x = b");
 }
Exemplo n.º 23
0
 void perform_test_trivial() {
   if (not (T() == T()))
     OKLIB_THROW("not (T() == T())");
 }
Exemplo n.º 24
0
 void perform_test_trivial() {
   if (not (b <= a))
     OKLIB_THROW("not b <= a");
 }
Exemplo n.º 25
0
 void perform_test_trivial() {
   if (a > b)
     OKLIB_THROW("not not a > b");
 }