Skip to content

Commit

Permalink
Add test vectors using 64 bit seeds for the 32 bit functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 11, 2024
1 parent 8ea5ca1 commit fd906b5
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 72 deletions.
89 changes: 53 additions & 36 deletions mulxp1_32_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,63 @@
struct reference_entry
{
std::size_t length;
std::uint32_t seed;
std::uint64_t seed;
std::uint32_t result;
};

reference_entry const ref[] =
{
{ 0, 0x00000000, 0x6F5D607C },
{ 0, 0x9E3779B9, 0x49DAC063 },
{ 17, 0x00000000, 0xA9830593 },
{ 17, 0x9E3779B9, 0xA3ED9324 },
{ 34, 0x00000000, 0x580A9DFB },
{ 34, 0x9E3779B9, 0x79334B61 },
{ 51, 0x00000000, 0xEC81A87C },
{ 51, 0x9E3779B9, 0x089B2005 },
{ 68, 0x00000000, 0x044EB1FA },
{ 68, 0x9E3779B9, 0xA9E373FA },
{ 85, 0x00000000, 0xBD925846 },
{ 85, 0x9E3779B9, 0x9C636C64 },
{ 102, 0x00000000, 0x1D6857EA },
{ 102, 0x9E3779B9, 0x57866FC5 },
{ 119, 0x00000000, 0xB1F4C4A5 },
{ 119, 0x9E3779B9, 0x70C6F1E3 },
{ 136, 0x00000000, 0x2F519887 },
{ 136, 0x9E3779B9, 0x26E25BC8 },
{ 153, 0x00000000, 0x4923B36C },
{ 153, 0x9E3779B9, 0x2E25C187 },
{ 170, 0x00000000, 0xB9FF9CB5 },
{ 170, 0x9E3779B9, 0xC0A36E75 },
{ 187, 0x00000000, 0x9DC48EA3 },
{ 187, 0x9E3779B9, 0x29C12DF6 },
{ 204, 0x00000000, 0x42495C84 },
{ 204, 0x9E3779B9, 0x4A32B5E1 },
{ 221, 0x00000000, 0x1A1E98A3 },
{ 221, 0x9E3779B9, 0xD192AE46 },
{ 238, 0x00000000, 0x2DF87B0B },
{ 238, 0x9E3779B9, 0x8A9D9F97 },
{ 255, 0x00000000, 0xBFB8759B },
{ 255, 0x9E3779B9, 0xEF44B8AF },
{ 272, 0x00000000, 0x3FA97697 },
{ 272, 0x9E3779B9, 0xAB5391D9 },
{ 0, 0x0000000000000000, 0x6F5D607C },
{ 0, 0x000000009E3779B9, 0x49DAC063 },
{ 0, 0x9E3779B97F4A7C15, 0x91524C8F },
{ 17, 0x0000000000000000, 0xA9830593 },
{ 17, 0x000000009E3779B9, 0xA3ED9324 },
{ 17, 0x9E3779B97F4A7C15, 0xE9AA0CB5 },
{ 34, 0x0000000000000000, 0x580A9DFB },
{ 34, 0x000000009E3779B9, 0x79334B61 },
{ 34, 0x9E3779B97F4A7C15, 0xF180A2F1 },
{ 51, 0x0000000000000000, 0xEC81A87C },
{ 51, 0x000000009E3779B9, 0x089B2005 },
{ 51, 0x9E3779B97F4A7C15, 0xA677AE59 },
{ 68, 0x0000000000000000, 0x044EB1FA },
{ 68, 0x000000009E3779B9, 0xA9E373FA },
{ 68, 0x9E3779B97F4A7C15, 0xE3C240A5 },
{ 85, 0x0000000000000000, 0xBD925846 },
{ 85, 0x000000009E3779B9, 0x9C636C64 },
{ 85, 0x9E3779B97F4A7C15, 0x02933DE4 },
{ 102, 0x0000000000000000, 0x1D6857EA },
{ 102, 0x000000009E3779B9, 0x57866FC5 },
{ 102, 0x9E3779B97F4A7C15, 0xD1ADC02C },
{ 119, 0x0000000000000000, 0xB1F4C4A5 },
{ 119, 0x000000009E3779B9, 0x70C6F1E3 },
{ 119, 0x9E3779B97F4A7C15, 0xAF8C7828 },
{ 136, 0x0000000000000000, 0x2F519887 },
{ 136, 0x000000009E3779B9, 0x26E25BC8 },
{ 136, 0x9E3779B97F4A7C15, 0x801ECE05 },
{ 153, 0x0000000000000000, 0x4923B36C },
{ 153, 0x000000009E3779B9, 0x2E25C187 },
{ 153, 0x9E3779B97F4A7C15, 0xFFA4C1AD },
{ 170, 0x0000000000000000, 0xB9FF9CB5 },
{ 170, 0x000000009E3779B9, 0xC0A36E75 },
{ 170, 0x9E3779B97F4A7C15, 0x5C256B00 },
{ 187, 0x0000000000000000, 0x9DC48EA3 },
{ 187, 0x000000009E3779B9, 0x29C12DF6 },
{ 187, 0x9E3779B97F4A7C15, 0xF98121BE },
{ 204, 0x0000000000000000, 0x42495C84 },
{ 204, 0x000000009E3779B9, 0x4A32B5E1 },
{ 204, 0x9E3779B97F4A7C15, 0xFB117D56 },
{ 221, 0x0000000000000000, 0x1A1E98A3 },
{ 221, 0x000000009E3779B9, 0xD192AE46 },
{ 221, 0x9E3779B97F4A7C15, 0x58707551 },
{ 238, 0x0000000000000000, 0x2DF87B0B },
{ 238, 0x000000009E3779B9, 0x8A9D9F97 },
{ 238, 0x9E3779B97F4A7C15, 0xB3647B31 },
{ 255, 0x0000000000000000, 0xBFB8759B },
{ 255, 0x000000009E3779B9, 0xEF44B8AF },
{ 255, 0x9E3779B97F4A7C15, 0x0305D1F0 },
{ 272, 0x0000000000000000, 0x3FA97697 },
{ 272, 0x000000009E3779B9, 0xAB5391D9 },
{ 272, 0x9E3779B97F4A7C15, 0x8248DE41 },
};

