Example #1
0
int test_vm_alloc() {
	int i;
	int *baz, *buf = vm_zalloc(tvm, sizeof(int) * 16);
	ASSERT_NOTNULL(buf);
	for (i = 0; i < 16; ++i)
		ASSERT_EQ(int, buf[i], 0);
	vm_free(tvm, buf);

	buf = vm_zalloc(tvm, sizeof(int) * 4096);
	ASSERT_NOTNULL(buf);
	for (i = 0; i < 4096; ++i)
		ASSERT_EQ(int, buf[i], 0);
	vm_free(tvm, buf);

	buf = vm_zalloc(tvm, sizeof(int) * 32);
	for (i = 0; i < 32; ++i)
		ASSERT_EQ(int, buf[i], 0);
	baz = vm_realloc(tvm, buf, sizeof(int) * 4096);
	ASSERT_TRUE(buf == baz);
	for (i = 0; i < 32; ++i)
		ASSERT_EQ(int, baz[i], 0);
	
	vm_free(tvm, vm_zalloc(tvm, 16));

	buf = vm_realloc(tvm, baz, sizeof(int) * 1024 * 4096);
	ASSERT_FALSE(buf == baz);
	return 0;
}
Example #2
0
void GetCurDisplay(HDC& rCompatibleHDC, HBITMAP& rHbitmap)
{
    HDC desktopDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
    ASSERT_NOTNULL(desktopDC);

    int cx = GetDeviceCaps(desktopDC, HORZRES);
    int cy = GetDeviceCaps(desktopDC, VERTRES);

    rCompatibleHDC = CreateCompatibleDC(desktopDC);
    ASSERT_NOTNULL(rCompatibleHDC);

    rHbitmap = CreateCompatibleBitmap(desktopDC, cx, cy);
    ASSERT_NOTNULL(rHbitmap);
    HBITMAP oldbitMap = (HBITMAP)SelectObject(rCompatibleHDC, rHbitmap);

    // 因为在正常得到的图像是颠倒的,所以需要在之前处理成反的
    //int res = BitBlt(rCompatibleHDC, 0, cy, cx, -1*cy, desktopDC, 0, 0, SRCCOPY);
    /*
    StretchBlt也允许水平或垂直翻转图像。如果cxSrc和cxDst标记(转换成设备单位以后)不同,
    那么StretchBlt就建立一个镜像:左右翻转。在STRETCH程序中,通过将xDst参数改为cxClient并将cxDst参数改成-cxClient,
    就可以做到这一点。如果cySrc和cyDst不同,则StretchBlt会上下翻转图像。要在STRETCH程序中测试这一点,
    可将yDst参数改为cyClient并将cyDst参数改成-cyClient。
    */
    int res = StretchBlt(rCompatibleHDC, 0, cy, cx, -1*cy, desktopDC, 0, 0, cx, cy,SRCCOPY);
    //int res = StretchDIBits(rCompatibleHDC, 0, 0, cx, -1*cy, desktopDC, 0, 0, cx, cy,SRCCOPY);

    ASSERT_NOTZERO(res);

    rHbitmap = (HBITMAP)SelectObject(rCompatibleHDC, oldbitMap);

    DeleteDC(desktopDC);
}
void BR::Database::load(std::string filename)
{
  this->filename = filename;
  size_t dir_pos = filename.find_last_of("\\/");
  std::string filename_prefix = dir_pos == std::string::npos ? "" : filename.substr(0, dir_pos + 1);
  std::string book_image_filename;
  std::string book_info_filename;

  TiXmlDocument document(filename.c_str());
  if (!document.LoadFile())
  {
    throw DatabaseException("unable to load file: " + filename);
  }
  //get books
  TiXmlElement * element = document.RootElement()->FirstChildElement("book");
  do
  {
    Book * book = new Book();
    //read XML
    TiXmlElement * child = element->FirstChildElement("isbn");
    ASSERT_NOTNULL(child, "Unknown file stucture. No ISBN Element.");
    book->isbn = child->GetText();
    
    child = child->NextSiblingElement("title");
    ASSERT_NOTNULL(child, "Unknown file stucture. No title element.");
    book->title = child->GetText();
    
    child = child->NextSiblingElement("author");
    ASSERT_NOTNULL(child, "Unknown file stucture. No author element.");
    book->author = child->GetText();
    
    child = child->NextSiblingElement("image_filename");
    ASSERT_NOTNULL(child, "Unknown file stucture. No image filename.");
    book_image_filename = filename_prefix +  child->GetText();
    
    child = child->NextSiblingElement("image_info_filename");
    ASSERT_NOTNULL(child, "Unknown file stucture. No image info filename.");
    book_info_filename = filename_prefix + child->GetText();

    //load structures
    cv::FileStorage fs(book_info_filename, cv::FileStorage::READ);
    cv::read(fs["keypoints"], book->keypoints);
    fs["descriptors"] >> book->descriptors;
    fs.release();

    //load image
    book->image = cv::imread(book_image_filename);
    
    books.push_back(book);
  } while( (element = element->NextSiblingElement("book")) != NULL);
}
Example #4
0
static void test_cwmp_get_parameter_path_node (abts_case *tc, void *data)
{
    cwmp_t * c = (cwmp_t*)data;

    parameter_node_t * param;
    FUNCTION_TRACE();
    param = cwmp_get_parameter_path_node(c->root, "InternetGatewayDevice.");
    ASSERT_NOTNULL(param);
    param = cwmp_get_parameter_path_node(c->root, "InternetGatewayDevice.WANDevice.{i}.WANConnectionNumberOfEntries");
    ASSERT_NOTNULL(param);
    param = cwmp_get_parameter_path_node(c->root, "InternetGatewayDevice.WANDevice.1.WANConnectionNumberOfEntries");
    ASSERT_NULL(param);
    
}
Example #5
0
TEST_P(Int32Compare, UsingLoadParam) {
    auto param = TRTest::to_struct(GetParam());

    char inputTrees[120] = {0};
    std::snprintf(inputTrees, 120,
       "(method return=Int32 args=[Int32, Int32] "
         "(block "
           "(ireturn "
             "(%s "
               "(iload parm=0) "
               "(iload parm=1)))))",
       param.opcode.c_str());
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<int32_t (*)(int32_t, int32_t)>();
    volatile auto exp = param.oracle(param.lhs, param.rhs);
    volatile auto act = entry_point(param.lhs, param.rhs);
    ASSERT_EQ(exp, act);
}
Example #6
0
static void test_getset_parameter_node_value (abts_case *tc, void *data)
{
    cwmp_t * c = (cwmp_t*)data;

    parameter_node_t * param;
    char * name = "InternetGatewayDevice.DeviceInfo.SoftwareVersion";
    char * retval;
    char * value ;
    
    pool_t * pool = pool_create(POOL_DEFAULT_SIZE);
    FUNCTION_TRACE();
    param = cwmp_get_parameter_path_node(c->root, name);
    ASSERT_NOTNULL(param);
    
    value = "V1.3.x";

    cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
    
    retval = cwmp_data_get_parameter_value(c, param, name, pool);
    printf("retval ------------------is %s\n", retval);
    ASSERT_STR_EQ(value, retval);
   
    
    value = "V1.4.x";
    cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
    retval = cwmp_data_get_parameter_value(c, param, name, pool);
    ASSERT_STR_EQ(value, retval);
    
    
    pool_destroy(pool);

}
Example #7
0
TEST_P(DoubleToFloat, UsingConst) {
    auto param = TRTest::to_struct(GetParam());

    char inputTrees[512] = {0};
    std::snprintf(inputTrees, 512,
        "(method return=Float"
        "  (block"
        "    (freturn"
        "      (d2f"
        "        (dconst %f) ) ) ) )",
        param.value);
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<float (*)()>();
    volatile auto exp = param.oracle(param.value);
    volatile auto act = entry_point();
    if (std::isnan(exp)) {
        ASSERT_EQ(std::isnan(exp), std::isnan(act));
    } else {
        ASSERT_EQ(exp, act);
    }
}
Example #8
0
TEST_P(DoubleToFloat, UsingLoadParam) {
    auto param = TRTest::to_struct(GetParam());

    char *inputTrees =
        "(method return=Float args=[Double]"
        "  (block"
        "    (freturn"
        "      (d2f"
        "        (dload parm=0) ) ) ) )";
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<float (*)(double)>();
    volatile auto exp = param.oracle(param.value);
    volatile auto act = entry_point(param.value);
    if (std::isnan(exp)) {
        ASSERT_EQ(std::isnan(exp), std::isnan(act));
    } else {
        ASSERT_EQ(exp, act);
    }
}
Example #9
0
TEST_P(Int8ToInt32, UsingLoadParam) {
    std::string arch = omrsysinfo_get_CPU_architecture();
    SKIP_IF(OMRPORT_ARCH_S390 == arch || OMRPORT_ARCH_S390X == arch, KnownBug)
        << "The Z code generator incorrectly spills sub-integer types arguments (see issue #3525)";

    auto param = TRTest::to_struct(GetParam());

    char *inputTrees =
        "(method return=Int32 args=[Int8]"
        "  (block"
        "    (ireturn"
        "      (b2i"
        "        (bload parm=0) ) ) ) )";
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<int32_t (*)(int8_t)>();
    volatile auto exp = param.oracle(param.value);
    volatile auto act = entry_point(param.value);
    ASSERT_EQ(exp, act);
}
Example #10
0
TEST_P(DoubleCompare, UsingConst) {
    auto param = TRTest::to_struct(GetParam());

    char inputTrees[1024] = {0};
    std::snprintf(inputTrees, 1024,
       "(method return=Int32 "
         "(block "
           "(ireturn "
             "(%s "
               "(dconst %f) "
               "(dconst %f)))))",
       param.opcode.c_str(), param.lhs, param.rhs);
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<int32_t (*)(void)>();
    volatile auto exp = param.oracle(param.lhs, param.rhs);
    volatile auto act = entry_point();
    ASSERT_EQ(exp, act);
}
Example #11
0
		void renderSolid (Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld, bool selected) const
		{
			if (selected) {
				m_renderOrigin.render(renderer, volume, localToWorld);
			}

			ASSERT_NOTNULL(m_entity.getEntityClass().m_state_wire);
			renderer.SetState(m_entity.getEntityClass().m_state_wire, Renderer::eWireframeOnly);
		}
