Exemple #1
0
int main( int argc, char* argv[] )
{
    try {
        cla::parser P;

        P - cla::ignore_mismatch 
            << cla::named_parameter<rt::cstring>( "test" ) - (cla::prefix = "--")
            << cla::named_parameter<rt::cstring>( "init" ) - (cla::prefix = "--",cla::optional);

        P.parse( argc, argv );

        assign_op( test_lib_name, P.get( "test" ), 0 );
        if( P["init"] )
            assign_op( init_func_name, P.get( "init" ), 0 );

        int res = ::riakboost::unit_test::unit_test_main( &load_test_lib, argc, argv );

        ::riakboost::unit_test::framework::clear();
        dyn_lib::close( test_lib_handle );

        return res;
    }
    catch( rt::logic_error const& ex ) {
        std::cout << "Fail to parse command line arguments: " << ex.msg() << std::endl;
        return -1;
    }
}
Exemple #2
0
void bounds(iter_t begin, iter_t end, vector<ndim>& min, vector<ndim>& max) {
  if (begin == end) {
    min.setZero();
    max.setZero();
  } else {
    min = max = *begin;
    while (++begin != end) {
      vector<ndim> v = *begin;
      assign_op(min, min, v, carve::util::min_functor());
      assign_op(max, max, v, carve::util::max_functor());
    }
  }
}
/**
*   @brief Entry point of the program
*
*   @param [in]  argc   argument count
*   @param [in]  argv   argument vector
*   @return             Indicates execution failure or success
*/
int main(int argc, char* argv[])
{
    try
    {
        cla::parser P;

        P - cla::ignore_mismatch
                << cla::named_parameter<rt::cstring>("test") - (cla::prefix = "--")
                << cla::named_parameter<rt::cstring>("list") - (cla::prefix = "--", cla::optional)
                << cla::named_parameter<rt::cstring>("list-debug") - (cla::prefix = "--", cla::optional)
                << cla::named_parameter<rt::cstring>("init") - (cla::prefix = "--", cla::optional);

        P.parse(argc, argv);

        assign_op(test_lib_name, P.get("test"), 0);

        if (P["init"])
        {
            assign_op(init_func_name, P.get("init"), 0);
        }

        int res = ::boost::exit_success;

        //if the list or the list-debug command line directives are present then just enumerate tests,
        //otherwise execute the tests according to the additional Boost UTF specific  command line options supplied
        if (P["list"] || P["list-debug"])
        {
            res = ListTests(P);
        }
        else
        {
            //run tests
            res = ::boost::unit_test::unit_test_main(&load_test_lib, argc, argv);
        }

        ::boost::unit_test::framework::clear();
        dyn_lib::close(test_lib_handle);    //unload the library

        return res;
    }
    catch (rt::logic_error const& ex)
    {
        std::cout << "Fail to parse command line arguments: " << ex.msg() << std::endl;
        return -1;
    }
}
    static bool _( cstring source, hexerboost::optional<dstring>& res )
    {
        BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<dstring>" );

        res = dstring();
        assign_op( *res, source, 0 );

        return true;
    }
/**
*   @brief Generates an object of type ofstream so as to write to file
*
*   @param [in]  P   Reference to the object handling the command line parsing
*   @param [in]  arg Full filepath where to write the XML file to
*/
std::unique_ptr<std::ofstream> GetListOutputStream(const cla::parser& P, const std::string& arg)
{
    std::string listOut;
    assign_op(listOut, P.get(arg), 0);

    if (!listOut.empty())
    {
        return std::unique_ptr<std::ofstream>(new std::ofstream(listOut, (std::ios_base::out | std::ios_base::trunc)));
    }

    return std::unique_ptr<std::ofstream>();
}
Exemple #6
0
RecordingStatus::Enum assign_record(Thread & thread, Instruction const & inst, Instruction const ** pc) {
	*pc = assign_op(thread,inst);
	Value& r = REGISTER(thread, inst.c);
	//Inline this logic here would make the recorder more fragile, 
	// so for now we simply construct the pointer again:
	if(r.isFuture()) {
		thread.trace.outputs.push_back(thread.frame.environment->makePointer((String)inst.a));
		thread.trace.Commit(thread);
	}
	//thread.trace.SetMaxLiveRegister(thread.base,inst.c);
	return RecordingStatus::NO_ERROR;
}
Exemple #7
0
    void        operator()( mpl::identity<TestType> )
    {
        std::string full_name;
        assign_op( full_name, m_test_case_name, 0 );
        full_name += '<';
        full_name += typeid(TestType).name();
        if( boost::is_const<TestType>::value )
            full_name += " const";
        full_name += '>';

        m_holder.m_test_cases.push_back( 
            new test_case( full_name, test_case_template_invoker<TestCaseTemplate,TestType>() ) );
    }
    void        operator()( mpl::identity<TestType> )
    {
        std::string full_name;
        assign_op( full_name, m_test_case_name, 0 );
        full_name += '<';
#ifndef BOOST_NO_RTTI
         full_name += typeid(TestType).name();
#else
        full_name += BOOST_CURRENT_FUNCTION;
#endif
        if( boost::is_const<TestType>::value )
            full_name += "_const";
        full_name += '>';

        m_holder.m_test_cases.push_back( new test_case( ut_detail::normalize_test_case_name( full_name ),
                                                        m_test_case_file,
                                                        m_test_case_line,
                                                        test_case_template_invoker<TestCaseTemplate,TestType>() ) );
    }
