1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Tests integrity checks
8 // Copyright (C) 2007 Lasse Collin
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 ///////////////////////////////////////////////////////////////////////////////
25 static const uint8_t test_string[9] = "123456789";
26 static const uint8_t test_unaligned[12] = "xxx123456789";
32 static const uint32_t test_vector = 0xCBF43926;
35 uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0);
36 if (crc != test_vector)
40 crc = lzma_crc32(test_unaligned + 3, sizeof(test_string), 0);
41 if (crc != test_vector)
46 for (size_t i = 0; i < sizeof(test_string); ++i)
47 crc = lzma_crc32(test_string + i, 1, crc);
48 if (crc != test_vector)
58 static const uint64_t test_vector = 0x995DC9BBDF1939FA;
61 uint64_t crc = lzma_crc64(test_string, sizeof(test_string), 0);
62 if (crc != test_vector)
66 crc = lzma_crc64(test_unaligned + 3, sizeof(test_string), 0);
67 if (crc != test_vector)
72 for (size_t i = 0; i < sizeof(test_string); ++i)
73 crc = lzma_crc64(test_string + i, 1, crc);
74 if (crc != test_vector)
88 error |= test_crc32();
89 error |= test_crc64();