Example #12
0
		void registerModule (const std::string& type, int version, const std::string& name, Module& module)
		{
			ASSERT_NOTNULL(&module);
			if (!m_modules.insert(Modules_::value_type(ModuleKey(ModuleType(type, version), name), &module)).second) {
				g_warning("Module already registered: type='%s' name='%s'\n", type.c_str(), name.c_str());
			} else {
				g_message("Module registered: type='%s' version='%i' name='%s'\n", type.c_str(), version, name.c_str());
			}
		}
Example #13
0
void registerModule( const char* type, int version, const char* name, Module& module ){
	ASSERT_NOTNULL( &module );
	if ( !m_modules.insert( Modules_::value_type( ModuleKey( ModuleType( type, version ), name ), &module ) ).second ) {
		globalErrorStream() << "module already registered: type=" << makeQuoted( type ) << " name=" << makeQuoted( name ) << "\n";
	}
	else
	{
		globalOutputStream() << "Module Registered: type=" << makeQuoted( type ) << " version=" << makeQuoted( version ) << " name=" << makeQuoted( name ) << "\n";
	}
}
bool C2DimensionSourceIndexFile::GenerateType(wstring* wstrColoumnName)
{
	m_wstrResultContent += L"public:\r\n";
	m_wstrResultContent += L"static const void* s_pColounm[";
	m_wstrResultContent += ItoWStatic(m_ColumnCount);
	m_wstrResultContent += L"];\r\n";

	unsigned int curPos = m_wstrMetaRow.find(L"\t", 0) + 1;

	int colIndex = 0;
	while (curPos < m_wstrMetaRow.size())
	{
		wstring wFieldStr = m_wstrMetaRow.substr(curPos, m_wstrMetaRow.find(L"\t", curPos) - curPos);
		int typePos = wFieldStr.find(L":", 0);
		ASSERT_NEQU(typePos, string::npos);
		wstring wstrFieldName = wFieldStr.substr(0, typePos);
		wstring wstrType = wFieldStr.substr(typePos + 1, wFieldStr.size() - (typePos + 1));
		TypeContainer *pTypeContainer = GetTypeContaner((WCHAR*)wstrType.c_str());
		ASSERT_NOTNULL(pTypeContainer);
		m_wstrResultContent += L"\t";

		wstrColoumnName[colIndex] = wstrFieldName;
		m_ConvertFunc[colIndex++] = pTypeContainer->pValueFunc;

		m_wstrResultContent += L"static const ";
		m_wstrResultContent += pTypeContainer->pMemberStr;
		m_wstrResultContent += L" m_";
		m_wstrResultContent += wstrFieldName;
		m_wstrResultContent += L"[";
		m_wstrResultContent += ItoWStatic(m_RowCount);
		m_wstrResultContent += L"];\r\n";
		curPos = m_wstrMetaRow.find(L"\t", curPos) + 1;
	}

	m_wstrResultContent += L"\t const static int m_Size;\r\n";
	m_wstrResultContent += L"\t template<typename T>\r\n";
	m_wstrResultContent += L"\t static bool GetCell(int x, int y, T& res){\r\n";
	m_wstrResultContent += L"if (ISINRANGE(x, 0, ";
	m_wstrResultContent += ItoWStatic(m_RowCount-1);
	m_wstrResultContent += L") && ISINRANGE(y, 0, ";
	m_wstrResultContent += ItoWStatic(m_ColumnCount - 1);
	m_wstrResultContent += L")){\r\n";
	m_wstrResultContent += L"res = ((T*)s_pColounm[y])[x];\r\n";
	m_wstrResultContent += L"return true;";
	m_wstrResultContent += L"}else{\r\n";
	m_wstrResultContent += L"return false; }\r\n";

	m_wstrResultContent += L"}\r\n";
	m_wstrResultContent += L"};\r\n";

	
	return true;
}
Example #15
0
char* GetCaptureScreenDCRGBbits(int& rWidth,int& rHeight, int& rPixelBitSize)
{
    HDC compatibleHDC = NULL;
    HBITMAP compatibleHbitmap = NULL;

    compatibleHDC = NULL;
    compatibleHbitmap = NULL;
    GetCurDisplay(compatibleHDC, compatibleHbitmap);
    ASSERT_NOTNULL(compatibleHDC);
    ASSERT_NOTNULL(compatibleHbitmap);
    BITMAPINFO rBmpinfo = { 0 };
    GetBitmapInfo(rBmpinfo, compatibleHbitmap);
    rWidth = rBmpinfo.bmiHeader.biWidth;
    rHeight = rBmpinfo.bmiHeader.biHeight;
    rPixelBitSize = rBmpinfo.bmiHeader.biBitCount;
    char* lpRGBBits = GetBMPBinaryData(&rBmpinfo, compatibleHbitmap, compatibleHDC);
    ASSERT_NOTNULL(lpRGBBits);
    DeleteDC(compatibleHDC);
    DeleteObject(compatibleHbitmap);
    return lpRGBBits;
}
Example #16
0
static void test_cwmp_session_create_addobject(abts_case *tc, void *data)
{
    cwmp_t * cwmp = (cwmp_t*)data;
    pool_t * pool = pool_create(POOL_DEFAULT_SIZE);
    xmldoc_t *  doc, *newdoc;
    char * message = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
                       xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\" xmlns=\"urn:dslforum-org:cwmp-1-0\"><SOAP-ENV:Header><cwmp:ID soap:mustUnderstand=\"1\">1234</cwmp:ID></SOAP-ENV:Header>  \
                       <SOAP-ENV:Body><cwmp:AddObject><ObjectName>InternetGatewayDevice.WANDevice.</ObjectName><ParameterKey></ParameterKey></cwmp:AddObject></SOAP-ENV:Body></SOAP-ENV:Envelope>"
    ;
   

   printf("create session\n"); 
    cwmp_session_t * session = cwmp_session_create(cwmp);
    pool_create(POOL_DEFAULT_SIZE);
   pool_create(POOL_DEFAULT_SIZE);
  pool_create(POOL_DEFAULT_SIZE);
 pool_create(POOL_DEFAULT_SIZE);
pool_create(POOL_DEFAULT_SIZE);
pool_create(POOL_DEFAULT_SIZE);
pool_create(POOL_DEFAULT_SIZE);
pool_create(POOL_DEFAULT_SIZE);
 printf("open session \n"); 
    cwmp_session_open(session);
  
   

       
    cwmp_uint32_t msglength = strlen(message);
    size_t len;

    char *xmlbuf = pool_palloc(pool, msglength+32);

    len = sprintf(xmlbuf,"<cwmp>");
    strncpy(xmlbuf + len, message, msglength);
    strcpy(xmlbuf + len + msglength, "</cwmp>");
//    strcat(xmlbuf, "</cwmp>");
 //   xmlbuf[len+msglength+7] = '\0';

    printf("agent analyse xml: \n%s", xmlbuf);

    doc = XmlParseBuffer(pool, xmlbuf);
    ASSERT_NOTNULL(doc);
    
    newdoc = cwmp_session_create_addobject_response_message(session, doc, pool);
    
    cwmp_write_doc_to_chunk(newdoc, session->writers,  pool);
    
    cwmp_chunk_print(session->writers);
    
    pool_destroy(pool);

}
Example #17
0
            void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
            {
                PreventDefaultAction();

                Unit* caster = eventInfo.GetActor();
                caster->CastSpell(nullptr, SPELL_PET_GUARD_DOG_HAPPINESS, aurEff);

                Unit* target = eventInfo.GetProcTarget();
                if (!target->CanHaveThreatList())
                    return;
                float addThreat = CalculatePct(ASSERT_NOTNULL(eventInfo.GetSpellInfo())->Effects[EFFECT_0].CalcValue(caster), aurEff->GetAmount());
                target->GetThreatManager().AddThreat(caster, addThreat, GetSpellInfo(), false, true);
            }
