예제 #1
0
int move_west_test(void)
{
  point moved = move(center(), WEST);
  _assert(moved.x == 1);
  _assert(moved.y == 0);
  return 0;
}
예제 #2
0
int move_north_test(void)
{
  point moved = move(center(), NORTH);
  _assert(moved.x == 0);
  _assert(moved.y == 1);
  return 0;
}
예제 #3
0
int move_east_test(void)
{
  point moved = move(center(), EAST);
  _assert(moved.x == -1);
  _assert(moved.y == 0);
  return 0;
}
예제 #4
0
void Packet <PACKET_GRENADE_THROW>::onReceive(const ENetEvent &event)
{
    char characterSet = 0;
    int ownerID = 0, x = 0, y = 0, dir = 0, projectileID = 0, target_x = 0, target_y = 0;
    sscanf((char*)event.packet->data, "%*c %c %d %d %d %d %d %d %d", &characterSet, &ownerID, &x, &y, &dir, &projectileID, &target_x, &target_y);

    _assert(Master::getInstance().isValidCharacterSet(characterSet), "Invalid character set in processPacket_grenadeThrow.");
    _assert(ownerID >= 0, "Character ID is negative in processPacket_grenadeThrow.");
    _assert(projectileID >= 0, "Projectile ID is negative in processPacket_grenadeThrow.");

    //playPositionalSound(grenadeThrowSample, Player[playerCharacterID].x, Player[playerCharacterID].y, x, y);
    // ALLS
    Master::getInstance().Projectile.push_back(ProjectileClass(characterSet,
                                         ownerID,
                                         x, y,
                                         dir/100.f,
                                         projectileID,
                                         PROJECTILE_TYPE_GRENADE));
    Master::getInstance().Projectile.back().grenadeRotation = (rand()%360)*M_PI/180.f;
    Master::getInstance().Projectile.back().grenadeThrowDistance = Master::getInstance().getDistance(x,y,target_x,target_y);
    Master::getInstance().Projectile.back().timeout_grenadeExplode = globalTime+3000.0;

    if(characterSet == CHARACTER_PLAYER && ownerID == playerCharacterID) {
        Master::getInstance().viewOffsetX = -cos(dir/100.f)*(3+rand()%3);
        Master::getInstance().viewOffsetY = -sin(dir/100.f)*(3+rand()%3);
        Master::getInstance().timeout_grenadeThrow = globalTime+3000.0;
    }
}
예제 #5
0
static int test_dup(void)
{
    test_start("dup");

    cleri_grammar_t * grammar;
    cleri_t * k_hi, * dup;

    k_hi = cleri_keyword(ORIG, "hi", false);
    dup = cleri_dup(DUPL, k_hi);
    grammar = cleri_grammar(cleri_sequence(0, 2, k_hi, dup), NULL);

    _assert (k_hi->gid == ORIG);
    _assert (dup->gid == DUPL);
    _assert_is_valid (grammar, "hi hi");
    _assert_is_not_valid (grammar, "hi");
    _assert_parse_str (
        grammar,
        "",
        "error at position 0, expecting: hi",
        &translate);
    _assert_parse_str (
        grammar,
        "hi",
        "error at position 2, expecting: hi(dup)",
        &translate);

    cleri_grammar_free(grammar);

    return test_end();
}
예제 #6
0
int move_northwest_test(void)
{
  point moved = move(center(), NORTH);
  moved = move(moved, WEST);
  _assert(moved.x == 1);
  _assert(moved.y == 1);
  return 0;
}
예제 #7
0
int move_south_test(void)
{
  point moved = move(center(), SOUTH);
  _assert(moved.x == 0);
  _assert(moved.y == -1);

  return 0;
}
int testAppend() {
  LinkedList list;
  linkedListInit(&list, INTEGER);
  linkedListAppend(&list, (mixed)1);
  _assert(linkedListIndexOf(&list, (mixed)1) == 0);
  linkedListAppend(&list, (mixed)2);
  _assert(linkedListIndexOf(&list, (mixed)2) == 1);
  return 0;
}
예제 #9
0
int si_llega_un_header_de_get_a_una_direccion_el_parser_lo_entiende() {
    char* testRequest = "GET / HTTP 1.1"
            "\nContent-type:'application/json'";

    t_HTMLAction action = getHTMLAction(testRequest);

    _assert(string_equals_ignore_case(action.direction, "/index.html"));
    _assert(action.method == HTMLMethod_GET);
    return 0;
}
예제 #10
0
void setTestData( queryList *listpointer )
{
	queryList *tempQueries ;
	int numClauses ;
	
	tempQueries = listpointer ;
	
	while( tempQueries != NULL )
	{
		char testString[BUFFER_SIZE] = { '\0' } ;		
		char valueString[BUFFER_SIZE] = { '\0' } ;

		for( numClauses = 0 ; numClauses <= tempQueries -> oneQuery -> numClauses ; numClauses++ )
		{
			strcpy( valueString, tempQueries -> oneQuery -> myClauses[numClauses].value ) ;
			
			if( strcmp( tempQueries -> oneQuery -> myClauses[numClauses].attribute, "ID" ) == 0 )
			{
				if( ( strstr( valueString, "file:///" ) ) != NULL ) 
				{
					char cwd[BUFFER_SIZE] = { '\0' } ;
					if( getcwd ( cwd , BUFFER_SIZE ) == NULL )
						_debug( __FILE__, __LINE__, 0, "error in getcwd" ) ;
					else
					{		
						char *token, *value ;
						char tempQuery[BUFFER_SIZE] = { '\0' } ;
						
						strcpy( tempQuery, valueString ) ;
						
						token = strtok( tempQuery, ":" ) ;
						_assert( __FILE__, __LINE__, token  ) ;
			
						strcat( testString, token ) ;
						strcat( testString, "://" ) ;
						strcat( testString, cwd ) ;
						
						value = strpbrk( valueString, ":" ) ;
						_assert( __FILE__, __LINE__, value  ) ;
						
						strcat( testString, value + 3 ) ;						
					}
				}
				else
					strcpy( testString, valueString ) ;
				
				free( tempQueries -> oneQuery -> myClauses[numClauses].value ) ;
				tempQueries -> oneQuery -> myClauses[numClauses].value = strdup( testString ) ;	
				testString[0] = '\0' ;
			}
		}
		tempQueries = ( queryList* ) tempQueries -> link ;
	}
}
예제 #11
0
void Packet <PACKET_QUEST_PROGRESS_CHANGE>::onReceive(const ENetEvent &event)
{
    int questIndex = -1, questProgress = -1;
    sscanf((char*)event.packet->data, "%*c %d %d", &questIndex, &questProgress);

    _assert(questIndex >= 0 && questIndex < (int)Master::getInstance().Quest.size(),
            "Quest index out of bounds in processPacket_questProgressChange.");
    _assert(questProgress >= 0 && questProgress <= 100,
            "Incorrect quest progress in processPacket_questProgressChange.");

    Master::getInstance().Quest[questIndex].progress = questProgress;
}
예제 #12
0
BOOL CNdbControls::Create(HINSTANCE hInst, HWND hParent) {

    m_hInstance = hInst ;
    m_hParent		= hParent ;
    m_tb.Create(m_hInstance, m_hParent, ID_TOOLBAR, IDB_TOOLBAR) ;
    m_sb.Create(m_hInstance, m_hParent, ID_STATUSBAR) ;
    m_tv.Create(m_hInstance, m_hParent, IDM_TREEVIEW, ID_TREEVIEW) ;
    _assert(AddView("Computers", ITEM_COMPR_ROOT)) ;
    _assert(AddView("Databases", ITEM_DB_ROOT)) ;

    return TRUE ;
}
예제 #13
0
void MissionLighting::loadCloudMap( const char * file )
{
   cloudMapFile = file;

   print( V_LOW, "Loading cloud map: %s\n", cloudMapFile.c_str() );
   
   cloudMap = GFXBitmap::load( cloudMapFile.c_str() );

   _assert( cloudMap, "Failed to load cloud lightmap file: %s\n", cloudMapFile );

   // check the bitdepth
   if( cloudMap->getBitDepth() != 24 )
      _assert( 0, "Cloud Bitmap must be a 24bit image" );
}
예제 #14
0
파일: Perft.cpp 프로젝트: gekomad/Cinnamon
void Perft::alloc() {
    perftRes.hash = (_ThashPerft **) calloc(perftRes.depth + 1, sizeof(_ThashPerft *));
    _assert(perftRes.hash);
    const u64 k = 1024 * 1024 * mbSize / POW2[perftRes.depth];
    for (int i = 1; i <= perftRes.depth; i++) {
        perftRes.sizeAtDepth[i] = k * POW2[i - 1] / sizeof(_ThashPerft);
        perftRes.hash[i] = (_ThashPerft *) calloc(perftRes.sizeAtDepth[i], sizeof(_ThashPerft));
        _assert(perftRes.hash[i]);
#ifdef DEBUG_MODE
        cout << "alloc hash[" << i << "] " << perftRes.sizeAtDepth[i] * sizeof(_ThashPerft) << endl;
#endif

    }
}
예제 #15
0
파일: Pragmas.c 프로젝트: AlexIljin/oo2c
static Config__Variable OOC_Config_Pragmas__GetValue(OOC_Config_Pragmas__History h, OOC_Config_Pragmas__Variable var, OOC_INT32 charPos) {
  register OOC_INT32 i0,i1,i2,i3,i4,i5,i6;
  OOC_INT32 l;
  OOC_INT32 r;
  OOC_INT32 m;

  i0 = (OOC_INT32)var;
  _assert((i0!=(OOC_INT32)0), 127, 3331);
  i1 = (OOC_INT32)*(OOC_INT32*)((_check_pointer(i0, 3372))+12);
  i1 = _check_pointer(i1, 3382);
  i2 = OOC_ARRAY_LENGTH(i1, 0);
  i1 = *(OOC_INT32*)(i1+(_check_index(0, i2, OOC_UINT8, 3382))*4);
  i2 = charPos;
  i1 = i2<i1;
  if (i1) goto l16;
  l = 0;
  i1 = *(OOC_INT32*)((_check_pointer(i0, 3658))+16);
  r = i1;
  i3 = 1!=i1;
  if (i3) goto l5;
  i1=0;
  goto l15;
l5:
  i3=i1;i1=0;
l6_loop:
  i4 = (i1+i3)>>1;
  m = i4;
  i5 = (OOC_INT32)*(OOC_INT32*)((_check_pointer(i0, 3887))+12);
  i5 = _check_pointer(i5, 3897);
  i6 = OOC_ARRAY_LENGTH(i5, 0);
  i5 = *(OOC_INT32*)(i5+(_check_index(i4, i6, OOC_UINT32, 3897))*4);
  i5 = i5<=i2;
  if (i5) goto l9;
  r = i4;
  i3=i4;
  goto l10;
l9:
  l = i4;
  i1=i4;
l10:
  i4 = (i1+1)!=i3;
  if (i4) goto l6_loop;
l15:
  i0 = (OOC_INT32)*(OOC_INT32*)((_check_pointer(i0, 4004))+8);
  i0 = _check_pointer(i0, 4012);
  i2 = OOC_ARRAY_LENGTH(i0, 0);
  i0 = (OOC_INT32)*(OOC_INT32*)(i0+(_check_index(i1, i2, OOC_UINT32, 4012))*4);
  return (Config__Variable)i0;
  goto l17;
l16:
  i1 = (OOC_INT32)h;
  i2 = (OOC_INT32)*(OOC_INT32*)(_check_pointer(i1, 3588));
  i0 = (OOC_INT32)*(OOC_INT32*)((_check_pointer(i0, 3619))+4);
  i1 = (OOC_INT32)*(OOC_INT32*)(_check_pointer(i1, 3588));
  i0 = (OOC_INT32)OOC_TBCALL(((OOC_INT32)OOC_TBPROC_ADR(((OOC_INT32)OOC_TYPE_TAG((_check_pointer(i2, 3604)))), Config_Section_Options__SectionDesc_GetValue)),Config_Section_Options__SectionDesc_GetValue)((Config_Section_Options__Section)i1, (Object__String)i0);
  return (Config__Variable)i0;
l17:
  _failed_function(3198); return 0;
  ;
}
예제 #16
0
void
ShaderParam::Apply()
{
	switch (type)
	{
	case ShaderParam::Type::Float:
		sVar->SetFloat(fValue[0]);
		break;

	case ShaderParam::Type::Vector:
		vVar->SetFloatVector(fValue);
		break;

	case ShaderParam::Type::Int:
		sVar->SetInt(iValue);
		break;

	case ShaderParam::Type::Texture:
		tVar->SetResource(tValue->m_pTextureView);
		break;

	case ShaderParam::Type::Matrix:
		mVar->SetMatrix((float*)mValue);
		break;

	default:
		_assert(false);//unhandled case!
		break;
	}
}
예제 #17
0
void 
ShaderParam::SetVariable(
	ID3D10EffectVariable* var
)
{
	variable = var;

	switch (type)
	{
	case Type::Float:
	case Type::Int:
		sVar = var->AsScalar();
		break;

	case Type::Vector:
		vVar = var->AsVector();
		break;

	case Type::Texture:
		tVar = var->AsShaderResource();
		break;

	case Type::Matrix:
		mVar = var->AsMatrix();
		break;

	default:
		_assert(false);//unhandled case!
		break;
	}
}
예제 #18
0
void setConfiguartionData( char *theLine, char *newLine, char *cwd, char *searchDir )
{
	char *lineType, *testLine ;
	char fileTestSite[] = "/testDir" ;
	
	_debug( __FILE__, __LINE__, 5, "cwd is %s", cwd ) ;

	lineType = testLine = NULL ;
	
	testLine = strdup( theLine ) ;
	
	lineType = strtok( testLine , "=" ) ;
	_assert( __FILE__, __LINE__, lineType ) ;
	
	if( ( strcmp( "SEARCHDIR", lineType ) == 0 ) )
	{
		sprintf( newLine,"%s%s%s\n", "SEARCHDIR=", cwd, fileTestSite ) ;
		strcat( searchDir, cwd ) ;
		strcat( searchDir, fileTestSite ) ;
	}
	else if( ( strcmp( "MAILBOX", lineType ) == 0 ) )
		sprintf( newLine,"%s%s/%s\n", "MAILBOX=", cwd, "mailBox.dat" ) ;
	else
		strcpy( newLine, theLine ) ;
		
	free( testLine ) ;
}
예제 #19
0
 inline T &operator [] (int index)
 {
     #ifdef CONTAINER_CHECK_BOUNDS
     _assert(index >= 0 && index < m_vector.size(), "Index out of bounds in container [] operator.");
     #endif
     return *m_vector[index];
 }
