Files
WoW-Hybrid-gateway/tests/warrior_cooldown_modifiers_test.cpp
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

45 lines
3.7 KiB
C++

#include "gateway/warrior_cooldown_modifiers.hpp"
#include <algorithm>
#include <bit>
#include <iostream>
#include <limits>
using namespace gateway;
namespace {
void check(bool value,const char* message){if(!value)throw Error(message);}
Bytes source(uint8_t bit,int32_t value,uint8_t operation=11){Bytes out{bit,operation};le(out,std::bit_cast<uint32_t>(value),4);return out;}
std::optional<LegacyPacket> convert(uint8_t bit,int32_t value,uint8_t cls=1,uint32_t opcode=0x266,uint8_t op=11){return warrior_cooldown::translate_flat(opcode,source(bit,value,op),cls);}
template<class F>void rejects(F action){try{action();}catch(const Error&){return;}throw Error("malformed source accepted");}
}
int main(){try{
auto packet=convert(9,-1500);check(packet.has_value(),"current exact Disarm route missing");
check(packet->opcode==0x690027,"must use original70334normalized opcode, not reference670027");
// Independent byte oracle: count1/op11/count1/f32(-1500)/classbit9.
const Bytes expected{1,0,0,0,11,1,0,0,0,0,0x80,0xbb,0xc4,9};
check(packet->body==expected,"exact14-byte native modifier wire differs");
size_t admitted=0,held=0;
for(uint8_t bit=0;bit<64;++bit){
const auto result=convert(bit,-750);auto row=std::find_if(warrior_cooldown::Routes.begin(),warrior_cooldown::Routes.end(),[&](const auto& r){return r.source_bit==bit;});
if(row==warrior_cooldown::Routes.end()){check(!result,"unproved source bit forwarded");++held;continue;}
++admitted;check(result && result->body.size()==14,"generated admitted route missing");Reader r(result->body);
check(r.le(4)==1 && r.le(1)==11 && r.le(4)==1 && r.f32()==-750 && r.le(1)==row->native_bit,"generated route payload mismatch");r.end();
}
check(admitted==17 && held==47,"current strict route scope changed");
check(convert(34,-500)->body.back()==37 && convert(36,-500)->body.back()==52 && convert(37,-500)->body.back()==45,"source/native bit namespaces conflated");
check(!convert(25,-1500) && !convert(32,-1500),"ShieldSlam missing/collateral class masks must remain held");
check(!convert(13,-1500) && !convert(35,-1500),"unpublished private allocation leaked into runtime");
for(uint8_t cls:{uint8_t(0),uint8_t(6),uint8_t(10),uint8_t(255)})check(!convert(9,-1500,cls),"unsupported class changed");
for(uint8_t operation:{uint8_t(0),uint8_t(10),uint8_t(21),uint8_t(30)})check(!convert(9,-1500,1,0x266,operation),"other semantics forwarded");
check(!convert(9,-1500,1,0x267) && !convert(9,-1500,1,0x1266),"percent/foreign opcode forwarded");
auto zero=convert(9,0);check(zero && zero->body==Bytes({1,0,0,0,11,1,0,0,0,0,0,0,0,9}),"real zero removal dropped");
check(convert(9,-750)->body!=packet->body && convert(9,-1500)->body==packet->body,"absolute replacement changed to delta");
check(convert(9,-1500)->body==packet->body,"duplicate absolute aggregate changed meaning");
check(convert(9,std::numeric_limits<int32_t>::min()).has_value(),"exact signed float value rejected");
check(!convert(9,16777217) && !convert(9,std::numeric_limits<int32_t>::max()),"inexact integer→float silently forwarded");
auto raw=source(9,-1500);
for(size_t size=0;size<raw.size();++size)rejects([&]{warrior_cooldown::translate_flat(0x266,std::span(raw).first(size),1);});
raw.push_back(0);rejects([&]{warrior_cooldown::translate_flat(0x266,raw,1);});
rejects([&]{convert(64,-1500);});rejects([&]{convert(255,-1500);});
std::cout<<"Warrior flat11: current17routes, exact14byte70334packet, all64bits, ownershipclass/heldnamespaces/zero/replacement/precision/truncation PASS\n";
return 0;
}catch(const std::exception& error){std::cerr<<"Warrior cooldown modifier: "<<error.what()<<'\n';return 1;}}