예제 #1
0
int main () {
  Tree t1(1), t2("u"), t3(5);
  Tree t4(t1,"*",t2);
  Tree t5("-",t3);

  t4(12.0, 0, 0);
  t5.value();

  Tree t6(t1,"/",t3);
  t6(12.12,0,0);

  Tree t7(t1,"+",t5);
  t7.value();
}
예제 #2
0
int main(void)
{
	vector<int> ret;

	TreeNode root(1);
	TreeNode t2(2);
	TreeNode t3(3);
	TreeNode t4(4);
	TreeNode t5(5);
	TreeNode t6(6);
	TreeNode t7(7);
	TreeNode t8(8);
	TreeNode t9(9);
	TreeNode t10(10);

	root.left = &t2;
	root.right = &t3;
	t2.left = &t4;
	t3.left = &t5;
	t3.right = &t6;
	t5.left = &t7;
	t6.left = &t8;
	t6.right = &t9;
	t8.left = &t10;

	Solution s;
	ret = s.preorderTraversal(&root);
	for(auto it = ret.begin(); it != ret.end(); ++it)
	{
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
예제 #3
0
파일: t6-main.c 프로젝트: peach07up/CS398
int main(){
   float* A = (float*) memalign(16, LEN6*sizeof(float));
   float* D = (float*) memalign(16, LEN6*sizeof(float));
      
   for (int i = 0 ; i < LEN6 ; i ++) {
      A[i] = (float)(i)/(float)LEN6;
      D[i] = (float)(i+3)/(float)LEN6;
   }

   unsigned long long start_c, end_c, diff_c;
   start_c = _rdtsc();

   t6(A,D);

   end_c =_rdtsc(); 
   diff_c = end_c - start_c;
   float giga_cycle = diff_c / 1000000000.0;
   
   float ttt = (float)0.;
   #pragma novector
   for (int i = 0 ; i < LEN6 ; i ++) {
      ttt += A[i];
	}
   printf("t6 took\t %.2f and the result is %f\n", giga_cycle, ttt);
}
예제 #4
0
void
test_types()
{
  std::cout << "--- types ---\n";
  Void_type t1;
  std::cout << t1 << '\n'; // void

  Boolean_type t2;
  std::cout << t2 << '\n'; // bool

  Integer_type t3;
  std::cout << t3 << '\n'; // int

  Float_type t4;
  std::cout << t4 << '\n'; // double

  Function_type t5({&t2, &t3}, t2);
  std::cout << t5 << '\n'; // (bool, int32) -> bool

  Pointer_type t6(t2);
  std::cout << t6 << '\n'; // bool*;

  Reference_type t7(t5);
  std::cout << t7 << '\n'; // ((bool, int32) -> bool)&;

  Function_type t8({}, t1);
  std::cout << t8 << '\n'; // () -> void

  Sequence_type t9(*new Pointer_type(t8));
  std::cout << t9 << '\n'; // (() -> void)*[]
}
예제 #5
0
int
CC_Client::run_basic_tests (void)
{
  Test_Single_Lock_With_Mode t1 (naming_service_,
                                 CosConcurrencyControl::read);
  Test_Single_Lock_With_Mode t2 (naming_service_,
                                 CosConcurrencyControl::write);
  Test_Single_Lock_With_Mode t3 (naming_service_,
                                 CosConcurrencyControl::upgrade);
  Test_Single_Lock_With_Mode t4 (naming_service_,
                                 CosConcurrencyControl::intention_read);
  Test_Single_Lock_With_Mode t5 (naming_service_,
                                 CosConcurrencyControl::intention_write);
  // This test should be run for several different lock mode, but
  // since we do not support
  Test_Release_Not_Held_Lock t6 (naming_service_,
                                 CosConcurrencyControl::read);
  if (t1.run () == CC_SUCCESS &&
      t2.run () == CC_SUCCESS &&
      t3.run () == CC_SUCCESS &&
      t4.run () == CC_SUCCESS &&
      t5.run () == CC_SUCCESS &&
      t6.run () == CC_SUCCESS )
    return CC_SUCCESS;
  else
    return CC_FAIL;
}
예제 #6
0
파일: time.cpp 프로젝트: jrwilson/ioa
static const char*
op_plus_equal ()
{
  std::cout << __func__ << std::endl;

  ioa::time t1 (1, 500500);
  ioa::time t2 (-2, -300300);

  ioa::time t3 (t1);
  t3 += t1;
  mu_assert (t3.sec () == 3);
  mu_assert (t3.usec () == 1000);

  ioa::time t4 (t1);
  t4 += t2;

  mu_assert (t4.sec () == 0);
  mu_assert (t4.usec () == -799800);

  ioa::time t5 (t2);
  t5 += t1;
  mu_assert (t5.sec () == 0);
  mu_assert (t5.usec () == -799800);

  ioa::time t6 (t2);
  t6 += t2;
  mu_assert (t6.sec () == -4);
  mu_assert (t6.usec () == -600600);

  return 0;
}
예제 #7
0
void tst_QSizeF::scale() {
    QSizeF t1(10.4, 12.8);
    t1.scale(60.6, 60.6, Qt::IgnoreAspectRatio);
    QCOMPARE(t1, QSizeF(60.6, 60.6));

    QSizeF t2(10.4, 12.8);
    t2.scale(43.52, 43.52, Qt::KeepAspectRatio);
    QCOMPARE(t2, QSizeF(35.36, 43.52));

    QSizeF t3(9.6, 12.48);
    t3.scale(31.68, 31.68, Qt::KeepAspectRatioByExpanding);
    QCOMPARE(t3, QSizeF(31.68, 41.184));

    QSizeF t4(12.8, 10.4);
    t4.scale(43.52, 43.52, Qt::KeepAspectRatio);
    QCOMPARE(t4, QSizeF(43.52, 35.36));

    QSizeF t5(12.48, 9.6);
    t5.scale(31.68, 31.68, Qt::KeepAspectRatioByExpanding);
    QCOMPARE(t5, QSizeF(41.184, 31.68));

    QSizeF t6(0.0, 0.0);
    t6.scale(200, 240, Qt::IgnoreAspectRatio);
    QCOMPARE(t6, QSizeF(200, 240));

    QSizeF t7(0.0, 0.0);
    t7.scale(200, 240, Qt::KeepAspectRatio);
    QCOMPARE(t7, QSizeF(200, 240));

    QSizeF t8(0.0, 0.0);
    t8.scale(200, 240, Qt::KeepAspectRatioByExpanding);
    QCOMPARE(t8, QSizeF(200, 240));
}
예제 #8
0
파일: struct.c 프로젝트: 4ker/8cc
void testmain() {
    print("struct");
    t1();
    t2();
    t3();
    t4();
    t5();
    t6();
    t7();
    t8();
    t9();
    t10();
    t11();
    t12();
    t13();
    t14();
    unnamed();
    assign();
    arrow();
    incomplete();
    bitfield_basic();
    bitfield_mix();
    bitfield_union();
    bitfield_unnamed();
    bitfield_initializer();
    test_offsetof();
    flexible_member();
    empty_struct();
}
예제 #9
0
bool replace_test( )
{
  bool rc = true;
  const std::string s1( "Insert me!" );

  std::string t1( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
  t1.replace( 0, std::string::npos, s1, 0, std::string::npos );
  if( t1 != "Insert me!" || INSANE( t1 ) ) FAIL

  std::string t2( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
  t2.replace( 0, 1, s1, 0, std::string::npos );
  if( t2 != "Insert me!BCDEFGHIJKLMNOPQRSTUVWXYZ" || INSANE( t2 ) ) FAIL

  std::string t3( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
  t3.replace( 1, 0, s1, 0, 1 );
  if( t3 != "AIBCDEFGHIJKLMNOPQRSTUVWXYZ" || INSANE( t3 ) ) FAIL

  std::string t4( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
  t4.replace( 26, 0, s1, 0, std::string::npos );
  if( t4 != "ABCDEFGHIJKLMNOPQRSTUVWXYZInsert me!" || INSANE( t4 ) ) FAIL

  std::string t5( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
  t5.replace( 4, 3, s1, 2, 5 );
  if( t5 != "ABCDsert HIJKLMNOPQRSTUVWXYZ" || INSANE( t5 ) ) FAIL

  std::string t6( "Shorty" );
  t6.replace( 1, 2, s1, 0, 2 );
  if( t6 != "SInrty" || INSANE( t6 ) ) FAIL

  // Need to test other replace methods.

  return( rc );
}
예제 #10
0
int main() {
    TreeNode root1(1);
    TreeNode root2(1);
	TreeNode t2(2);
	TreeNode t3(3);
	TreeNode t4(4);
	TreeNode t5(5);
	TreeNode t6(6);
	TreeNode t7(7);
	TreeNode t8(8);
	TreeNode t9(9);
	
	root1.left = &t2;
	root1.right = &t3;
	root2.left = &t2;
	root2.right = &t3;
	t2.left = &t4;
	t2.right = &t5;
	t3.right = &t6;
	t4.left = &t7;
	t4.right = &t8;
	t8.left = &t9;
	
	Solution s;
	std::cout << s.isSameTree(&root1, &root2) << std::endl;
    
	return 0;
}
예제 #11
0
void
test_print()
{
    cout << "test_print" << endl;

    sc_time t1;
    cout << t1 << endl;

    uint64 v = 1230;
    sc_time t2( v, false );
    cout << t2 << endl;

    v *= 10000;
    sc_time t3( v, false );
    cout << t3 << endl;

    v *= 100;
    sc_time t4( v, false );
    cout << t4 << endl;

    v *= 10000;
    sc_time t5( v, false );
    cout << t5 << endl;

    v *= 100;
    sc_time t6( v, false );
    cout << t6 << endl;

    v *= 10000;
    sc_time t7( v, false );
    cout << t7 << endl;
}
예제 #12
0
void testmain(void) {
    print("pointer");
    t1();
    t2();
    t3();
    t4();
    t5();
    t6();
    subtract();
}
예제 #13
0
void tst_QSize::scale()
{
    QSize t1( 10, 12 );
    t1.scale( 60, 60, Qt::IgnoreAspectRatio );
    QCOMPARE( t1, QSize(60, 60) );

    QSize t2( 10, 12 );
    t2.scale( 60, 60, Qt::KeepAspectRatio );
    QCOMPARE( t2, QSize(50, 60) );

    QSize t3( 10, 12 );
    t3.scale( 60, 60, Qt::KeepAspectRatioByExpanding );
    QCOMPARE( t3, QSize(60, 72) );

    QSize t4( 12, 10 );
    t4.scale( 60, 60, Qt::KeepAspectRatio );
    QCOMPARE( t4, QSize(60, 50) );

    QSize t5( 12, 10 );
    t5.scale( 60, 60, Qt::KeepAspectRatioByExpanding );
    QCOMPARE( t5, QSize(72, 60) );

    // test potential int overflow
    QSize t6(88473, 88473);
    t6.scale(141817, 141817, Qt::KeepAspectRatio);
    QCOMPARE(t6, QSize(141817, 141817));

    QSize t7(800, 600);
    t7.scale(400, INT_MAX, Qt::KeepAspectRatio);
    QCOMPARE(t7, QSize(400, 300));

    QSize t8(800, 600);
    t8.scale(INT_MAX, 150, Qt::KeepAspectRatio);
    QCOMPARE(t8, QSize(200, 150));

    QSize t9(600, 800);
    t9.scale(300, INT_MAX, Qt::KeepAspectRatio);
    QCOMPARE(t9, QSize(300, 400));

    QSize t10(600, 800);
    t10.scale(INT_MAX, 200, Qt::KeepAspectRatio);
    QCOMPARE(t10, QSize(150, 200));

    QSize t11(0, 0);
    t11.scale(240, 200, Qt::IgnoreAspectRatio);
    QCOMPARE(t11, QSize(240, 200));

    QSize t12(0, 0);
    t12.scale(240, 200, Qt::KeepAspectRatio);
    QCOMPARE(t12, QSize(240, 200));

    QSize t13(0, 0);
    t13.scale(240, 200, Qt::KeepAspectRatioByExpanding);
    QCOMPARE(t13, QSize(240, 200));
}
예제 #14
0
int main(void)
{
   assert(4 == sizeof(int));

   x += t1();
   x += t2();
   x += t3();
   x += t4();
   x += t5();
   x += t6();

   return x & 255;
}
예제 #15
0
int main(int argc, char *argv[])
{
   int i, t, c, pi;

   char test[64];

   if (argc > 1)
   {
      t = 0;

      for (i=0; i<strlen(argv[1]); i++)
      {
         c = tolower(argv[1][i]);

         if (!strchr(test, c))
         {
            test[t++] = c;
            test[t] = 0;
         }
      }
   }
   else strcat(test, "0123456789");

   pi = pigpio_start(0, 0);

   if (pi < 0)
   {
      fprintf(stderr, "pigpio initialisation failed (%d).\n", pi);
      return 1;
   }

   printf("Connected to pigpio daemon (%d).\n", pi);

   if (strchr(test, '0')) t0(pi);
   if (strchr(test, '1')) t1(pi);
   if (strchr(test, '2')) t2(pi);
   if (strchr(test, '3')) t3(pi);
   if (strchr(test, '4')) t4(pi);
   if (strchr(test, '5')) t5(pi);
   if (strchr(test, '6')) t6(pi);
   if (strchr(test, '7')) t7(pi);
   if (strchr(test, '8')) t8(pi);
   if (strchr(test, '9')) t9(pi);
   if (strchr(test, 'a')) ta(pi);
   if (strchr(test, 'b')) tb(pi);
   if (strchr(test, 'c')) tc(pi);

   pigpio_stop(pi);

   return 0;
}
예제 #16
0
파일: Tree.cpp 프로젝트: blueocci/codes
void testTree(){
	Tree<int> t2(2),t1(1),t3(3),t4(4),t5(5),t6(6);
	t1.appendChildTree(t2);
	t1.appendChildTree(t3);
	t3.appendChildTree(t4);
	t4.appendChildTree(t5);
	t5.appendChildTree(t6);
	cout << "t1's depth is:" << t1.depth() << endl;
	t1.travelDfs();
	//cout << endl << "Hello from Tree.cpp" << endl;
	//TRACE0("Print in Tree.cpp:::TRACE0.\n");
	//TRACE1("t1's depth is:%d.\n",t1.depth());
	int in;
	cin >> in;
}
예제 #17
0
void tst_QTime::isValid()
{
    QTime t1;
    QVERIFY( !t1.isValid() );
    QTime t2(24,0,0,0);
    QVERIFY( !t2.isValid() );
    QTime t3(23,60,0,0);
    QVERIFY( !t3.isValid() );
    QTime t4(23,0,-1,0);
    QVERIFY( !t4.isValid() );
    QTime t5(23,0,60,0);
    QVERIFY( !t5.isValid() );
    QTime t6(23,0,0,1000);
    QVERIFY( !t6.isValid() );
}
예제 #18
0
TEST(TupleTest, Basic)
{
    Tuple1<int> t1(1);
    Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee"));
    Tuple3<int, int, int> t3(1, 2, 3);
    Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a);
    Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a);
    Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a);

    EXPECT_EQ(1, t1.a);
    EXPECT_EQ(1, t2.a);
    EXPECT_EQ(1, t3.a);
    EXPECT_EQ(2, t3.b);
    EXPECT_EQ(3, t3.c);
    EXPECT_EQ(1, t4.a);
    EXPECT_EQ(2, t4.b);
    EXPECT_EQ(3, t4.c);
    EXPECT_EQ(1, t5.a);
    EXPECT_EQ(2, t5.b);
    EXPECT_EQ(3, t5.c);
    EXPECT_EQ(4, t5.d);
    EXPECT_EQ(1, t6.a);
    EXPECT_EQ(2, t6.b);
    EXPECT_EQ(3, t6.c);
    EXPECT_EQ(4, t6.d);
    EXPECT_EQ(5, t6.e);

    EXPECT_EQ(1, t1.a);
    DispatchToFunction(&DoAdd, t4);
    EXPECT_EQ(6, t1.a);

    int res = 0;
    DispatchToFunction(&DoAdd, MakeTuple(9, 8, 7, &res));
    EXPECT_EQ(24, res);

    Addy addy;
    EXPECT_EQ(1, t4.a);
    DispatchToMethod(&addy, &Addy::DoAdd, t5);
    EXPECT_EQ(10, t4.a);

    Addz addz;
    EXPECT_EQ(10, t4.a);
    DispatchToMethod(&addz, &Addz::DoAdd, t6);
    EXPECT_EQ(15, t4.a);
}
예제 #19
0
void TestTuple6()
{
	test_db_config::DbConfig config;
	bool bRet = config.Init();
	assert( bRet == true );
	occiwrapper::ConnectionInfo info( config.GetStrIp(), 1521, config.GetUserName(), config.GetPassword(), config.GetSid() );
	occiwrapper::SessionFactory sf;
	occiwrapper::Session s = sf.Create( info );
	string strErrMsg;

	struct tm objTm;
	objTm.tm_year = 2014 - 1900;
	objTm.tm_mon = 11;
	objTm.tm_mday = 30;
	objTm.tm_hour = 10;
	objTm.tm_min = 43;
	objTm.tm_sec = 0;
	string str = "123";

	s << strCreateTable, now, bRet, strErrMsg;
	s << "truncate table tbl_test_tuple_elements", now, bRet, strErrMsg;
	assert( bRet );

	// test 6 elements
	//tuple< int, float, string, struct tm, struct tm, double > t6 = make_tuple( 1, 1.1, "str1", objTm, objTm, 1.2 );
	tuple< int, float, string, struct tm, struct tm, double > t6( 1, 1.1, "str1", objTm, objTm, 1.2 );
	s << "insert into tbl_test_tuple_elements( t1, t2, t3, t4, t5, t6 ) values ( :1, :2, :3, :4, :5, :6 )", use( t6 ), now, bRet, strErrMsg;
	assert( bRet );

	tuple< int, float, string, struct tm, struct tm, double > t6Out;
	s << "select t1, t2, t3, t4, t5, t6 from tbl_test_tuple_elements", into( t6Out ), now, bRet, strErrMsg;
	assert( bRet );
	assert( get< 0 >( t6Out ) == 1 );
	assert( get< 1 >( t6Out ) == ( float )1.1 );
	assert( get< 2 >( t6Out ) == "str1" );
	assert( get< 3 >( t6Out ).tm_mon == 11 );
	assert( get< 4 >( t6Out ).tm_min == 43 );
	//assert( get< 3 >( t6Out ) == get< 4 >( t6Out ) );
	assert( get< 5 >( t6Out ) == 1.2 );

	s << "drop table tbl_test_tuple_elements", now, bRet, strErrMsg;
	assert( bRet );
}
예제 #20
0
int main(int argc, char *argv[])
{
    int i;
    struct id one;

    progname = argv[0];

    tool_init_log();

    t1();
    t2();
    t3();
    t4();
    t5(); t6();

    report_leaks();
    tool_close_log();
    exit(0);
}
int _tmain(int argc, _TCHAR* argv[])
{
	//captura o tempo inicial da simulação
	tempoInicial = std::chrono::system_clock::now();

	//cria e inicializa contador que sera usado para identificar as placas dos carros
	cntr = 0;

	//cria filas de carros
	Fila f;			//fila de carros a espera de atendimento nas bombas
	Fila fOleo;		//fila de carros na troca de oleo
	
	//cria 3 geradores (de carros)
	std::thread t1(gerador, 1, 2, &f);  //gerador 1, cria carros de 2 em 2 segundos
	std::thread t2(gerador, 2, 5, &f);	//gerador 2, cria carros de 5 em 5 segundos
	std::thread t3(gerador, 3, 7, &f);	//gerador 3, cria carros de 7 em 7 segundos

	//cria 2 bombas para atendimento
	//neste exemplo, as duas bombas "consomem" carros a partir da mesma fila
	//elas tem todas o mesmo tempo de atendimento; isto pode ser alterado no prototipo...
	//as bombas recebem referencias para as duas filas (a de atendimento e a fila oleo)
	//porque elas removem da fila de atendimento e inserem (possivelmente) na fila oleo...
	std::thread t4(atende, 1, &f, &fOleo);	//bomba 1
	std::thread t5(atende, 2, &f, &fOleo);  //bomba 2

	//cria estação de troca de oleo
	//30% dos carros que saem do atendimento vao para troca de oleo
	//os demais sao destruidos logo apos o atendimento
	std::thread t6(trocaOleo, &fOleo);  //troca de oleo

	t1.join();
	t2.join();
	t3.join();
	t4.join();
	t5.join();
	t6.join();

	std::cout << "encerrando... " << getClock() << std::endl;

	cin.get();

	return 0;
}
예제 #22
0
파일: function.c 프로젝트: davecheney/8cc
void testmain(void) {
    print("function");

    expect(77, t1());
    t2(79);
    t3(1, 2, 3, 4, 5, 6);
    t4();
    t5();
    expect(3, t6());
    expect(12, t7(3, 4));
    t8(23);
    t9();
    expect(7, t10(3, 4.0));
    func_ptr_call();
    func_name();
    empty();
    empty2();
    test_bool();
    test_struct();
}
예제 #23
0
int main(){
	t1();
	t2();
	t3();
	t4();
	t5();
	t6();
	t7();
	t8();
	t9();
	t10();
	t11();
	t12();
	t13();
	t14();
	t15();
	t16();
	t17();
	return 0;
}
int main() {
	TreeNode t1(1), t2(2), t3(3), t4(4), t5(5), t6(6), t7(7), t8(8), t9(9);
	t4.left = &t2;
	t4.right = &t5;

	t2.left = &t1;
	t2.right = &t3;

	t5.right = &t9;

	t9.left = &t7;
	t7.left = &t6;
	t7.right = &t8;
	
	Solution s;
	bool ret = s.isBalanced(&t4);
	
	printf("Return value is %s\n", ret ? "true":"false");

	return 0;
}
예제 #25
0
int main(void){

	printf("Running unit tests...\n");
	initArrays();
	t1();
	t2();
	t3();
	t4();
	t5();
	t6();
	t7();
	t8();
	t9();
	t10();
	t11();
	t12();
	t13();
	t14();

	return 1;
}
예제 #26
0
int main(){
    TreeNode t0(15);
    TreeNode t1(10);
    TreeNode t2(20);
    TreeNode t3(8);
    TreeNode t4(12);
    TreeNode t5(16);
    TreeNode t6(25);
    TreeNode t7(13);
    TreeNode t8(17);
    t0.left = &t1;
    t0.right = &t2;
    t1.left = &t3;
    t1.right = &t4;
    t2.left = &t5;
    t2.right = &t6;
    t4.right = &t7;
    t5.right = &t8;
    cout<<lca(&t0,&t3,&t7)->val<<endl;
    return 0;
}
예제 #27
0
int main(int argc, char *argv[])
{
    qDebug() << argv[0];
    QCoreApplication a(argc, argv);

    try {
        QScopedPointer<Tst_QEjdbDatabase> t1(new Tst_QEjdbDatabase());

        QScopedPointer<Tst_QEjdbCollection> t2 (
                    new Tst_QEjdbCollection("file:test_db")
                    );

        QScopedPointer<Tst_QEjdbPerformance> t3 (
                    new Tst_QEjdbPerformance("file:test_db")
                    );

        QScopedPointer<Tst_QEjdbCollection> t4 (
                    new Tst_QEjdbCollection("socket:qtejdbtest")
                    );

        QScopedPointer<Tst_QEjdbPerformance> t5 (
                    new Tst_QEjdbPerformance("socket:qtejdbtest")
                    );
        QScopedPointer<Tst_QBsonModel> t6 (
                    new Tst_QBsonModel("file:test_db")
                    );


        QTest::qExec(t1.data(), argc, argv);
        QTest::qExec(t2.data(), argc, argv);
        QTest::qExec(t3.data(), argc, argv);
        //QTest::qExec(t4.data(), argc, argv);
        //QTest::qExec(t5.data(), argc, argv);
        QTest::qExec(t6.data(), argc, argv);


    } catch(QEjdbException &ex) {
        qDebug() << ex;
    }
}
예제 #28
0
파일: time.cpp 프로젝트: jrwilson/ioa
static const char*
ctor ()
{
  std::cout << __func__ << std::endl;

  ioa::time t1 (1, 500000);
  mu_assert (t1.sec () == 1);
  mu_assert (t1.usec () == 500000);

  ioa::time t2 (-1, 500000);
  mu_assert (t2.sec () == 0);
  mu_assert (t2.usec () == -500000);

  ioa::time t3 (1, -500000);
  mu_assert (t3.sec () == 0);
  mu_assert (t3.usec () == 500000);

  ioa::time t4 (-1, -500000);
  mu_assert (t4.sec () == -1);
  mu_assert (t4.usec () == -500000);

  ioa::time t5 (1, 5000000);
  mu_assert (t5.sec () == 6);
  mu_assert (t5.usec () == 0);

  ioa::time t6 (-1, 5000000);
  mu_assert (t6.sec () == 4);
  mu_assert (t6.usec () == 0);

  ioa::time t7 (1, -5000000);
  mu_assert (t7.sec () == -4);
  mu_assert (t7.usec () == 0);

  ioa::time t8 (-1, -5000000);
  mu_assert (t8.sec () == -6);
  mu_assert (t8.usec () == 0);

  return 0;
}
예제 #29
0
void Grid::addTriangles(vector_tri *triangles, float (*func)(Vector3f)) {
    for (int i = 0; i < numSteps(0)-1; i++) {
        for (int j = 0; j < numSteps(1)-1; j++) {
            for (int k = 0; k < numSteps(2)-1; k++) {
                int ic = numSteps(1)*numSteps(2);
                int jc = numSteps(2);

                Vector3f *v1 = &vertices[i*ic+j*jc+k];
                Vector3f *v2 = &vertices[i*ic+j*jc+k+1]; 
                Vector3f *v3 = &vertices[(i+1)*ic+j*jc+k+1];
                Vector3f *v4 = &vertices[(i+1)*ic+j*jc+k];
                Vector3f *v5 = &vertices[i*ic+(j+1)*jc+k];
                Vector3f *v6 = &vertices[i*ic+(j+1)*jc+k+1];
                Vector3f *v7 = &vertices[(i+1)*ic+(j+1)*jc+k+1];
                Vector3f *v8 = &vertices[(i+1)*ic+(j+1)*jc+k];

                Tetrahedron t1(v2, v1, v5, v4);
                Tetrahedron t2(v2, v4, v5, v8);
                Tetrahedron t3(v2, v5, v6, v8);
                Tetrahedron t4(v3, v6, v7, v8);
                Tetrahedron t5(v3, v2, v4, v8);
                Tetrahedron t6(v3, v2, v6, v8);

                //Tetrahedron t1(v5, v6, v8, v1);
                //Tetrahedron t2(v7, v6, v3, v8);
                //Tetrahedron t3(v2, v1, v6, v3);
                //Tetrahedron t4(v4, v8, v3, v1);
                //Tetrahedron t5(v1, v3, v6, v8);
                t1.addTriangles(triangles, func);
                t2.addTriangles(triangles, func);
                t3.addTriangles(triangles, func);
                t4.addTriangles(triangles, func);
                t5.addTriangles(triangles, func);
                t6.addTriangles(triangles, func);
            }
        }
    }   
}
예제 #30
0
int main (int argc, char *argv[])
{

	ThreadHello t1(0);
	ThreadHello t2(1);
	ThreadHello t3(2);
	ThreadHello t4(3);
	ThreadHello t5(4);
	ThreadHello t6(5);

	printf("pressione qquer tecla para sair\n");

	t1.start();
	t2.start();
	t3.start();
	t4.start();
	t5.start();
	t6.start();
	getchar();
	t1.stop();
	t2.stop();

return 0;  }