Files
WoW-Hybrid-gateway/tests/engine_original_main_header_test.c
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

28 lines
1.4 KiB
C

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "native/engine_original_main_header.h"
#define CHECK(x) do { if(!(x)){fprintf(stderr,"FAIL line %d\n",__LINE__);exit(1);} }while(0)
int main(void)
{
unsigned char page[4096],*exact;size_t i;
memset(page,0xa5,sizeof(page));
memcpy(page,gw_engine_original_main_header_bytes,1024);
CHECK(gw_engine_original_main_header_matches(page,4096));
CHECK(gw_engine_original_main_header_matches(page,1024));
CHECK(!gw_engine_original_main_header_matches(page,1023));
CHECK(!gw_engine_original_main_header_matches(NULL,4096));
CHECK(!gw_engine_original_main_header_matches(page,0));
for(i=0;i<1024;++i){page[i]^=1;CHECK(!gw_engine_original_main_header_matches(page,sizeof(page)));page[i]^=1;}
for(i=1024;i<sizeof(page);++i)page[i]=(unsigned char)i;
CHECK(gw_engine_original_main_header_matches(page,sizeof(page)));
exact=(unsigned char*)malloc(1024);CHECK(exact!=NULL);
memcpy(exact,gw_engine_original_main_header_bytes,1024);
CHECK(gw_engine_original_main_header_matches(exact,1024));
/* The function consumes exactly0x400 even with a larger supplied byte count. */
CHECK(gw_engine_original_main_header_matches(exact,4096));
free(exact);
puts("PASS exact1024 fingerprint, every-prefix-byte mutation, short/null inputs, suffix ignored, ASan bounded read");
return 0;
}