Exemple #9
0
void
carve::triangulate::incorporateHolesIntoPolygon(
    const std::vector<std::vector<carve::geom2d::P2> > &poly,
    std::vector<std::pair<size_t, size_t> > &result,
    size_t poly_loop,
    const std::vector<size_t> &hole_loops) {
  typedef std::vector<carve::geom2d::P2> loop_t;

  size_t N = poly[poly_loop].size();

  // work out how much space to reserve for the patched in holes.
  for (size_t i = 0; i < hole_loops.size(); i++) {
    N += 2 + poly[hole_loops[i]].size();
  }

  // this is the vector that we will build the result in.
  result.clear();
  result.reserve(N);

  // this is a heap of result indices that defines the vertex test order.
  std::vector<size_t> f_loop_heap;
  f_loop_heap.reserve(N);

  // add the poly loop to result.
  for (size_t i = 0; i < poly[poly_loop].size(); ++i) {
    result.push_back(std::make_pair((size_t)poly_loop, i));
  }

  if (hole_loops.size() == 0) {
    return;
  }

  std::vector<std::pair<size_t, size_t> > h_loop_min_vertex;

  h_loop_min_vertex.reserve(hole_loops.size());

  // find the major axis for the holes - this is the axis that we
  // will sort on for finding vertices on the polygon to join
  // holes up to.
  //
  // it might also be nice to also look for whether it is better
  // to sort ascending or descending.
  // 
  // another trick that could be used is to modify the projection
  // by 90 degree rotations or flipping about an axis. just as
  // long as we keep the carve::geom3d::Vector pointers for the
  // real data in sync, everything should be ok. then we wouldn't
  // need to accomodate axes or sort order in the main loop.

  // find the bounding box of all the holes.
  carve::geom2d::P2 h_min, h_max;
  h_min = h_max = poly[hole_loops[0]][0];
  for (size_t i = 0; i < hole_loops.size(); ++i) {
    const loop_t &hole = poly[hole_loops[i]];
    for (size_t j = 0; j < hole.size(); ++j) {
      assign_op(h_min, h_min, hole[j], carve::util::min_functor());
      assign_op(h_max, h_max, hole[j], carve::util::max_functor());
    }
  }
  // choose the axis for which the bbox is largest.
  int axis = (h_max.x - h_min.x) > (h_max.y - h_min.y) ? 0 : 1;

  // for each hole, find the minimum vertex in the chosen axis.
  for (size_t i = 0; i < hole_loops.size(); ++i) {
    const loop_t &hole = poly[hole_loops[i]];
    size_t best, curr;
    best = 0;
    for (curr = 1; curr != hole.size(); ++curr) {
      if (detail::axisOrdering(hole[curr], hole[best], axis)) {
        best = curr;
      }
    }
    h_loop_min_vertex.push_back(std::make_pair(hole_loops[i], best));
  }

  // sort the holes by the minimum vertex.
  std::sort(h_loop_min_vertex.begin(), h_loop_min_vertex.end(), order_h_loops_2d(poly, axis));

  // now, for each hole, find a vertex in the current polygon loop that it can be joined to.
  for (unsigned i = 0; i < h_loop_min_vertex.size(); ++i) {
    // the index of the vertex in the hole to connect.
    size_t hole_i = h_loop_min_vertex[i].first;
    size_t hole_i_connect = h_loop_min_vertex[i].second;

    carve::geom2d::P2 hole_min = poly[hole_i][hole_i_connect];

    f_loop_heap.clear();
    // we order polygon loop vertices that may be able to be connected
    // to the hole vertex by their distance to the hole vertex
    heap_ordering_2d _heap_ordering(poly, result, hole_min, axis);

    const size_t SZ = result.size();
    for (size_t j = 0; j < SZ; ++j) {
      // it is guaranteed that there exists a polygon vertex with
      // coord < the min hole coord chosen, which can be joined to
      // the min hole coord without crossing the polygon
      // boundary. also, because we merge holes in ascending
      // order, it is also true that this join can never cross
      // another hole (and that doesn't need to be tested for).
      if (pvert(poly, result[j]).v[axis] <= hole_min.v[axis]) {
        f_loop_heap.push_back(j);
        std::push_heap(f_loop_heap.begin(), f_loop_heap.end(), _heap_ordering);
      }
    }

    // we are going to test each potential (according to the
    // previous test) polygon vertex as a candidate join. we order
    // by closeness to the hole vertex, so that the join we make
    // is as small as possible. to test, we need to check the
    // joining line segment does not cross any other line segment
    // in the current polygon loop (excluding those that have the
    // vertex that we are attempting to join with as an endpoint).
    size_t attachment_point = result.size();

    while (f_loop_heap.size()) {
      std::pop_heap(f_loop_heap.begin(), f_loop_heap.end(), _heap_ordering);
      size_t curr = f_loop_heap.back();
      f_loop_heap.pop_back();
      // test the candidate join from result[curr] to hole_min

      if (!testCandidateAttachment(poly, result, curr, hole_min)) {
        continue;
      }

      attachment_point = curr;
      break;
    }

    if (attachment_point == result.size()) {
      CARVE_FAIL("didn't manage to link up hole!");
    }

    patchHoleIntoPolygon_2d(result, attachment_point, hole_i, hole_i_connect, poly[hole_i].size());
  }
}