883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
77 lines
6.1 KiB
C++
77 lines
6.1 KiB
C++
#include "gateway/group.hpp"
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
namespace {
|
|
void check(bool good){if(!good)throw Error("source group codec fixture assertion");}
|
|
template<class F>void rejects(F f){try{f();}catch(const Error&){return;}throw Error("expected source group rejection");}
|
|
void boundaries(const Bytes& packet){
|
|
for(size_t n=0;n<packet.size();++n)rejects([&]{turtle_group_list(std::span<const uint8_t>(packet).first(n));});
|
|
auto extra=packet;extra.push_back(0);rejects([&]{turtle_group_list(extra);});
|
|
}
|
|
Bytes one_member(unsigned method=3,unsigned threshold=2,uint64_t master=0){
|
|
// Independent Tortoise writer order; the receiver is excluded from rows.
|
|
Bytes out;le(out,0,1);le(out,0,1);le(out,1,4);cstring(out,"Peer");le(out,4513,8);le(out,1,1);le(out,0,1);
|
|
le(out,4509,8);le(out,method,1);le(out,master,8);le(out,threshold,1);le(out,0,1);return out;
|
|
}
|
|
}
|
|
int main(){
|
|
check(turtle_group_list_opcode==0x7D);
|
|
const Bytes solo(24,0);auto clear=turtle_group_list(solo);
|
|
check(clear.explicit_solo && clear.members.empty() && !clear.leader && !clear.loot);
|
|
boundaries(solo);
|
|
// Literal normal group-of-one source golden, no policy/difficulty tail.
|
|
const auto alone=unhex("0000000000009d11000000000000");auto one=turtle_group_list(alone);
|
|
check(alone.size()==14 && !one.explicit_solo && one.type==TurtleGroupType::normal && !one.own_flags && one.members.empty() && one.leader==4509 && !one.loot);
|
|
boundaries(alone);
|
|
auto raid_alone=alone;raid_alone[0]=1;raid_alone[1]=0x87;
|
|
auto raid_one=turtle_group_list(raid_alone);check(!raid_one.explicit_solo && raid_one.type==TurtleGroupType::raid && raid_one.own_flags==0x87 && !raid_one.loot);
|
|
// Literal normal party: type0/own0/count1/Peer\0/rawGUID4513/status1/
|
|
// flags0/leader4509/methodGROUP_LOOT3/master0/thresholdUNCOMMON2/difficulty0.
|
|
const auto party=unhex("0000010000005065657200a11100000000000001009d110000000000000300000000000000000200");
|
|
check(party==one_member());auto group=turtle_group_list(party);
|
|
check(!group.explicit_solo && group.type==TurtleGroupType::normal && group.members.size()==1 && group.members[0].name=="Peer" && group.members[0].guid==4513 && group.members[0].status==1 && !group.members[0].flags && group.leader==4509 && group.loot && group.loot->method==TurtleGroupLootMethod::group && !group.loot->master && group.loot->threshold==2 && !group.loot->difficulty);
|
|
boundaries(party);
|
|
for(unsigned method=0;method<=4;++method){
|
|
auto policy=turtle_group_list(one_member(method,2,method==2?0xf13000123456789aULL:0));
|
|
check(unsigned(policy.loot->method)==method && policy.loot->master==(method==2?0xf13000123456789aULL:0));
|
|
}
|
|
// Missing/zero master remains literal source state, not fabricated owner.
|
|
check(turtle_group_list(one_member(2,2,0)).loot->master==0);
|
|
for(unsigned threshold=0;threshold<=6;++threshold)check(turtle_group_list(one_member(0,threshold)).loot->threshold==threshold);
|
|
for(unsigned threshold:{7u,255u})rejects([&]{turtle_group_list(one_member(0,threshold));});
|
|
for(unsigned method:{5u,255u})rejects([&]{turtle_group_list(one_member(method));});
|
|
rejects([&]{turtle_group_list(one_member(0,2,4509));});
|
|
auto changed=party;changed.back()=1;rejects([&]{turtle_group_list(changed);});
|
|
// All source status bits, including reserved0x20, are retained as a byte.
|
|
for(unsigned status=0;status<=255;++status){auto b=party;b[19]=uint8_t(status);check(turtle_group_list(b).members[0].status==status);}
|
|
for(unsigned flag:{0u,7u,0x80u,0x87u}){auto b=party;b[1]=uint8_t(flag);b[20]=uint8_t(flag);auto value=turtle_group_list(b);check(value.own_flags==flag && value.members[0].flags==flag);}
|
|
for(unsigned flag:{8u,0x10u,0x20u,0x40u,0xffu}){
|
|
changed=party;changed[1]=uint8_t(flag);rejects([&]{turtle_group_list(changed);});
|
|
changed=party;changed[20]=uint8_t(flag);rejects([&]{turtle_group_list(changed);});
|
|
}
|
|
for(unsigned type:{2u,255u}){changed=party;changed[0]=uint8_t(type);rejects([&]{turtle_group_list(changed);});}
|
|
for(unsigned i=0;i<8;++i){changed=solo;changed[i]=1;rejects([&]{turtle_group_list(changed);});}
|
|
changed=party;for(unsigned i=11;i<19;++i)changed[i]=0;rejects([&]{turtle_group_list(changed);});
|
|
changed=party;for(unsigned i=21;i<29;++i)changed[i]=0;rejects([&]{turtle_group_list(changed);});
|
|
// Empty/unterminated/over-bound name strings fail without scanning tails.
|
|
changed=party;changed[6]=0;rejects([&]{turtle_group_list(changed);});
|
|
Bytes unterminated{0,0,1,0,0,0};unterminated.insert(unterminated.end(),49,'a');rejects([&]{turtle_group_list(unterminated);});
|
|
auto names=[](size_t size){Bytes b{0,0,1,0,0,0};cstring(b,std::string(size,'a'));le(b,4513,8);le(b,0,1);le(b,0,1);le(b,4509,8);le(b,0,1);le(b,0,8);le(b,2,1);le(b,0,1);return b;};
|
|
check(turtle_group_list(names(48)).members[0].name.size()==48);rejects([&]{turtle_group_list(names(49));});
|
|
// UTF8 names are copied unchanged; no guessed ASCII-only name policy.
|
|
auto utf=names(2);utf[6]=0xc3;utf[7]=0xa9;check(turtle_group_list(utf).members[0].name=="\xc3\xa9");
|
|
// Count bounds refer to OTHER members: party4, raid39, not5 or40.
|
|
auto roster=[](unsigned count,bool raid,bool duplicate){
|
|
Bytes b;le(b,raid?1:0,1);le(b,0,1);le(b,count,4);
|
|
for(unsigned i=0;i<count;++i){cstring(b,"Peer"+std::to_string(i));le(b,duplicate?1:i+1,8);le(b,i%256,1);le(b,i%8,1);}
|
|
le(b,900,8);if(count){le(b,2,1);le(b,900,8);le(b,6,1);le(b,0,1);}return b;
|
|
};
|
|
check(turtle_group_list(roster(4,false,false)).members.size()==4);
|
|
check(turtle_group_list(roster(39,true,false)).members.size()==39);
|
|
rejects([&]{turtle_group_list(roster(5,false,false));});rejects([&]{turtle_group_list(roster(40,true,false));});
|
|
rejects([&]{turtle_group_list(roster(2,false,true));});
|
|
auto count_overflow=party;for(unsigned i=2;i<6;++i)count_overflow[i]=0xff;rejects([&]{turtle_group_list(count_overflow);});
|
|
rejects([&]{turtle_group_list(Bytes(2327,0));});
|
|
std::cout<<"Source GROUP_LIST exact solo clear, normal zero-peer group, bounded party/raid snapshots, flags and conditional loot policy checked; no native UI/gameplay claim.\n";
|
|
}
|