Example #18
0
void CGameDialog::Init()
{
  InitGlobalPrefPath();
  LoadPrefs();
  ScanForGames();
  if (mGames.empty())
  {
	  Error("Didn't find any valid game file descriptions, aborting\n");
  }
  else
  {
	  std::list<CGameDescription *>::iterator iGame, iPrevGame;
	  for(iGame=mGames.begin(), iPrevGame = mGames.end(); iGame!=mGames.end(); iPrevGame = iGame, ++iGame)
	  {
		  if(iPrevGame != mGames.end())
			  if(strcmp((*iGame)->getRequiredKeyValue("name"), (*iPrevGame)->getRequiredKeyValue("name")) < 0)
			  {
				  CGameDescription *h = *iGame;
				  *iGame = *iPrevGame;
				  *iPrevGame = h;
			  }
	  }
  }
 
  CGameDescription* currentGameDescription = 0;

  if (!m_bGamePrompt)
  {
    // search by .game name
    std::list<CGameDescription *>::iterator iGame;
    for(iGame=mGames.begin(); iGame!=mGames.end(); ++iGame)
    {
      if ((*iGame)->mGameFile == m_sGameFile)
      {
        currentGameDescription = (*iGame);
        break;
      }
    }
  }
  if (m_bGamePrompt || !currentGameDescription)
  {
    Create();
    DoGameDialog();
    // use m_nComboSelect to identify the game to run as and set the globals
    currentGameDescription = GameDescriptionForComboItem();
    ASSERT_NOTNULL(currentGameDescription);
  }
  g_pGameDescription = currentGameDescription;

  g_pGameDescription->Dump();
}
Example #19
0
void Channel::GetChannelName(std::string& channelName, uint32 channelId, LocaleConstant locale, AreaTableEntry const* zoneEntry)
{
    if (channelId)
    {
        ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
        if (!(channelEntry->Flags & CHANNEL_DBC_FLAG_GLOBAL))
        {
            if (channelEntry->Flags & CHANNEL_DBC_FLAG_CITY_ONLY)
                channelName = Trinity::StringFormat(channelEntry->Name->Str[locale], sObjectMgr->GetTrinityString(LANG_CHANNEL_CITY, locale));
            else
                channelName = Trinity::StringFormat(channelEntry->Name->Str[locale], ASSERT_NOTNULL(zoneEntry)->AreaName->Str[locale]);
        }
        else
            channelName = channelEntry->Name->Str[locale];
    }
}
Example #20
0
EntityClass *Eclass_ForName(const char *name, bool has_brushes)
{
	ASSERT_NOTNULL(name);

  if(string_empty(name))
  {
    return eclass_bad;
  }

  EntityClasses::iterator i = g_entityClasses.find(name);
  if(i != g_entityClasses.end() && string_equal((*i).first, name))
  {
    return (*i).second;
  }

	EntityClass* e = EntityClass_Create_Default(name, has_brushes);
	return Eclass_InsertAlphabetized(e);
}
Example #21
0
bool MapResource_loadFile(const MapFormat& format, scene::Node& root, const char* filename)
{
  globalOutputStream() << "Open file " << filename << " for read...";
  TextFileInputStream file(filename);
  if(!file.failed())
  {
    globalOutputStream() << "success\n";
    ScopeDisableScreenUpdates disableScreenUpdates(path_get_filename_start(filename), "Loading Map");
    ASSERT_NOTNULL(g_entityCreator);
    format.readGraph(root, file, *g_entityCreator);
    return true;
  }
  else
  {
    globalErrorStream() << "failure\n";
    return false;
  }
}
Example #22
0
EMessageBoxReturn Dialog::DoModal()
{
  importData();

  PreModal();

  EMessageBoxReturn ret = modal_dialog_show(m_window, m_modal);
  ASSERT_NOTNULL(m_window);
  if(ret == eIDOK)
  {
    exportData();
  }

  gtk_widget_hide(GTK_WIDGET(m_window));

  PostModal(m_modal.ret);

  return m_modal.ret;
}
Example #23
0
EntityClass* EntityClassDoom3_findOrInsert( const char *name, bool has_brushes ){
	ASSERT_NOTNULL( name );

	if ( string_empty( name ) ) {
		return g_EntityClassDoom3_bad;
	}

	EntityClasses::iterator i = g_EntityClassDoom3_classes.find( name );
	if ( i != g_EntityClassDoom3_classes.end()
	     //&& string_equal((*i).first, name)
		 ) {
		return ( *i ).second;
	}

	EntityClass* e = EntityClass_Create_Default( name, has_brushes );
	EntityClass* inserted = EntityClassDoom3_insertUnique( e );
	ASSERT_MESSAGE( inserted == e, "" );
	return inserted;
}
Example #24
0
TEST_F(IlGenTest, Return3) {
    auto trees = parseString("(block (ireturn (iconst 3)))");

    TR::TypeDictionary types;
    auto Int32 = types.PrimitiveType(TR::Int32);
    TR::IlType* argTypes[] = {Int32};

    auto injector = Tril::TRLangBuilder{trees, &types};
    TR::ResolvedMethod compilee{__FILE__, LINETOSTR(__LINE__), "Return3InIL", sizeof(argTypes)/sizeof(TR::IlType*), argTypes, Int32, 0, &injector};
    TR::IlGeneratorMethodDetails methodDetails{&compilee};
    int32_t rc = 0;
    auto entry_point = compileMethodFromDetails(NULL, methodDetails, warm, rc);

    ASSERT_EQ(0, rc) << "Compilation failed";
    ASSERT_NOTNULL(entry_point) << "Entry point of compiled body cannot be null";

    auto entry = reinterpret_cast<int32_t(*)(void)>(entry_point);
    ASSERT_EQ(3, entry()) << "Compiled body did not return expected value";
}
Example #25
0
EMessageBoxReturn Dialog::DoModal ()
{
	// Import the values from the registry before showing the dialog
	_registryConnector.importValues();

	PreModal();

	EMessageBoxReturn ret = modal_dialog_show(m_window, m_modal);
	ASSERT_NOTNULL(m_window);
	if (ret == eIDOK) {
		_registryConnector.exportValues();
	}

	gtk_widget_hide(GTK_WIDGET(m_window));

	PostModal(m_modal.ret);

	return m_modal.ret;
}
Example #26
0
TEST_P(FloatToInt32, UsingLoadParam) {
    auto param = TRTest::to_struct(GetParam());

    char *inputTrees =
        "(method return=Int32 args=[Float]"
        "  (block"
        "    (ireturn"
        "      (f2i"
        "        (fload parm=0) ) ) ) )";
    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);

    Tril::DefaultCompiler compiler{trees};

    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;

    auto entry_point = compiler.getEntryPoint<int32_t (*)(float)>();
    volatile auto exp = param.oracle(param.value);
    volatile auto act = entry_point(param.value);
    ASSERT_EQ(exp, act);
}
Example #27
0
TEST_F(VectorTest, VDoubleAdd) { 

   auto inputTrees = "(method return= NoType args=[Address,Address,Address]           "
                     "  (block                                                        "
                     "     (vstorei type=VectorDouble offset=0                        "
                     "         (aload parm=0)                                         "
                     "            (vadd                                               "
                     "                 (vloadi type=VectorDouble (aload parm=1))      "
                     "                 (vloadi type=VectorDouble (aload parm=2))))    "
                     "     (return)))                                                 ";

    auto trees = parseString(inputTrees);

    ASSERT_NOTNULL(trees);
    //TODO: Re-enable this test on S390 after issue #1843 is resolved. 
    //
    // This test is currently disabled on Z platforms because not all Z platforms
    // have vector support. Determining whether a specific platform has the support
    // at runtime is currently not possible in tril. So the test is being disabled altogether
    // on Z for now.
#ifndef TR_TARGET_S390
    Tril::DefaultCompiler compiler{trees};
    ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


    auto entry_point = compiler.getEntryPoint<void (*)(double[],double[],double[])>();
    //TODO: What do we query to determine vector width?  
    // -- This test currently assumes 128bit SIMD  

    double output[] =  {0.0, 0.0};
    double inputA[] =  {1.0, 2.0};
    double inputB[] =  {1.0, 2.0};

    entry_point(output,inputA,inputB); 
    EXPECT_DOUBLE_EQ(inputA[0] + inputB[0], output[0]); // Epsilon = 4ULP -- is this necessary? 
    EXPECT_DOUBLE_EQ(inputA[1] + inputB[1], output[1]); // Epsilon = 4ULP -- is this necessary? 
#endif
}
Example #28
0
Map* MapManager::CreateBaseMap(uint32 id)
{
    Map* map = FindBaseMap(id);

    if (!map)
    {
        MapEntry const* entry = sMapStore.AssertEntry(id);
        if (entry->ParentMapID != -1)
        {
            CreateBaseMap(entry->ParentMapID);

            // must have been created by parent map
            map = FindBaseMap(id);
            return ASSERT_NOTNULL(map);
        }

        std::lock_guard<std::mutex> lock(_mapsLock);
        map = CreateBaseMap_i(entry);
    }

    ASSERT(map);
    return map;
}
bool C2DimensionFile::Generate(wstring& wstrMetaRow, int row, int colounm, list<wstring>& contentStrList)
{
	m_ConvertFunc = (ValueFunc*)malloc(colounm * sizeof(ValueFunc));
	m_RowCount = row;
	m_ColumnCount = colounm;

	m_wstrMetaRow = wstrMetaRow;
	m_wstrMetaRow.replace(m_wstrMetaRow.find(L"\r"), 1, L"\t");
	GenerateHeader();

	wstring* wstrColoumnName = new wstring[colounm];
	ASSERT_NOTNULL(wstrColoumnName);

	GenerateType(wstrColoumnName);

	GenerateFill(wstrColoumnName, contentStrList);
	
	delete[] wstrColoumnName;

	OutputDebugStringW(m_wstrResultContent.c_str());

	return true;
}
Example #30
0
static int test_kstr_creation(struct ymd_mach *vm) {
	const struct kstr *kz = kstr_fetch(vm, "abcdef", 6);
	ASSERT_EQ(int, kz->marked, vm->gc.white);
	ASSERT_NOTNULL(kz);
	ASSERT_EQ(int, kz->type, T_KSTR);
	ASSERT_STREQ(kz->land, "abcdef");
	ASSERT_EQ(int, kz->len, 6);

	kz = kstr_fetch(vm, "abcdef", 3);
	ASSERT_EQ(int, kz->marked, vm->gc.white);
	ASSERT_STREQ(kz->land, "abc");
	ASSERT_EQ(int, kz->len, 3);

	kz = kstr_fetch(vm, "abcdef", 0);
	ASSERT_EQ(int, kz->marked, vm->gc.white);
	ASSERT_STREQ(kz->land, "");
	ASSERT_EQ(int, kz->len, 0);

	kz = kstr_fetch(vm, "abcdefgh", -1);
	ASSERT_EQ(int, kz->marked, vm->gc.white);
	ASSERT_STREQ(kz->land, "abcdefgh");
	ASSERT_EQ(int, kz->len, 8);
	return 0;
}