コード例 #1
0
ファイル: ProcTest.cpp プロジェクト: mibrahim/boomerang
/*==============================================================================
 * FUNCTION:		ProcTest::testName
 * OVERVIEW:		Test setting and reading name, constructor, native address
 *============================================================================*/
void ProcTest::testName () {
	Prog* prog = new Prog();
	BinaryFile *pBF = new BinaryFileStub();
	CPPUNIT_ASSERT(pBF != 0);
	std::string nm("default name");
	BinaryFileFactory bff;
	pBF = bff.Load(HELLO_PENTIUM);
	FrontEnd *pFE = new PentiumFrontEnd(pBF, prog, &bff);
	CPPUNIT_ASSERT(pFE != 0);
	prog->setFrontEnd(pFE);
	CPPUNIT_ASSERT(prog);
	pFE->readLibraryCatalog();				// Since we are not decoding
	m_proc = new UserProc(prog, nm, 20000); // Will print in decimal if error
	std::string actual(m_proc->getName());
	CPPUNIT_ASSERT_EQUAL(std::string("default name"), actual);

	std::string name("printf");
	LibProc lp(prog, name, 30000);
	actual =  lp.getName();
	CPPUNIT_ASSERT_EQUAL(name, actual);

	ADDRESS a = lp.getNativeAddress();
	ADDRESS expected = 30000;
	CPPUNIT_ASSERT_EQUAL(expected, a);
	a = m_proc->getNativeAddress();
	expected = 20000;
	CPPUNIT_ASSERT_EQUAL(expected, a);

	delete prog;
	// delete pFE;		// No! Deleting the prog deletes the pFE already (which deletes the BinaryFileFactory)
}
コード例 #2
0
ファイル: main.cpp プロジェクト: martamius/mushi
static inline bool Copy_To(QString inputfile, const QString outfile)
{
    bool succ;
    QString ultimacartellaaperta = outfile.left(outfile.lastIndexOf("/"))+"/";
    QDir dira(ultimacartellaaperta);
    dira.mkpath(ultimacartellaaperta);
    
    if (inputfile.startsWith(":/")) {
        QResource actual(inputfile);
        /////qDebug() << "rvalid->" << actual.isValid() << "|" << actual.absoluteFilePath();
        QFile fr(actual.absoluteFilePath());
        succ = fr.copy(outfile);
        if (!succ) {
        QMessageBox::warning(0,"Error \"XHTML Editor\" ",QString("Unable to copy \"%1\" ").arg(inputfile)); 
        }
        return succ;
    }
    
    QFile Imaged(inputfile); 
    succ =  Imaged.copy(outfile);
    if (!succ) {
    QMessageBox::warning(0,"Error \"XHTML Editor\" ",QString("Unable to copy \"%1\" ").arg(inputfile)); 
    }
    return succ;
    
}
コード例 #3
0
u32 CDetailPathManager::location_on_path		(const CGameObject *object, float distance, Fvector &result) const
{
	VERIFY						(m_restricted_object);
	result						= object->Position();
	u32							vertex_result = object->ai_location().level_vertex_id();
	if (!actual())
		return					(vertex_result);

	if (path().empty())
		return					(vertex_result);

	if (curr_travel_point_index() >= path().size() - 1)
		return					(vertex_result);

	float						current_distance = 0.f;
	xr_vector<STravelPathPoint>::const_iterator	I = path().begin() + curr_travel_point_index() + 1;
	xr_vector<STravelPathPoint>::const_iterator	E = path().end();
	for ( ; I != E; ++I) {
		float					next = (*(I - 1)).position.distance_to((*I).position);
		if (current_distance + next > distance) {
			result				= (*I).position;
			return				((*I).vertex_id);
		}
	}

	result						= path().back().position;
	return						(path().back().vertex_id);
}
コード例 #4
0
/**
 * @param num_bytes The number of bytes to send, currently, this is also the number of packets to send (we sent one data byte per packet)
 *
 */