예제 #20
0
파일: ctap.c 프로젝트: GrayTShirt/ctap
void ctap_cmp_ok(int a, const char *op, int b, const char *file, unsigned long line, const char *fmt, ...)
{
	int k = strcmp(op, "||") == 0 ? (a || b)
	      : strcmp(op, "&&") == 0 ? (a && b)
	      : strcmp(op, "|")  == 0 ? (a |  b)
	      : strcmp(op, "^")  == 0 ? (a ^  b)
	      : strcmp(op, "&")  == 0 ? (a &  b)
	      : strcmp(op, "==") == 0 ? (a == b)
	      : strcmp(op, "!=") == 0 ? (a != b)
	      : strcmp(op, "<")  == 0 ? (a <  b)
	      : strcmp(op, "<=") == 0 ? (a <= b)
	      : strcmp(op, ">")  == 0 ? (a >  b)
	      : strcmp(op, ">=") == 0 ? (a >= b)
	      : strcmp(op, "<<") == 0 ? (a << b)
	      : strcmp(op, ">>") == 0 ? (a >> b)
	      : strcmp(op, "+")  == 0 ? (a +  b)
	      : strcmp(op, "-")  == 0 ? (a -  b)
	      : strcmp(op, "/")  == 0 ? (a /  b)
	      : strcmp(op, "%")  == 0 ? (a %  b)
	      : diag("unknown operator: '%s'", op);

	vmsg(fmt, msg);
	if (!_assert(k, 0, file, line, msg)) {
		diag("   %d %s %d failed", a, op, b);
	}
}
예제 #21
0
 inline T &back()
 {
     #ifdef CONTAINER_CHECK_BOUNDS
     _assert(m_size, "Container is empty in container back.");
     #endif
     return *m_vector.back();
 }
