Esempio n. 1
0
int
main (void)
{
  struct s g6_s = { 106 };

  start (1, 0);
  g1 (tmp);

  start (2, 0);
  g2 (&tmp);

  start (3, 0);
  g3 (&tmp);

  start (4, 0);
  g4 (&tmp);

  start (5, 0);
  g5 (tmp);

  start (6, &g6_s);
  g6 (tmp);

  start (7, 0);
  g7 (tmp);

  start (8, 0);
  g8 (&tmp);

  start (9, 0);
  g9 (&tmp);

  return 0;
}
bool sanity()
{  
   GameState g0(5, 7, 7);    // Not a valid game state 
   GameState g1(1, 2, 254);  // Finish in 1 round
   GameState g2(2, 3, 254);  //   ...  in 2 rounds
   GameState g3(3, 4, 254);  //   ...  in 3 rounds
   GameState g4(4, 5, 254);  //
   GameState g5(4, 9, 254);  // These come from a (slower) python implementation
   GameState g6(8, 11, 254);
   GameState g7(12, 19, 254);
   GameState g8(8, 35, 254);
   
   GameState g9(1, 4, 6);   // From webpage, known to finish in 15 minutes = at round 2
   
   if (explore_game(g0)!=0) return false; // Verify that we get the expected number
   if (explore_game(g1)!=1) return false; // of rounds for given input states
   if (explore_game(g2)!=2) return false; //
   if (explore_game(g3)!=3) return false; // report an error if not
   if (explore_game(g4)!=4) return false;
   if (explore_game(g5)!=5) return false;
   if (explore_game(g6)!=6) return false;
   if (explore_game(g7)!=7) return false;
   if (explore_game(g8)!=8) return false;
   if (explore_game(g9)!=2) return false;
   
   return true;
}
Esempio n. 3
0
/*
   Gauge32( void);
   Gauge32( const unsigned long i);
   Gauge32 ( const Gauge32 &g);
   ~Gauge32();
   SmiUINT32 get_syntax();
   SnmpSyntax *clone() const;
   Gauge32& operator=( const Gauge32 &uli);
   Gauge32& operator=( const unsigned long i);
   operator unsigned long();
   SnmpSyntax& operator=( SnmpSyntax &val);

--  What is a Gauge? According to RFC 1155 section: 3.2.3.4
   This  application-wide type represents a non-negative integer
   which may increase or decrease, but which latches at a maximum
   value of 2^32-1 (4294967295 dec) for gauges.
 */
static void
TestGuage (void)
{
#if !defined (ACE_WIN32)
   long l = LONG_MAX, nl = LONG_MIN;  // limits.h
   unsigned long ul = ULONG_MAX, def = 0;
   int i = INT_MAX, ni = INT_MIN;
   unsigned int ui = UINT_MAX;
   unsigned short us = 10;
   short si = static_cast<short> (65535);

   // constructors
   Gauge32 g1;
   ACE_ASSERT(g1 == def);
   Gauge32 g2(l);
   ACE_ASSERT(g2 == static_cast<unsigned long> (l));
   Gauge32 g3(nl);
   ACE_ASSERT(g3 == static_cast<unsigned long> (nl));
   Gauge32 g4(ul);
   ACE_ASSERT(g4 == ul);
   Gauge32 g5(i);
   ACE_ASSERT(g5 == static_cast<unsigned long> (i));
   Gauge32 g6(ni);
   ACE_ASSERT(g6 == static_cast<unsigned long> (ni));
   Gauge32 g7(ui);
   ACE_ASSERT(g7 == ui);
   Gauge32 *g8 = new Gauge32(g5);
   ACE_ASSERT(g8 != 0);
   delete g8;

  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g1(\"\") [%u]\n",
    (unsigned long)g1));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g2(\"%u\") [%u]\n",
    l, (unsigned long)g2));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g3(\"%u\") [%u]\n",
    nl, (unsigned long)g3));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g4(\"%u\") [%u]\n",
    ul, (unsigned long)g4));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g5(\"%u\") [%u]\n",
    i, (unsigned long)g5));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g6(\"%u\") [%u]\n",
    ni, (unsigned long)g6));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g7(\"%u\") [%u]\n",
    ui, (unsigned long)g7));

  // assignent
  g1 = g2;  // obj
  ACE_ASSERT(g1 == g2);
  g1 = g1; // self
  ACE_ASSERT(g1 == g1);
  g1 = def; // unsigned long
  ACE_ASSERT(g1 == def);
  g1 = us; // unsigned short
  ACE_ASSERT(g1 == static_cast<unsigned long> (us));
  g1 = si; // unsigned short
  ACE_ASSERT(g1 == static_cast<unsigned long> (si));
