Files
WoW-Hybrid-gateway/tests/quest_poi_request_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

43 lines
2.3 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#include "gateway/quest_poi_request.hpp"
#include "../native/quest_translation.hpp"
#include <algorithm>
#include <bit>
#include <iostream>
#include <limits>
using namespace gateway;
static void check(bool b){if(!b)throw Error("quest POI request fixture");}
template<class F>static void rejects(F f){try{f();}catch(const Error&){return;}throw Error("expected rejected POI request");}
static Bytes request(uint32_t count){
Bytes b;le(b,count,4);
for(unsigned i=0;i<NativeQuestPoiSlots;++i)le(b,i==0?60141:i==1?0:i==2?60141:i==174?0xffffffffu:i,4);
return b;
}
int main(){
auto all=request(175);check(all.size()==704);
auto decoded=native_quest_poi_request(all);
check(decoded.count==175&&decoded.ids[0]==60141&&decoded.ids[1]==0&&decoded.ids[2]==60141&&decoded.ids[174]==-1);
auto empty=request(0);auto none=native_quest_poi_request(empty);
// Count zero does not make the fixed array optional or require it to be zero.
check(none.count==0&&none.ids[0]==60141&&none.ids[174]==-1);
auto partial=request(3);auto first=native_quest_poi_request(partial);
check(first.count==3&&first.ids[0]==60141&&first.ids[1]==0&&first.ids[2]==60141&&first.ids[174]==-1);
for(auto count:{176u,0x7fffffffu,0x80000000u,0xffffffffu})
rejects([&]{(void)native_quest_poi_request(request(count));});
for(size_t n=0;n<all.size();++n)
rejects([&]{(void)native_quest_poi_request(std::span<const uint8_t>(all.data(),n));});
auto extra=all;extra.push_back(0);rejects([&]{(void)native_quest_poi_request(extra);});
NativeQuestTranslation state;NativeQuestTranslation::Bindings bindings;
for(const auto& body:{all,empty,partial}){
auto held=state.client(0x4400de,body,bindings);
check(held.held&&held.packets.empty()&&!held.status_multiple_requested);
state.sent(held);
}
check(state.held==3);
rejects([&]{(void)state.client(0x4400de,extra,bindings);});
rejects([&]{(void)state.client(0x4400de,request(176),bindings);});
// The other auxiliary quest requests keep their prior hold behavior.
check(state.client(0x3e0022,{},bindings).held&&state.client(0x3e0023,{},bindings).held);
std::cout<<"704-byte fixed quest POI query framing and no-response hold passed\n";
}