int main()
Expand All @@ -68,7 +85,7 @@ int main()

if( r != e.result )
{
std::fprintf( stderr, "Reference value mismatch for length %zu, seed %08" PRIX32 ": was %08" PRIX32 ", expected %08" PRIX32 "\n", e.length, e.seed, r, e.result );
std::fprintf( stderr, "Reference value mismatch for length %zu, seed %016" PRIX64 ": was %08" PRIX32 ", expected %08" PRIX32 "\n", e.length, e.seed, r, e.result );
++errors;
}
}
Expand Down
89 changes: 53 additions & 36 deletions mulxp3_32_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,63 @@
struct reference_entry
{
std::size_t length;
std::uint32_t seed;
std::uint64_t seed;
std::uint32_t result;
};

reference_entry const ref[] =
{
{ 0, 0x00000000, 0x8E655EAE },
{ 0, 0x9E3779B9, 0xEF63B598 },
{ 17, 0x00000000, 0x69931AE7 },
{ 17, 0x9E3779B9, 0xDC735952 },
{ 34, 0x00000000, 0xEBFAD8A5 },
{ 34, 0x9E3779B9, 0xD7B63531 },
{ 51, 0x00000000, 0xAA337B35 },
{ 51, 0x9E3779B9, 0x134C803C },
{ 68, 0x00000000, 0x42BABC15 },
{ 68, 0x9E3779B9, 0xB4A6F072 },
{ 85, 0x00000000, 0x1A39F5C2 },
{ 85, 0x9E3779B9, 0xAB805A44 },
{ 102, 0x00000000, 0xCA101728 },
{ 102, 0x9E3779B9, 0x2A3380E3 },
{ 119, 0x00000000, 0xD95677AE },
{ 119, 0x9E3779B9, 0xCE68A989 },
{ 136, 0x00000000, 0xD9E48D12 },
{ 136, 0x9E3779B9, 0xE4B7F350 },
{ 153, 0x00000000, 0x2C6040EB },
{ 153, 0x9E3779B9, 0x2277D67A },
{ 170, 0x00000000, 0x6B8F0E37 },
{ 170, 0x9E3779B9, 0x0F04D6F4 },
{ 187, 0x00000000, 0x6EA8D6AC },
{ 187, 0x9E3779B9, 0x06932376 },
{ 204, 0x00000000, 0x11568A19 },
{ 204, 0x9E3779B9, 0xB49F516B },
{ 221, 0x00000000, 0x733B857D },
{ 221, 0x9E3779B9, 0x15AD48B2 },
{ 238, 0x00000000, 0x9EF34228 },
{ 238, 0x9E3779B9, 0xD7444A15 },
{ 255, 0x00000000, 0x5ACF71B8 },
{ 255, 0x9E3779B9, 0x11A6CEF3 },
{ 272, 0x00000000, 0xFF645816 },
{ 272, 0x9E3779B9, 0x3C737157 },
{ 0, 0x0000000000000000, 0x8E655EAE },
{ 0, 0x000000009E3779B9, 0xEF63B598 },
{ 0, 0x9E3779B97F4A7C15, 0xE4C5A28A },
{ 17, 0x0000000000000000, 0x69931AE7 },
{ 17, 0x000000009E3779B9, 0xDC735952 },
{ 17, 0x9E3779B97F4A7C15, 0x039BFAC6 },
{ 34, 0x0000000000000000, 0xEBFAD8A5 },
{ 34, 0x000000009E3779B9, 0xD7B63531 },
{ 34, 0x9E3779B97F4A7C15, 0x7CB4A6A5 },
{ 51, 0x0000000000000000, 0xAA337B35 },
{ 51, 0x000000009E3779B9, 0x134C803C },
{ 51, 0x9E3779B97F4A7C15, 0xC3CF319C },
{ 68, 0x0000000000000000, 0x42BABC15 },
{ 68, 0x000000009E3779B9, 0xB4A6F072 },
{ 68, 0x9E3779B97F4A7C15, 0x913BE4C7 },
{ 85, 0x0000000000000000, 0x1A39F5C2 },
{ 85, 0x000000009E3779B9, 0xAB805A44 },
{ 85, 0x9E3779B97F4A7C15, 0x0AFBBB6A },
{ 102, 0x0000000000000000, 0xCA101728 },
{ 102, 0x000000009E3779B9, 0x2A3380E3 },
{ 102, 0x9E3779B97F4A7C15, 0x795BC156 },
{ 119, 0x0000000000000000, 0xD95677AE },
{ 119, 0x000000009E3779B9, 0xCE68A989 },
{ 119, 0x9E3779B97F4A7C15, 0x11358E7A },
{ 136, 0x0000000000000000, 0xD9E48D12 },
{ 136, 0x000000009E3779B9, 0xE4B7F350 },
{ 136, 0x9E3779B97F4A7C15, 0xC0CBF17E },
{ 153, 0x0000000000000000, 0x2C6040EB },
{ 153, 0x000000009E3779B9, 0x2277D67A },
{ 153, 0x9E3779B97F4A7C15, 0x6774C7F3 },
{ 170, 0x0000000000000000, 0x6B8F0E37 },
{ 170, 0x000000009E3779B9, 0x0F04D6F4 },
{ 170, 0x9E3779B97F4A7C15, 0x279B5D64 },
{ 187, 0x0000000000000000, 0x6EA8D6AC },
{ 187, 0x000000009E3779B9, 0x06932376 },
{ 187, 0x9E3779B97F4A7C15, 0x8CA50A78 },
{ 204, 0x0000000000000000, 0x11568A19 },
{ 204, 0x000000009E3779B9, 0xB49F516B },
{ 204, 0x9E3779B97F4A7C15, 0xDC248FCF },
{ 221, 0x0000000000000000, 0x733B857D },
{ 221, 0x000000009E3779B9, 0x15AD48B2 },
{ 221, 0x9E3779B97F4A7C15, 0x13506892 },
{ 238, 0x0000000000000000, 0x9EF34228 },
{ 238, 0x000000009E3779B9, 0xD7444A15 },
{ 238, 0x9E3779B97F4A7C15, 0x5E73D730 },
{ 255, 0x0000000000000000, 0x5ACF71B8 },
{ 255, 0x000000009E3779B9, 0x11A6CEF3 },
{ 255, 0x9E3779B97F4A7C15, 0x95B68776 },
{ 272, 0x0000000000000000, 0xFF645816 },
{ 272, 0x000000009E3779B9, 0x3C737157 },
{ 272, 0x9E3779B97F4A7C15, 0x10AE1445 },
};

int main()
Expand All @@ -68,7 +85,7 @@ int main()

if( r != e.result )
{
std::fprintf( stderr, "Reference value mismatch for length %zu, seed %08" PRIX32 ": was %08" PRIX32 ", expected %08" PRIX32 "\n", e.length, e.seed, r, e.result );
std::fprintf( stderr, "Reference value mismatch for length %zu, seed %016" PRIX64 ": was %08" PRIX32 ", expected %08" PRIX32 "\n", e.length, e.seed, r, e.result );
++errors;
}
}
Expand Down

0 comments on commit fd906b5

Please sign in to comment.