TEST(StringSetTest, UnionOfTwoStringSets) { // Tests the Unions of two sets, including all strings. StringSet first, second; first.Add("First string."); first.Add("Second string."); first.Add("Third string."); second.Add("First string."); second.Add("Second string."); StringSet third = first.Union(second); EXPECT_TRUE(third.Contains("First string.")); EXPECT_TRUE(third.Contains("Second string.")); EXPECT_TRUE(third.Contains("Third string.")); EXPECT_EQ(3, third.Count()); }
TEST(StringSetTest, IntersectionOfTwoStrings) { // Tests the intersection of two set, including only strings occuring // in both sets. StringSet first, second; first.Add("First string."); first.Add("Second string."); first.Add("Third string."); second.Add("First string."); second.Add("Second string."); StringSet intersection = first.Intersection(second); EXPECT_TRUE(intersection.Contains("First string.")); EXPECT_TRUE(intersection.Contains("Second string.")); EXPECT_FALSE(intersection.Contains("Third string.")); EXPECT_EQ(2, intersection.Count()); }
// Takes two string sets and returns the intersection set. StringSet StringSet::Intersection(StringSet in_set) { StringSet result; for (int i = 0; i < this->Count(); ++i) if (in_set.Contains(this->GetString(i))) result.Add(this->GetString(i)); return result; }
// Takes two string sets and returns the union set. StringSet StringSet::Union(StringSet in_set) { StringSet result; for (int i = 0; i < this->Count(); ++i) result.Add(this->GetString(i)); for (int i = 0; i < in_set.Count(); ++i) if (!result.Contains(in_set.GetString(i))) result.Add(in_set.GetString(i)); return result; }
// read symbol table void Database::loadSymbols(wxInputStream &file) { wxTextInputStream str(file, wxT(" \t"), wxConvAuto(wxFONTENCODING_UTF8)); int c = 0; while(!file.Eof()) { wxString line = str.ReadLine(); if (line.IsEmpty()) break; std::wistringstream stream(line.c_str().AsWChar()); Symbol *sym = new Symbol; stream >> sym->id; ::readQuote(stream, sym->module); ::readQuote(stream, sym->procname); ::readQuote(stream, sym->sourcefile); stream >> sym->sourceline; sym->isCollapseFunction = osFunctions.Contains(sym->procname.c_str()); sym->isCollapseModule = osModules.Contains(sym->module.c_str()); symbols[sym->id] = sym; } }
TEST(StringSetTest, RemoveString) { // Removes a given string from the set. set.Remove(str); EXPECT_FALSE(set.Contains(str)); }
TEST(StringSetTest, CheckSetContainsString2) { // Tests if the set contains a second given string. EXPECT_FALSE(set.Contains("Something, Something")); }
TEST(StringSetTest, CheckSetContainsString) { // Tests if the set contains a given string. EXPECT_TRUE(set.Contains(str)); }
void SourceView::showFile(std::string path, int proclinenum, const LINEINFOMAP *lineinfomap) { currentfile = path; SetValue("");//clear text SetDefaultStyle(wxTextAttr(*wxBLACK)); if (path == "[hint KiFastSystemCallRet]") { AppendText( " Hint: KiFastSystemCallRet often means the thread was waiting for something else to finish.\n" " \n" " Possible causes might be disk I/O, waiting for an event, or maybe just calling Sleep().\n" ); return; } if (path == "" || path == "[unknown]") { SetValue("[ No source file available for this location. ]"); return; } FILE *file = fopen(path.c_str(),"r"); if(!file) { char *crtSub = "\\crt\\src\\"; char *crt = strstr((char *)path.c_str(),crtSub); if(crt) { for(size_t i=0;i<msDevPaths.size();i++) { std::string newPath(msDevPaths[i]); newPath += crt+strlen(crtSub); path = newPath; file = fopen(path.c_str(),"r"); if(file) break; } } } if(!file) { AppendText(std::string("[ Could not open file '" + path + "'. ]").c_str()); return; } Show(false); std::string displaytext= "{\\rtf1\\ansi\\fdeff0{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;}\\cf1"; int linenum = 1;//1-based counting //int showpos = 0;//index of character to make visible in order to scroll to line where proc is defined. const int MARGIN_WIDTH = 7; char line[1024*10]; bool block=false; char blockType; while(fgets(line,sizeof(line),file)) { char outLine[1024*20]; LINEINFOMAP::const_iterator result = lineinfomap->find(linenum); if(result != lineinfomap->end()) { sprintf(outLine,"{\\b\\cf2 %0.2fs\t}",result->second.count); } else { strcpy(outLine,"\t"); } char *out = outLine+strlen(outLine); char *in = line; while(*in) { if(!block) { if(in[0] == '/' && in[1] == '/') { block = true; blockType = '/'; strcpy(out,"{\\cf3 "); out += strlen(out); } else if(in[0] == '/' && in[1] == '*') { block = true; blockType = '*'; strcpy(out,"{\\cf3 "); out += strlen(out); } else if(in[0] == '"' && ( in[-1] != '\\' || in[-2] == '\\' )) { block = true; blockType = '"'; strcpy(out,"{\\cf3 "); out += strlen(out); } if(!isCToken(in[-1]) && isCToken(in[0])) { char token[1024*10]; char *tokOut = token; while(isCToken(*in)) { *(tokOut++) = *(in++); } *tokOut=0; if(keywords.Contains(token)) { strcpy(out,"{\\cf4 "); out += strlen(out); strcpy(out,token); out += strlen(out); strcpy(out,"}"); out += strlen(out); } else { strcpy(out,token); out += strlen(token); } continue; } } else { if(blockType == '*' && in[-2] == '*' && in[-1] == '/') { block = false; strcpy(out,"}"); out += strlen(out); } else if(blockType == '"' && in[0] == '"' && ( in[-1] != '\\' || in[-2] == '\\' )) { *(out++) = '"'; block = false; strcpy(out,"}"); out += strlen(out); in++; continue; } } switch(in[0]) { case '\n': case '\r': if(block && blockType == '/') { block = false; strcpy(out,"}"); out += strlen(out); } break; case '{': case '}': case '\\': *(out++) = '\\'; *(out++) = in[0]; break; default: *(out++) = in[0]; break; } in++; } *out = 0; strcat(outLine,"\\line\n"); displaytext += outLine ;//form line to display linenum++; } displaytext += "}"; fclose(file); SendMessage((HWND)GetHWND(),EM_EXLIMITTEXT,0,displaytext.size()); SETTEXTEX settextex = { ST_DEFAULT, 1200, }; SendMessage((HWND)GetHWND(),EM_SETTEXTEX,(WPARAM)&settextex,(LPARAM)displaytext.c_str()); wxFont font(8, wxMODERN , wxNORMAL, wxNORMAL); const bool res = SetStyle(0, (long)displaytext.size(), wxTextAttr(wxNullColour, wxNullColour, font)); const int showpos = std::max((int)XYToPosition(0, std::max(proclinenum -7 , 0)), 0); ShowPosition(showpos); Show(true); }
bool IsOsModule(wxString mod) { return osModules.Contains(mod); }
bool IsOsFunction(wxString function) { return osFunctions.Contains(function); }