void test01 ( void )

/******************************************************************************/
/*
  Purpose:

    TEST01 tests WRAP2.

  Licensing:

    This code is distributed under the GNU LGPL license. 

  Modified:

    31 May 2010

  Author:

    John Burkardt
*/
{
  int i;
  int m;
  int q;
  int q_in;

  fprintf ( stdout, "\n" );
  fprintf ( stdout, "TEST01\n" );
  fprintf ( stdout, "  WRAP2 performs a circular wrap.\n" );
  fprintf ( stdout, "  Q is expected to range between 0 and M.\n" );
  fprintf ( stdout, "  WRAP2 takes an input value of Q, and either\n" );
  fprintf ( stdout, "  increments it by M+1 until in the range, or\n" );
  fprintf ( stdout, "  decrements it by M+1 until in the range,\n" );
  fprintf ( stdout, "  and returns the result as the function value.\n" );

  for ( m = 2; m <= 4; m++ )
  {
    fprintf ( stdout, "\n" );
    fprintf ( stdout, "   M  Qin  Qout\n" );
    fprintf ( stdout, "\n" );
    for ( i = -5; i < 3 * m; i++ )
    {
      q = i;
      q_in = q;
      wrap2 ( m, &q );
      fprintf ( stdout, "  %2d  %2d  %2d\n", m, q_in, q );
    }
  }
  return;
}
Example #2
0
void work()
{
  auto thing = std::make_unique<CopyNoSwappy>();
  edm::Wrapper<CopyNoSwappy> wrap(std::move(thing));

  auto thing2 = std::make_unique<SwappyNoCopy>();
  edm::Wrapper<SwappyNoCopy> wrap2(std::move(thing2));


  auto thing3 = std::make_unique<std::vector<double>>(10,2.2);
  assert(thing3->size() == 10);

  edm::Wrapper<std::vector<double> > wrap3(std::move(thing3));
  assert(wrap3->size() == 10);
  assert(thing3.get() == 0);
}
Example #3
0
void work()
{
  std::unique_ptr<CopyNoSwappy> thing(new CopyNoSwappy);
  art::Wrapper<CopyNoSwappy> wrap(thing);

  std::unique_ptr<SwappyNoCopy> thing2(new SwappyNoCopy);
  art::Wrapper<SwappyNoCopy> wrap2(thing2);


  std::unique_ptr<std::vector<double> >
    thing3(new std::vector<double>(10,2.2));
  assert(thing3->size() == 10);

  art::Wrapper<std::vector<double> > wrap3(thing3);
  assert(wrap3->size() == 10);
  assert(thing3.get() == 0);
}
Example #4
0
// Macro test.  Since the std::move call is outside the macro, it is
// safe to suggest a fix-it.
A test8(A a) {
  return std::move(a);
  // expected-warning@-1{{prevents copy elision}}
  // expected-note@-2{{remove std::move call}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:20}:""
  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:21-[[@LINE-4]]:22}:""
  return std::move(wrap1(a));
  // expected-warning@-1{{prevents copy elision}}
  // expected-note@-2{{remove std::move call}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:20}:""
  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:28-[[@LINE-4]]:29}:""
  return std::move(wrap1(wrap2(a)));
  // expected-warning@-1{{prevents copy elision}}
  // expected-note@-2{{remove std::move call}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:20}:""
  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:35-[[@LINE-4]]:36}:""
}