void tcp_tahoe_close_send_receive_test(gcstring message) {
    AddressPort to_connect("127.0.0.1", 5002);

    pthread_t t;
    struct var v;
    Timer timer;
    int client;
    int result;

    v.sem_ = new Semaphore();
    v.sem_->init(0);
    v.to_bind_ = new AddressPort("127.0.0.1", 5002);

    //Specify the number of bytes to send here.
    v.expected_string = message;


    if (pthread_create(&(t), NULL, &tcp_tahoe_close_send_receive_thread, &(v)) != 0) {
        FAIL() << "Error creating new thread in IntegrationTest.h";
    }

    v.sem_->wait();

    // Make sure that the thread is in the accept state
    usleep(50000);

    // Create client

    timer.start();
    client = wifu_socket(AF_INET, SOCK_STREAM, TCP_TAHOE);
    result = wifu_connect(client, (const struct sockaddr *) to_connect.get_network_struct_ptr(), sizeof (struct sockaddr_in));
    timer.stop();
    EXPECT_EQ(0, result);

    cout << "Duration (us) to create a socket and connect on localhost via wifu: " << timer.get_duration_microseconds() << endl;

    int size = 1500;
    char buffer[size];
    memset(buffer, 0, size);
    gcstring expected = v.expected_string;
    gcstring all_received = "";

    while (true) {

        int return_value = wifu_recv(client, &buffer, 1, 0);

        if (return_value == 0) {
            break;
        }

        gcstring actual(buffer);
        all_received.append(actual);

    }

    EXPECT_EQ(expected, all_received);
    wifu_close(client);
    //    cout << "IntegrationTest::send_receive_test(), received the following: " << all_received << endl;
    sleep(10);
}
コード例 #5
0
void CMovementManager::move_along_path	(CPHMovementControl *movement_control, Fvector &dest_position, float time_delta)
{
	START_PROFILE("Build Path/Move Along Path")
	VERIFY(movement_control);
	Fvector				motion;
	dest_position		= object().Position();

	float				precision = 0.5f;
	
	
	// Если нет движения по пути
	if (	!enabled() || 
			!actual()  ||
//			path_completed() || 
			detail().path().empty() ||
			detail().completed(dest_position,true) || 
			(detail().curr_travel_point_index() >= detail().path().size() - 1) ||
			fis_zero(old_desirable_speed())
		)
	{
		m_speed			= 0.f;
		

		DBG_PH_MOVE_CONDITIONS( if(ph_dbg_draw_mask.test(phDbgNeverUseAiPhMove)){movement_control->SetPosition(dest_position);movement_control->DisableCharacter();})
		if(movement_control->IsCharacterEnabled()) {
コード例 #6
0
/*==============================================================================
 * FUNCTION:		DfaTest::testMeetPointer
 * OVERVIEW:		Test meeting IntegerTypes with various other types
 *============================================================================*/
void DfaTest::testMeetPointer() {
	IntegerType i32(32, 1);
	IntegerType u32(32, -1);
	PointerType pi32(&i32);
	PointerType pu32(&u32);
	VoidType v;
	
	std::ostringstream ost1;
	ost1 << pu32.getCtype();
	std::string actual(ost1.str());
	std::string expected("unsigned int *");
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	bool ch = false;
	Type* res = pi32.meetWith(&pu32, ch, false);
	CPPUNIT_ASSERT(ch == true);
	std::ostringstream ost2;
	ost2 << res->getCtype();
	actual = ost2.str();
	expected = "/*signed?*/int *";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	ch = false;
	res = pi32.meetWith(&v, ch, false);	
	CPPUNIT_ASSERT(ch == false);

	res = pi32.meetWith(&i32, ch, false);
	std::ostringstream ost3;
	ost3 << res;
	actual = ost3.str();
	expected = "union";
	CPPUNIT_ASSERT_EQUAL(expected, actual);

}
コード例 #7
0
ファイル: commonmisc_test.cpp プロジェクト: WoLf-/NaCl-main
void sd_object::test<2>()
{
    const std::string decoded("random");
    //const std::string encoded("cmFuZG9t\n");
    const std::string streamed("b(6)\"random\"");
    typedef std::vector<U8> buf_t;
    buf_t buf;
    std::copy(
        decoded.begin(),
        decoded.end(),
        std::back_insert_iterator<buf_t>(buf));
    LLSD sd;
    sd = buf;
    std::stringstream str;
    S32 count = LLSDSerialize::toNotation(sd, str);
    ensure_equals("output count", count, 1);
    std::string actual(str.str());
    ensure_equals("formatted binary encoding", actual, streamed);
    sd.clear();
    LLSDSerialize::fromNotation(sd, str, str.str().size());
    std::vector<U8> after;
    after = sd.asBinary();
    ensure_equals("binary decoded size", after.size(), decoded.size());
    ensure("binary decoding", (0 == memcmp(
                                   &after[0],
                                   decoded.c_str(),
                                   decoded.size())));
}
コード例 #8
0
void TimeSigProperties::accept()
      {
      if (zText->text() != timesig->zText() || nText->text() != timesig->nText())
            timesig->setText(zText->text(), nText->text());
//      timesig->setSig(Fraction(zNominal->value(), nNominal->value()));
//      timesig->setActualSig(Fraction(zActual->value(), nActual->value()));
      if (textButton->isChecked())
            timesig->setSubtype(TSIG_NORMAL);
      else if (fourfourButton->isChecked()) {
            timesig->setSubtype(TSIG_FOUR_FOUR);
            qDebug("fourfour\n");
            }
      else if (allaBreveButton->isChecked()) {
            timesig->setSubtype(TSIG_ALLA_BREVE);
            qDebug("alla breve\n");
            }
      // setSig() and setActualSig must be AFTER setSubType()
      // as setSubType() also reset sig
      Fraction actual(zActual->value(), nActual->value());
      Fraction nominal(zActual->value(), nActual->value());
      Fraction stretch = nominal / actual;
      timesig->setSig(actual);
      timesig->setStretch(stretch);
      QDialog::accept();
      }
コード例 #9
0
TEST(SimpleString, CreateSequenceOfZero)
{
	SimpleString expected("");
	SimpleString actual("hello", 0);

	CHECK_EQUAL(expected, actual);
}
コード例 #10
0
TEST(SimpleString, CreateSequence)
{
	SimpleString expected("hellohello");
	SimpleString actual("hello", 2);

	CHECK_EQUAL(expected, actual);
}
コード例 #11
0
/*==============================================================================
 * FUNCTION:		TypeTest::testNotEqual
 * OVERVIEW:		Test type inequality
 *============================================================================*/
void TypeTest::testCompound() {
	BinaryFileFactory bff;
	BinaryFile *pBF = bff.Load(HELLO_WINDOWS);
	FrontEnd *pFE = new PentiumFrontEnd(pBF, new Prog, &bff);
	Boomerang::get()->setLogger(new FileLogger());		// May try to output some messages to LOG
	pFE->readLibraryCatalog();				// Read definitions

	Signature* paintSig = pFE->getLibSignature("BeginPaint");
	// Second argument should be an LPPAINTSTRUCT
	Type* ty = paintSig->getParamType(1);
	const char* p = ty->getCtype();
	std::string expected("LPPAINTSTRUCT");
	std::string actual(p);
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// Get the type pointed to
	ty = ty->asPointer()->getPointsTo();
	p = ty->getCtype();
	expected = "PAINTSTRUCT";
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);


	// Offset 8 should have a RECT
	Type* subTy = ty->asCompound()->getTypeAtOffset(8*8);
	p = subTy->getCtype();
	expected = "RECT";
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// Name at offset C should be bottom
	p = subTy->asCompound()->getNameAtOffset(0x0C*8);
	expected = "bottom";
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// Now figure out the name at offset 8+C
	p = ty->asCompound()->getNameAtOffset((8 + 0x0C)*8);
	expected = "rcPaint";
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// Also at offset 8
	p = ty->asCompound()->getNameAtOffset((8 + 0)*8);
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// Also at offset 8+4
	p = ty->asCompound()->getNameAtOffset((8 + 4)*8);
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	// And at offset 8+8
	p = ty->asCompound()->getNameAtOffset((8 + 8)*8);
	actual = p;
	CPPUNIT_ASSERT_EQUAL(expected, actual);

	delete pFE;
}
コード例 #12
0
	void ExpectOut(float val)
	{
		// Read unswapped.
		MathUtil::IntFloat expected(val), actual(m_dst.Read<float, false>());
		if (!actual.f || actual.f != actual.f)
			EXPECT_EQ(expected.i, actual.i);
		else
			EXPECT_EQ(expected.f, actual.f);
	}
コード例 #13
0
ファイル: tagged_tuple_test.cpp プロジェクト: Danath/fatal
void check_forwarding_ctor(TData &&...data) {
  static_assert(sizeof...(TTags) == sizeof...(TData), "size mismatch");

  tagged_tuple<tagged_type<TTags, typename std::decay<TData>::type>...> actual(
    std::forward<TData>(data)...
  );

  EXPECT_NE(nullptr, std::addressof(actual));
}
コード例 #14
0
ファイル: tuple_test.cpp プロジェクト: Andrew-He/fatal
void check_get(TData &&...data) {
  static_assert(sizeof...(TTags) == sizeof...(TData), "size mismatch");

  auto const tuple = std::make_tuple(data...);
  fatal::tuple<type_pair<TTags, typename std::decay<TData>::type>...> actual(
    std::forward<TData>(data)...
  );

  check_get_helper<TTags...>::check(tuple, actual);
}
コード例 #15
0
ファイル: tuple_test.cpp プロジェクト: Andrew-He/fatal
void check_tuple(TData &&...data) {
  static_assert(sizeof...(TTags) == sizeof...(TData), "size mismatch");

  auto const tuple = std::make_tuple(data...);
  fatal::tuple<type_pair<TTags, typename std::decay<TData>::type>...> actual(
    std::forward<TData>(data)...
  );

  FATAL_EXPECT_EQ(tuple, actual.data());
}
コード例 #16
0
ファイル: UnzipTest.cpp プロジェクト: uboot/CppZip
void UnzipTest::test_getFileContentFromPasswordProtectedZipFile_win64bit_winrar(void)
{
	bool ok = zip->open(passwordProtectedZipFile_win64bit_winrar, "secret");
	CPPUNIT_ASSERT_EQUAL_MESSAGE("open", true, ok);
	std::vector<unsigned char> content = zip->getFileContent(fileInsideZip);

	std::string expected = "this is a string";
	std::string actual(content.begin(), content.end());

	CPPUNIT_ASSERT_EQUAL_MESSAGE("file content", expected, actual);
}
コード例 #17
0
ファイル: RtlTest.cpp プロジェクト: zecke/boomerang
/*==============================================================================
 * FUNCTION:		RtlTest::testIsCompare
 * OVERVIEW:		Test the isCompare function
 *============================================================================*/
void RtlTest::testIsCompare ()
{
  BinaryFileFactory bff;
  BinaryFile *pBF = bff.Load(SWITCH_SPARC);
  CPPUNIT_ASSERT(pBF != 0);
  CPPUNIT_ASSERT(pBF->GetMachine() == MACHINE_SPARC);
  Prog* prog = new Prog;
  FrontEnd *pFE = new SparcFrontEnd(pBF, prog, &bff);
  prog->setFrontEnd(pFE);

  // Decode second instruction: "sub		%i0, 2, %o1"
  int iReg;
  Exp* eOperand = NULL;
  DecodeResult inst = pFE->decodeInstruction(0x10910);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == false);

  // Decode fifth instruction: "cmp		%o1, 5"
  inst = pFE->decodeInstruction(0x1091c);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == true);
  CPPUNIT_ASSERT_EQUAL(9, iReg);
  std::string expected("5");
  std::ostringstream ost1;
  eOperand->print(ost1);
  std::string actual(ost1.str());
  CPPUNIT_ASSERT_EQUAL(expected, actual);

  pBF->UnLoad();
  delete pBF;
  delete pFE;
  pBF = bff.Load(SWITCH_PENT);
  CPPUNIT_ASSERT(pBF != 0);
  CPPUNIT_ASSERT(pBF->GetMachine() == MACHINE_PENTIUM);
  pFE = new PentiumFrontEnd(pBF, prog, &bff);
  prog->setFrontEnd(pFE);

  // Decode fifth instruction: "cmp	$0x5,%eax"
  inst = pFE->decodeInstruction(0x80488fb);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == true);
  CPPUNIT_ASSERT_EQUAL(24, iReg);
  std::ostringstream ost2;
  eOperand->print(ost2);
  actual = ost2.str();
  CPPUNIT_ASSERT_EQUAL(expected, actual);

  // Decode instruction: "add		$0x4,%esp"
  inst = pFE->decodeInstruction(0x804890c);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == false);
  pBF->UnLoad();
  delete pFE;
}
コード例 #18
0
void CALifeMonsterDetailPathManager::follow_path				(const ALife::_TIME_ID &time_delta)
{
    VERIFY							(!completed());
    VERIFY							(!failed());
    VERIFY							(actual());
    VERIFY							(!m_path.empty());
    if (m_path.back() != object().get_object().m_tGraphID) {
        make_inactual();
    }

    if (m_path.size() == 1) {
        VERIFY						(object().get_object().m_tGraphID == m_destination.m_game_vertex_id);
        m_walked_distance			= 0.f;
        object().get_object().m_tNodeID			= m_destination.m_level_vertex_id;
        object().get_object().o_Position			= m_destination.m_position;
#ifdef DEBUG
        object().m_fDistanceFromPoint	= 0.f;
        object().m_fDistanceToPoint		= 0.f;
        object().m_tNextGraphID			= object().get_object().m_tGraphID;
#endif
        return;
    }

    float							last_time_delta = float(time_delta)/1000.f;
    for ( ; m_path.size() > 1;) {
        setup_current_speed			();
        float						update_distance = (last_time_delta/ai().alife().time_manager().normal_time_factor())*speed();

        float						distance_between = ai().game_graph().distance(object().get_object().m_tGraphID,(GameGraph::_GRAPH_ID)m_path[m_path.size() - 2]);
        if (distance_between > (update_distance + m_walked_distance)) {
            m_walked_distance		+= update_distance;
#ifdef DEBUG
            object().m_fDistanceFromPoint	= m_walked_distance;
            object().m_fDistanceToPoint		= distance_between;
            object().m_tNextGraphID			= (GameGraph::_GRAPH_ID)m_path[m_path.size() - 2];
#endif
            return;
        }

        update_distance					+= m_walked_distance;
        update_distance					-= distance_between;

        last_time_delta					= update_distance*ai().alife().time_manager().normal_time_factor()/speed();

        m_walked_distance				= 0.f;
        m_path.pop_back					();
//		Msg									("%6d %s changes graph point from %d to %d",Device.dwTimeGlobal,object().name_replace(),object().m_tGraphID,(GameGraph::_GRAPH_ID)m_path.back());
        object().get_object().alife().graph().change		(&object().get_object(),object().get_object().m_tGraphID,(GameGraph::_GRAPH_ID)m_path.back());
        VERIFY								(m_path.back() == object().get_object().m_tGraphID);

        object().on_location_change			();
        VERIFY								(m_path.back() == object().get_object().m_tGraphID);
    }
}
コード例 #19
0
ファイル: tuple_test.cpp プロジェクト: Andrew-He/fatal
void check_forwarding_ctor_tuple(TData &&...data) {
  static_assert(sizeof...(TTags) == sizeof...(TData), "size mismatch");

  std::tuple<TData...> expected(data...);

  tuple<type_pair<TTags, typename std::decay<TData>::type>...> actual(
    std::make_tuple(std::forward<TData>(data)...)
  );

  FATAL_EXPECT_EQ(expected, actual.data());
}
コード例 #20
0
ファイル: PlayerWidget.cpp プロジェクト: SvOlli/SLART
void PlayerWidget::unload( bool drop )
{
   if( mpFSM->getState() == PlayerFSM::ready )
   {
      QString actual( mpScrollLine->toolTip() );
      mpFSM->changeState( PlayerFSM::searching );
      if( !drop )
      {
         mpControlWidget->addToPlaylist( QStringList( actual ) );
      }
   }
}
コード例 #21
0
ファイル: z19.c プロジェクト: thektulu/lout
void DetachGalley(OBJECT hd)
{ OBJECT prnt, index;
  assert( type(hd) == HEAD && Up(hd) != hd, "DetachGalley: precondition!" );
  debug1(DGA, D, "DetachGalley( %s )", SymName(actual(hd)));
  Parent(prnt, Up(hd));
  assert( Up(prnt) != prnt, "DetachGalley: parent!" );
  New(index, UNATTACHED);
  pinpoint(index) = nilobj;
  MoveLink(Up(hd), index, PARENT);
  Link(NextDown(Up(prnt)), index);
  debug0(DGA, D, "DetachGalley returning.");
} /* end DetachGalley */
コード例 #22
0
ファイル: z09.c プロジェクト: thektulu/lout
OBJECT ParameterCheck(OBJECT x, OBJECT env)
{ OBJECT link, y, res, prnt_env, par, prnt;
  debug2(DCE, DD, "ParameterCheck(%s, %s)", EchoObject(x), EchoObject(env));
  assert( type(x) == CLOSURE, "ParameterCheck given non-CLOSURE!");

  /* case x is a parameter */
  prnt = SearchEnv(env, enclosing(actual(x)));
  if( prnt == nilobj )
  { debug0(DCE, DD, "ParameterCheck returning nilobj (prnt fail)");
    return nilobj;
  }
  prnt_env = GetEnv(prnt);
  for( link = Down(prnt);  link != prnt;  link = NextDown(link) )
  { Child(par, link);
    if( type(par) == PAR && actual(par) == actual(x) )
    {	assert( Down(par) != par, "ParameterCheck: Down(par)!");
	Child(y, Down(par));
	res = is_word(type(y)) ? CopyObject(y, no_fpos) : nilobj;
	debug1(DCE, DD, "  ParameterCheck returning %s", EchoObject(res));
	return res;
    }
  }

  /* case x is a default parameter */
  y = sym_body(actual(x));
  if( y == nilobj )
  { res = nilobj;
  }
  else if( is_word(type(y)) )
  { res = CopyObject(y, &fpos(y));
  }
  else if( type(y) == CLOSURE && is_par(type(actual(y))) )
  { res = ParameterCheck(y, prnt_env);
  }
  else
  { res = nilobj;
  }
  debug1(DCE, DD, "ParameterCheck returning %s", EchoObject(res));
  return res;
} /* end ParameterCheck */
コード例 #23
0
ファイル: z35.c プロジェクト: thektulu/lout
void InitTime(void)
{ time_t raw_time; struct tm *now;
  FULL_CHAR buff[20]; OBJECT par, tmp, sym, env;
  OBJECT tag, second, minute, hour, weekday,
	monthday, yearday, month, year, century, dst;
  debug0(DTK, D, "InitTime()");

  /* define @Moment symbol with its host of named parameters */
  MomentSym = load(KW_MOMENT,         LOCAL, StartSym);
  tag       = load(KW_TAG,            NPAR,  MomentSym);
  second    = load(KW_SECOND,         NPAR,  MomentSym);
  minute    = load(KW_MINUTE,         NPAR,  MomentSym);
  hour      = load(KW_HOUR,           NPAR,  MomentSym);
  monthday  = load(KW_DAY,            NPAR,  MomentSym);
  month     = load(KW_MONTH,          NPAR,  MomentSym);
  year      = load(KW_YEAR,           NPAR,  MomentSym);
  century   = load(KW_CENTURY,        NPAR,  MomentSym);
  weekday   = load(KW_WEEKDAY,        NPAR,  MomentSym);
  yearday   = load(KW_YEARDAY,        NPAR,  MomentSym);
  dst       = load(KW_DAYLIGHTSAVING, NPAR,  MomentSym);

  /* get current time and convert to ASCII */
  if( time(&raw_time) == -1 )
    Error(35, 1, "unable to obtain the current time", WARN, no_fpos);
  now = localtime(&raw_time);
  StringCopy(time_string, AsciiToFull(asctime(now)));
  time_string[StringLength(time_string) - 1] = '\0';

  /* start of current_moment */
  New(current_moment, CLOSURE);
  actual(current_moment) = MomentSym;

  /* attach its many parameters */
  add_par("%s",   KW_NOW,                      tag);
  add_par("%.2d", now->tm_sec,                 second);
  add_par("%.2d", now->tm_min,                 minute);
  add_par("%.2d", now->tm_hour,                hour);
  add_par("%d",   now->tm_mday,                monthday);
  add_par("%d",   now->tm_mon + 1,             month);
  add_par("%.2d", now->tm_year % 100,          year);
  add_par("%d",   (now->tm_year+1900) / 100,   century);
  add_par("%d",   now->tm_wday + 1,            weekday);
  add_par("%d",   now->tm_yday,                yearday);
  add_par("%d",   now->tm_isdst,               dst);

  /* add a null environment */
  New(env, ENV);
  AttachEnv(env, current_moment);
  debug0(DTK, D, "InitTime() returning.");
  debug0(DTK, DD, "current_moment =");
  ifdebug(DTK, DD, DebugObject(current_moment));
} /* end InitTime */
コード例 #24
0
ファイル: dictionary.cpp プロジェクト: shouganai/amf-cpp
TEST(DictionarySerializationTest, MultiByteLength) {
	AmfDictionary d(true, false);
	for(int i = 0; i < 300; ++i)
		d.insert(AmfInteger(i), AmfInteger(i));

	// for simplicity, only test header and total length
	v8 expected { 0x11, 0x84, 0x59, 0x00 };
	v8 actual(d.serialize());
	v8 header(actual.begin(), actual.begin() + 4);

	ASSERT_EQ(2166, actual.size());
	ASSERT_EQ(expected, header);
}
コード例 #25
0
void CRestrictedObject::remove_restrictions	(const shared_str &out_restrictions, const shared_str &in_restrictions)
{
	if (!out_restrictions.size() && !in_restrictions.size())
		return;

	START_PROFILE("Restricted Object/Remove Restrictions");
	
	Level().space_restriction_manager().remove_restrictions	(object().ID(),*out_restrictions,*in_restrictions);
	
	actual						(false);

	STOP_PROFILE;
}
コード例 #26
0
    //---------------------------------------------------------------------
    void
    BackgroundFileSerializer::readSectionHeader( Ogre::DataStreamPtr &stream
                                                ,const String &section_name )
    {
        String actual( readString( stream, section_name.size() ) );
        if( actual != section_name )
        {
            Ogre::LogManager::getSingleton().stream()
                << "Warming: Section didn't start with"
                << " expected String '" << section_name << "'"
                << " actual was '" << actual << "'";
        }

    }
