#include <stdio.h>
#include <string.h>

#include "../src/bio_bdl.h"

int main(int argc, char **argv) {
    const char *path = argc > 1 ? argv[1] : "tests/fixtures/test.bdl";
    int8_t delta[128];
    int8_t loaded[128];
    uint64_t steps = 0;
    for (uint32_t i = 0; i < sizeof(delta); ++i) {
        delta[i] = (int8_t)(i & 7u);
        loaded[i] = 0;
    }
    if (bio_bdl_save(path, delta, sizeof(delta), 42u) != BIO_OK ||
        bio_bdl_load(path, loaded, sizeof(loaded), &steps) != BIO_OK) {
        fprintf(stderr, "bdl save/load failed\n");
        return 1;
    }
    if (steps != 42u || memcmp(delta, loaded, sizeof(delta)) != 0) {
        fprintf(stderr, "bdl roundtrip mismatch\n");
        return 1;
    }
    puts("bio-tests: bdl persistence ok");
    return 0;
}