#endif /*ACE_WIN32*/
}
Esempio n. 4
0
int main1(void)
{ 
  int i;
  /* Check vec_extract with a non constant element numbering */
  for(i=0;i<10;i++)
    { 
      if (f(a, i) != (i&0x3))
        abort ();
    }
  
  /* Check vec_extract with a constant element numbering */
  if (f0(a) != 0)
    abort ();
  if (f1(a) != 1)
    abort ();
  if (f2(a) != 2)
    abort ();
  if (f3(a) != 3)
    abort ();
  /* Check that vec_extract works with a constant element higher than
     the number of elements.  */
  if (f4(a) != 0)
    abort ();

  /* Check vec_extract with a non constant element numbering */
  for(i=0;i<10;i++)
    {
      if (g(b, i) != (i&0x7))
        abort ();
    }
  
  /* Check vec_extract with a constant element numbering */
  if (g0(b) != 0)
    abort ();
  if (g1(b) != 1)
    abort ();
  if (g2(b) != 2)
    abort ();
  if (g3(b) != 3)
    abort ();
  if (g4(b) != 4)
    abort ();
  if (g5(b) != 5)
    abort ();
  if (g6(b) != 6)
    abort ();
  if (g7(b) != 7)
    abort ();
  /* Check that vec_extract works with a constant element higher than
     the number of elements.  */
  if (g8(b) != 0)
    abort ();
  
  return 0;
}
Esempio n. 5
0
int main(void)
{
/***************************** Natrual Syntax ********************************/
  Base a;
  Base b;
  Base c;
  Derived aa;

  // test ordinary function
  functor<void( ) > g0(&test0);
  g0();

  functor<double (double)> g1;
  g1 = &test1;
  assert(12.123 == g1(12.123));

  // test member function
  functor<void (int)> g2(&Base::d);
  functor<int (int)> g3(&Base::static_b);
  functor<int (int, int, int, int, int, int, int, int, int)> g4(&Base::d9);
  functor<int (int)> g5(&Base::virtual_c);
  // operator =
  functor<int (int, int)> g6;
  g6 = &Derived::Derived_a2; 

  functor<int (int)> g7(&Derived::virtual_c);
  // copy constructor
  functor<int (int)> g7_2;
  g7_2 = g7;
  functor<int (int)> g7_3(g7);
  // reference 
  functor<int (int)> &g7_4 = g7;
  // pointer 
  functor<int (int)> *g7_5 = &g7;


  g2(&a, 18);
  assert(18 == a.getBase());
  assert(g3(29) == 29);
  assert(g4(&b, 1,2,3,4,5,6,7,8,9) == (1+2+3+4+5+6+7+8+9));
  assert(g5(&c, 5) == 5);
  assert(g6(&aa, 5, 6) == 5+6);
  assert(g7(&aa, 6) == 10+6);
  assert(g7_2(&aa, 6) == 10+6);
  assert(g7_3(&aa, 6) == 10+6);
  assert(g7_4(&aa, 6) == 10+6);
  assert((*g7_5)(&aa, 6) == 10+6);

/************************************* STL *************************************/
  int myints[] = {32,71,12,45,26,80,53,33};
  std::vector<int> myvector1(myints, myints+8);
  std::vector<int> myvector2(myints, myints+8);

  functor<bool (int, int)> functorCmp = &mycmp;

  std::sort(myvector1.begin(), myvector1.end());
  std::sort(myvector2.begin(), myvector2.end(), functorCmp);

  assert(myvector1.size() == myvector2.size());
  for (unsigned int i = 0; i < myvector1.size(); ++i) {
    assert(myvector1[i] == myvector2[i]);
  }

/***************************** Performance Test ********************************/
//  performanceTest (500000000);

  return 0;
}
Esempio n. 6
0
 int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
     const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