예제 #22
0
TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
	const char *exp, const char *file, int line)
{
	int dx;
	int dy;
	uint x;
	uint y;

	dx = add & MapMaxX();
	if (dx >= (int)MapSizeX() / 2) dx -= MapSizeX();
	dy = (add - dx) / (int)MapSizeX();

	x = TileX(tile) + dx;
	y = TileY(tile) + dy;

	if (x >= MapSizeX() || y >= MapSizeY()) {
		char buf[512];

		snprintf(buf, lengthof(buf), "TILE_ADD(%s) when adding 0x%.4X and 0x%.4X failed",
			exp, tile, add);
#if !defined(_MSC_VER) || defined(WINCE)
		fprintf(stderr, "%s:%d %s\n", file, line, buf);
#else
		_assert(buf, (char*)file, line);
#endif
	}

	assert(TileXY(x, y) == TILE_MASK(tile + add));

	return TileXY(x, y);
}
예제 #23
0
void ScriptEditor::OnButton2Click(wxCommandEvent& event)
{
    _assert(editingScriptIndex >= 0 && editingScriptIndex < (int)Editor::getInstance().Script.size(),
            "Script index out of bounds in OnButton2Click.");
    Editor::getInstance().Script[editingScriptIndex].script = styledTextCtrl->GetText();
    Close();
}
예제 #24
0
void fatal_error(const char * filename, int line, const char * message)
{
    OutputDebugString("### Fatal Error ###");
    OutputDebugString(message);
    sprintf(error_buf, "file: %s\n", filename);
    OutputDebugString(error_buf);
    sprintf(error_buf, "line: %d\n", line);
    OutputDebugString(error_buf);

    if(g_logger != 0)
    {
        g_logger->printf(false, "### Fatal Error ###\n%s\nfile: %s\nline: %d\n",
            message, filename, line);
        g_logger->flush();
    }
    else
        OutputDebugString("(log unavailable)");
    // g_hinstance is zero until global constructors have completed, and is
    // set to zero just before global destructors are executed.
    if(g_hinstance == 0)
        TerminateProcess(GetCurrentProcess(), 1);
    // Call the C runtime library failure handler.
#ifdef __GNUC__
    _assert(message, filename, line);
#endif
}
예제 #25
0
void assert_failed_msg(const char * condition, const char * filename, int line,
    const char * message)
{
    OutputDebugString("### Assertion Failed ###\n");
    OutputDebugString(message);
    OutputDebugString(condition);
    sprintf(error_buf, "file: %s\n", filename);
    OutputDebugString(error_buf);
    sprintf(error_buf, "line: %d\n", line);
    OutputDebugString(error_buf);

    if(g_logger != 0)
    {
        g_logger->printf(false, "### Assertion Failed ###\n%s\n%s\nfile: %s\nline: %d\n",
            message, condition, filename, line);
        g_logger->flush();
    }
    else
        OutputDebugString("(log unavailable)\n");

	TerminateProcess(GetCurrentProcess(), 1);
    // Call the C runtime library failure handler.
#ifdef __GNUC__
    _assert(condition, filename, line);
#endif
}
예제 #26
0
static void traceMarkstack(void **markstack, int counter, const unsigned long * const globalSweepPtr,
		unsigned long localSweep, struct localAlloc *local){
	while(counter>=1){
		Entry *cur=markstack[counter--];
		_assert(cur!=NULL && assert_in_heap(cur));
		traceObj(cur, markstack, &counter, localSweep);
	}
}
예제 #27
0
파일: Library.cpp 프로젝트: bu2/cycript
CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream) {
    CYLocalPool local;
    CYDriver driver(stream);

    cy::parser parser(driver);
    _assert(parser.parse() == 0);
    _assert(driver.errors_.empty());

    CYOptions options;
    CYContext context(options);
    driver.program_->Replace(context);

    std::ostringstream str;
    CYOutput out(str, options);
    out << *driver.program_;
    return $pool.strdup(str.str().c_str());
}
예제 #28
0
파일: ctap.c 프로젝트: GrayTShirt/ctap
void ctap_ne_ptr(const void *x, const void *y, const char *file, unsigned long line, const char *fmt, ...)
{
	vmsg(fmt, msg);
	if (!_assert(x != y, 1, file, line, msg)) {
		ctap_diag(stderr, "         got: %p", x);
		ctap_diag(stderr, "    expected: <anything else>", y);
	}
}
예제 #29
0
파일: ctap.c 프로젝트: GrayTShirt/ctap
void ctap_ne_string(const char *x, const char *y, const char *file, unsigned long line, const char *fmt, ...)
{
	vmsg(fmt, msg);
	if (!_assert(!(x && y && strcmp(x, y) == 0), 1, file, line, msg)) {
		ctap_diag(stderr, "         got: '%s'", x);
		ctap_diag(stderr, "    expected: <anything else>");
	}
}
예제 #30
0
/**
 * @brief Clear the vote count for the given client
 */
static void
client_vote_clear(const char *key, ShutdownClient *client, void *data)
{
    _assert(client != NULL);

    client->ack_shutdown = kShutdownReplyNoRsp;
    client->elapsed = 0.0;
}