Files
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

44 lines
3.3 KiB
C++

#include "gateway/mirror_timer.hpp"
#include <iostream>
#include <limits>
using namespace gateway;
static void check(bool ok,const char* message){if(!ok)throw Error(message);}
static void rejects(uint32_t opcode,const Bytes& body){try{forever_mirror_timer(opcode,body);}catch(const Error&){return;}throw Error("unsupported mirror timer accepted");}
static Bytes start(uint32_t timer,uint32_t value,uint32_t maximum,int32_t scale,bool paused,uint32_t spell){
Bytes b;le(b,timer,4);le(b,value,4);le(b,maximum,4);le(b,std::bit_cast<uint32_t>(scale),4);le(b,paused,1);le(b,spell,4);return b;
}
int main(){try{
unsigned variants=0;
for(uint32_t timer=0;timer<3;++timer)for(auto value:{0u,1u,45000u,60000u})
for(auto scale:{int32_t(-1),int32_t(10),int32_t(0),std::numeric_limits<int32_t>::min(),std::numeric_limits<int32_t>::max()})
for(bool paused:{false,true})for(uint32_t spell:{0u,5384u}){
auto input=start(timer,value,60000,scale,paused,spell);auto out=forever_mirror_timer(0x1d9,input);Reader r(out.body);
check(out.opcode==0x4701bb && out.body.size()==18,"wrong native start framing");
check(r.le(1)==timer && r.le(4)==value && r.le(4)==60000,"server timer identity/duration changed");
check(r.le(4)==std::bit_cast<uint32_t>(scale) && r.le(4)==spell && r.le(1)==(paused?0x80u:0u),"scale/spell/frozen ordering changed");r.end();
// Repeated full source updates are forwarded exactly, including refill.
check(forever_mirror_timer(0x1d9,input).body==out.body,"source update was suppressed");++variants;
}
for(uint32_t timer=0;timer<3;++timer){
Bytes b;le(b,timer,4);
auto stop=forever_mirror_timer(0x1db,b);check(stop.opcode==0x4701bd && stop.body==Bytes{uint8_t(timer)},"stop changed timer");
for(uint8_t paused:{0,1}){auto pause=b;pause.push_back(paused);auto out=forever_mirror_timer(0x1da,pause);check(out.opcode==0x4701bc && out.body==Bytes({uint8_t(timer),uint8_t(paused?0x80:0)}),"pause/resume changed timer");}
}
auto valid=start(1,45231,60000,-1,true,5384);
check(forever_mirror_timer(0x1d9,valid).body==unhex("01afb0000060ea0000ffffffff0815000080"),"paused/spell golden native bytes differ");
for(uint32_t op:{0x1d9u,0x1dau,0x1dbu}){
auto input=op==0x1d9?valid:op==0x1da?Bytes{1,0,0,0,1}:Bytes{1,0,0,0};
for(size_t n=0;n<input.size();++n){rejects(op,Bytes(input.begin(),input.begin()+n));}
auto tail=input;tail.push_back(0);rejects(op,tail);
for(uint32_t timer:{3u,255u,256u,0xffffffffu}){auto bad=input;for(unsigned i=0;i<4;++i)bad[i]=uint8_t(timer>>(8*i));rejects(op,bad);}
}
rejects(0x1d8,valid);rejects(0x1dc,valid);
for(uint32_t bad:{0x80000000u,0xffffffffu}){
rejects(0x1d9,start(1,bad,bad,-1,false,0));rejects(0x1d9,start(1,1,bad,-1,false,0));rejects(0x1d9,start(1,1,60000,-1,false,bad));
}
rejects(0x1d9,start(1,0,0,-1,false,0));rejects(0x1d9,start(1,60001,60000,-1,false,0));
auto bad=valid;bad[16]=2;rejects(0x1d9,bad);rejects(0x1da,Bytes{1,0,0,0,2});
auto edge=start(2,0x7fffffff,0x7fffffff,-1,false,0x7fffffff);check(forever_mirror_timer(0x1d9,edge).body.size()==18,"signed maximum rejected");
std::cout<<variants<<" complete source timer starts plus stop/pause/refill/lifecycle/bounds PASS; no live breath UI claim.\n";
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}