okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b5de344b7
main
1#include "strata/program/message_boundary.hpp" 2 3#include <cstdio> 4 5int main () { 6using strata::program::message_checkpoint_boundary ; 7constexpr int64_t token = 248045 ; 8 std::vector < int64_t > ids (33100 ,7 ); 9ids [0 ]= ids [12 ]= ids [32800 ]= ids [33000 ]= token ; 10int checks = 0 ; 11auto check = [& ](int64_t resume ,int64_t turn ,int64_t expected ) { 12++ checks ; 13return message_checkpoint_boundary (ids ,resume ,turn ,token )== expected ; 14 }; 15if (!check (0 ,33000 ,32800 )|| !check (22016 ,33000 ,32800 )|| 16 !check (32800 ,33000 ,-1 )|| !check (33000 ,33000 ,-1 )|| 17 !check (-1 ,33000 ,-1 )|| !check (0 ,-1 ,-1 )|| 18 !check (0 ,33100 ,-1 )|| !check (0 ,32999 ,-1 )|| 19 !check (0 ,12 ,-1 )|| !check (0 ,32800 ,-1 ))return 1 ; 20for (int tail : {1 ,63 ,64 ,512 ,1024 ,1025 ,2048 }) { 21 std::vector < int64_t > fixture (8192 + tail + 1 ,9 ); 22fixture [8192 ]= fixture [8192 + tail ]= token ; 23if (message_checkpoint_boundary (fixture ,0 ,8192 + tail ,token )!= 24 (tail <=1024 ?8192 :-1 ))return 1 ; 25++ checks ; 26 } 27if (message_checkpoint_boundary ({},0 ,0 ,token )!= -1 || 28message_checkpoint_boundary (ids ,0 ,33000 ,-1 )!= -1 || 29message_checkpoint_boundary (ids ,0 ,33000 ,token ,8192 ,0 )!= -1 || 30message_checkpoint_boundary (ids ,0 ,33000 ,token ,-1 )!= -1 )return 1 ; 31checks += 4 ; 32 std::printf ("message_boundary_test OK (%d checks)\n" ,checks ); 33}