test: add basic test of blake3

laumann
Dec 18, 2023, 4:29 AM
TJVXQWAFNFXOLVSEDUP4DUUOA2ISSBS24VCF5NQN5V2MFLAZ3TMQC

Dependencies

  • [2] SMB3M6ES change: rework to make more testable

Change contents

  • file addition: test_blake3.c (----------)
    [2.16]
    #include <stdlib.h>
    #include <stdio.h>
    #include <stdint.h>
    #include <string.h>
    #undef NDEBUG
    #include <assert.h>
    #include "../common.h"
    #include "../blake3.h"
    #include "../types.h"
    static void
    test_b3hash()
    {
    u8 expected[32] = { 0xaf, 0x13, 0x49, 0xb9, 0xf5, 0xf9, 0xa1, 0xa6,
    0xa0, 0x40, 0x4d, 0xea, 0x36, 0xdc, 0xc9, 0x49,
    0x9b, 0xcb, 0x25, 0xc9, 0xad, 0xc1, 0x12, 0xb7,
    0xcc, 0x9a, 0x93, 0xca, 0xe4, 0x1f, 0x32, 0x62 };
    u8 input[1] = { 0 };
    u8 out[32] = { 0 };
    blake3_hash(out, input, 0);
    assert(blake3_cmp(out, expected) == 0);
    }
    int
    main()
    {
    test_b3hash();
    }
  • edit in test/meson.build at line 4
    [2.2768]
    [2.2768]
    'blake3'