// SPDX-License-Identifier: GPL-3.0-only #include "modern/content/toto_quote.hpp" #include "modern/content/ui_contract.hpp" #include "formats/executable_layout.hpp" #include #include using namespace bmh;using namespace bmh::modern; namespace { using J=cli::Json;using O=J::Object;using A=J::Array; const J& at(const J& v,const char* key){return v.object()->at(key);} void check(bool yes,const char* why){if(!yes)throw std::runtime_error(why);} J draft(int stake,int count){A rows;for(int c=0;c(std::get(duplicate.value).at("columns").value);rows[1]=rows[0];check(error(quote_toto_draft(g,0,duplicate))=="duplicate_column","duplicate columns accepted"); auto bad=draft(10000,1);std::get(std::get(bad.value).at("stake").value)["currency"]="USD";check(!parse_toto_draft(bad),"wrong currency accepted");bad=draft(10000,1);std::get(std::get(bad.value).at("stake").value)["minor"]="1000000garbage";check(!parse_toto_draft(bad),"partial money parsed");bad=draft(10000,1);std::get(std::get(bad.value).at("stake").value)["minor"]="1000001";check(!parse_toto_draft(bad),"fractional euro accepted"); const auto clear=quote_toto_draft(g,0,draft(0,0));check(*at(clear,"allowed").boolean()&&*at(clear,"clearing").boolean()&&*at(at(clear,"cost"),"minor").string()=="0","withdrawal does not follow existing clear path");check(!parse_toto_draft(draft(0,1)),"zero stake with tips accepted");g.memory.set8(::bmh::layout::CareerSession_DispatchToto_RuntimeField,9);check(error(quote_toto_draft(g,0,draft(10000,1)))=="toto_coupon_requires_eleven_matches","closed programme accepted"); std::cout<<"Toto preview: real rules, fee, duplicate columns, strict money, clear and read purity passed\n";return 0; }catch(const std::exception&e){std::cerr<