Files
EscapistsReintroduced/tests/test_content_browser.py
T
jakub 460d9808e5
continuous-integration/drone/push Build is passing
Simplify content controls and add vehicle roles; record Workshop 0.0.144
Discover installed mod vehicles and save independent garage, traffic, patrol and convoy assignments. Retire the superseded RHS 1.9 overrides. Include native menu, crew/driving and publication evidence.
2026-11-06 22:06:38 +01:00

29 lines
1.7 KiB
Python

"""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<string>', 'Array<string>').replace('foreach (','for (').replace('WidgetManager.Translate','Translate')
run(r'''
#include <cassert>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
struct string;
template<class T>struct Array:std::vector<T>{};
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<string>& 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')