Esempio n. 7
0
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	gluLookAt(r*cos(c*du), h, r*sin(c*du), 0, 0, 0, 0, 3, 0); //head position;eye direction(0.0,0.0,0.0),original point;(0.0,1.0,0.0),head above direction¡£
	
	//cylinder a(1, 15, 0, 90, 0, 0, 5, 0); //r,h,xangle yangle zangle, module position(xx yy zz)
	//sphere b(3, 100, 100, 0, 0, 0, 0, 2.5, 0); //r,xangle yangle zangle, module position(xx yy zz)
	//cube c(5, 10, 0, 0, 1, 1, 1); //length xangle yangle zangle, module position(xx yy zz)
	//rectangularpyramid d(4, 0, 0, 0, 0, 2, 0); //length xangle yangle zangle, module position(xx yy zz)
	//triangularpyramid f(2, 0, 0, 0, 8, 8, 8);//length xangle yangle zangle, module position(xx yy zz)						
	//f.draw();
	sphere sp(3, 100, 100, 0, 0, -2, 0, 8, 0);
	cylinder cy(3, 5, 0, 90, 0, -3, 9, -10);
	cube cu(3, 0, 0, 0, 0, 8, 10);
	triangularpyramid tr(2, 0, 0, 0, 0, -6, 8);
	rectangularpyramid rec(2, 0, 0, 0, 0, -6, -8);

	cylinder k1(0.3, 2, 90, 0, 0, 0, 0, 0);
	cylinder k2(0.3, 2, -90, 0, 0, 0, 0, 0);
	cylinder k3(0.3, 2, -45, 0, 0, 0, 0, 0);
	cylinder k4(0.3, 2.5, 45, 0, 0, 0, 0, 0);

	cylinder u1(0.3, 2, 90, 0, 0, 0, 0, 3);
	cylinder u2(0.3, 1.5, -90, 0, 0, 0, 0, 3);
	cylinder u3(0.3, 2, 0, 0, 0, 0, -1.8, 3);
	cylinder u4(0.3, 2, 90, 0, 0, 0, 0, 5);
	cylinder u5(0.3, 1.5, -90, 0, 0, 0, 0, 5);  

	cylinder g1(0.3, 2, -90, 0, 0, 0, -0.5, 6.4);
	cylinder g2(0.3, 1.5, -90, 0, 0, 0, -0.5, 6.4);
	cylinder g3(0.3, 2, 0, 0, 0, 0, -0.3, 6.4);
	cylinder g4(0.3, 2, 0, 0, 0, 0, 1.3, 6.4);
	cylinder g5(0.3, 2, 90, 0, 0, 0, 0, 8.4);
	cylinder g6(0.3, 1.5, -90, 0, 0, 0, 0, 8.4);
	cylinder g7(0.3, 2, 0, 0, 0, 0, -1.8, 6.4);

	cylinder e1(0.3, 1.8, -90, 0, 0, 0, -0.2, 10);
	cylinder e2(0.3, 1.8, 90, 0, 0, 0, -0.2, 10);
	cylinder e3(0.3, 2, 0, 0, 0, 0, -0.3, 10);
	cylinder e4(0.3, 2, 0, 0, 0, 0, 1.3, 10);
	cylinder e5(0.3, 2, 0, 0, 0, 0, -1.8, 10);

	cylinder r1(0.3, 1.8, -90, 0, 0, 0, -0.2, 13.5);
	cylinder r2(0.3, 1.8, 90, 0, 0, 0, -0.2, 13.5);
	cylinder r3(0.3, 2, 0, 0, 0, 0, -0.3, 13.5);
	cylinder r4(0.3, 1.2, 0, 0, 0, 0, 1.3, 13.5);
	cylinder r5(0.3, 1.7, 60, 0, 0, 0, 1.3, 14.5);
	cylinder r6(0.3, 2.5, 45, 0, 0, 0, 0, 13.5);


	cylinder c1(0.3, 2, 90, 0, 0, 0, 0, -15);
	cylinder c2(0.3, 2, -90, 0, 0, 0, 0, -15); 
	cylinder c3(0.3, 3, 0, 0, 0, 0, -1.8, -15);
	cylinder c4(0.3, 3, 0, 0, 0, 0, 1.8, -15);

	cylinder plus1(0.3,3.5, 0, 0, 0, 0, 0, -11);
	cylinder plus2(0.3, 4, 90, 0, 0, 0, 2, -9.2);
	cylinder plus3(0.3, 3.5, 0, 0, 0, 0, 0, -6);
	cylinder plus4(0.3, 4, 90, 0, 0, 0, 2, -4.2);
	cy.draw();
	sp.draw();
	cu.draw();
	tr.draw();
	rec.draw();

	k1.draw();
	k2.draw();
	k3.draw();
	k4.draw();

	u1.draw();
	u2.draw();
	u3.draw();
	u4.draw();
	u5.draw();
	
	g1.draw();
	g2.draw();
	g3.draw();
	g4.draw();
	g5.draw();
	g6.draw();
	g7.draw();

	e1.draw();
	e2.draw();
	e3.draw();
	e4.draw();
	e5.draw();

	r1.draw();
	r2.draw();
	r3.draw();
	r4.draw();
	r5.draw();
	r6.draw();

	c1.draw();
	c2.draw();
	c3.draw();
	c4.draw();
	
	plus1.draw();
	plus2.draw();
	plus3.draw();
	plus4.draw();

	glFlush();
	
}
Esempio n. 8
0
 void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); }