コード例 #27
0
void CRestrictedObject::remove_all_restrictions	()
{
	START_PROFILE("Restricted Object/Remove Restrictions");
	
	remove_all_restrictions	(RestrictionSpace::eRestrictorTypeOut);
	remove_all_restrictions	(RestrictionSpace::eRestrictorTypeIn);

	if (Level().space_restriction_manager().in_restrictions(object().ID()).size() || Level().space_restriction_manager().out_restrictions(object().ID()).size())
		actual			(false);

	Level().space_restriction_manager().restrict(object().ID(),"","");
	
	STOP_PROFILE;
}
コード例 #28
0
ファイル: z22.c プロジェクト: thektulu/lout
void FlushInners(OBJECT inners, OBJECT hd)
{ OBJECT y, z, tmp, dest_index;

  ifdebug(DGF, D,
    OBJECT link;
    fprintf(stderr, "dgf: [ FlushInners(");
    for( link = Down(inners);  link != inners;  link = NextDown(link) )
    {
      Child(y, link);
      fprintf(stderr, " %s", Image(type(y)));
      switch( type(y) )
      {

        case DEAD:
      
	  break;


        case RECEIVING:
        case UNATTACHED:
      
	  if( Down(y) != y )	/* bug fix (was assert before) */
	  { assert( Down(y) != y, "FlushInners: UNATTACHED!");
	    Child(z, Down(y));
	    fprintf(stderr, " %s", SymName(actual(z)));
	  }
	  break;


        case PRECEDES:
      
	  break;


        case GALL_PREC:

	  break;


        default:
      
	  break;
      }
    }
    fprintf(stderr, ")");
    debug0(DGF, D, "");
  )

  /* check for root galley case */
  if( hd != nilobj )
コード例 #29
0
ファイル: AKTestMethod.cpp プロジェクト: if1live/akira
	bool isEquals(const char* a, const char *b, const char *file, int line)
	{
		bool result = false;
		if(a == NULL && b != NULL)
		{
			result = false;
		}
		else if(a != NULL && b == NULL)
		{
			result = false;
		}
		else if(a == NULL && b == NULL)
		{
			result = true;
		}
		else
		{
			//a, b둘가 문자열인 경우
			std::string expected(a);
			std::string actual(b);
			if(expected == actual)
				result = true;
			else
				result = false;
		}

		if(result == true)
		{
			//LOG("[ PASSED ] %s.%s", test, method);
			return true;
		}
		else
		{
			std::string expected;
			std::string actual;
			if(a == NULL)
				expected = "NULL";
			else
				expected = a;

			if(b == NULL)
				actual = "NULL";
			else
				actual = b;

			showFailMsg(expected.c_str(), actual.c_str(), file, line);
			return false;
		}

	}
コード例 #30
0
ファイル: amdgcn_wave_rr1.cpp プロジェクト: jvesely/hcc
unsigned int run_test(const int num, const int tile, const int iter) {

  std::vector<T> input(num);
  int i = 1234;
  std::generate(input.begin(), input.end(), [&]() {
    return i++;
  });
  hc::array_view<T,1> av_input(num, input);

  std::vector<T> actual(num);
  hc::array_view<T,1> av_actual(num, actual);
  hc::parallel_for_each(av_input.get_extent().tile(tile), 
                        [=](hc::tiled_index<1> idx) [[hc]] {
    T v = av_input[idx.global[0]];
    for (int i = 0; i < iter; i++) {
      v = hc::__amdgcn_wave_rr1(v);
    }
    av_actual[idx] = v;
  });
  av_actual.synchronize();
  
  std::vector<T> expected(num);
  auto r = expected.begin();
  for (int j = 0; j < num; j+=WAVE_SIZE) {
    for (int lane = 0; lane < WAVE_SIZE; lane++,r++) {
      *r = input[j + ((lane - iter)%WAVE_SIZE)];
    }
  }
  
  int index = 0;
  r = expected.begin();
  int errors = std::count_if(actual.begin(), actual.end(), [&](int i) {
    T expected = *r;
    r++;

#if DEBUG==2
    if (i!=expected) {
      std::cerr << "test failed(" << typeid(expected).name() <<  ", num=" << num  << ", tile=" << tile << ", iter=" << iter << ", bound_ctrl=" << bound_ctrl << ") ";
      std::cerr << "expected[" << index << "]=" << expected << "  actual[" << index << "]=" << *r << std::endl;
      assert(false);
    }
    index++;
#endif

    return i != expected; 
  });

  return errors;
}