"""Search the entire server result set before paging; exercise real filter rules.""" from policy_harness import ROOT, body, run p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ServerItemCatalog.c' s=body(p,'static bool Matches(').replace('array', 'Array').replace('foreach (','for (').replace('WidgetManager.Translate','Translate') run(r''' #include #include #include #include #include struct string; templatestruct Array:std::vector{}; struct string:std::string{using std::string::string;string(std::string x):std::string(x){}bool IsEmpty(){return empty();}void ToLower(){std::transform(begin(),end(),begin(),[](unsigned char c){return std::tolower(c);});}bool Contains(string s){return find(s)!=npos;}void Split(string,Array& out,bool){std::istringstream in(*this);std::string s;while(in>>s)out.push_back(s);}}; string Translate(string s){return s;} ''' + s + r''' int main(){ assert(Matches("First Aid Kit","items/medical/kit.et",true,0,"first kit")); assert(Matches("FIRST AID KIT","items/medical/kit.et",true,1,"medical")); assert(!Matches("First Aid Kit","items/medical/kit.et",true,2,"")); assert(Matches("V2101 Red","cars/V2101_red.et",false,2,"v2101 RED")); assert(!Matches("V2101 Red","cars/V2101_red.et",false,1,"")); assert(!Matches("V2101 Red","cars/V2101_red.et",true,0,"v2101 blue")); assert(Matches("anything","",false,0," ")); int matches=0;for(int i=0;i<5000;i++)if(Matches("First Aid Kit","items/kit.et",i%2,2,"kit"))matches++; assert(matches==2500); } ''') print('PASS: whole-catalog multiword/case-insensitive search, name/path matching, enabled/disabled filters and large result sets')