Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: xz/tests/test_check.c

Issue 2869016: Add an unpatched version of xz, XZ Utils, to /trunk/deps/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « xz/tests/test_block_header.c ('k') | xz/tests/test_compress.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file test_check.c
4 /// \brief Tests integrity checks
5 ///
6 /// \todo Add SHA256
7 //
8 // Author: Lasse Collin
9 //
10 // This file has been put into the public domain.
11 // You can do whatever you want with this file.
12 //
13 ///////////////////////////////////////////////////////////////////////////////
14
15 #include "tests.h"
16
17
18 static const uint8_t test_string[9] = "123456789";
19 static const uint8_t test_unaligned[12] = "xxx123456789";
20
21
22 static bool
23 test_crc32(void)
24 {
25 static const uint32_t test_vector = 0xCBF43926;
26
27 // Test 1
28 uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0);
29 if (crc != test_vector)
30 return true;
31
32 // Test 2
33 crc = lzma_crc32(test_unaligned + 3, sizeof(test_string), 0);
34 if (crc != test_vector)
35 return true;
36
37 // Test 3
38 crc = 0;
39 for (size_t i = 0; i < sizeof(test_string); ++i)
40 crc = lzma_crc32(test_string + i, 1, crc);
41 if (crc != test_vector)
42 return true;
43
44 return false;
45 }
46
47
48 static bool
49 test_crc64(void)
50 {
51 static const uint64_t test_vector = 0x995DC9BBDF1939FA;
52
53 // Test 1
54 uint64_t crc = lzma_crc64(test_string, sizeof(test_string), 0);
55 if (crc != test_vector)
56 return true;
57
58 // Test 2
59 crc = lzma_crc64(test_unaligned + 3, sizeof(test_string), 0);
60 if (crc != test_vector)
61 return true;
62
63 // Test 3
64 crc = 0;
65 for (size_t i = 0; i < sizeof(test_string); ++i)
66 crc = lzma_crc64(test_string + i, 1, crc);
67 if (crc != test_vector)
68 return true;
69
70 return false;
71 }
72
73
74 int
75 main(void)
76 {
77 bool error = false;
78
79 error |= test_crc32();
80 error |= test_crc64();
81
82 return error ? 1 : 0;
83 }
OLDNEW
« no previous file with comments | « xz/tests/test_block_header.c ('k') | xz/tests/test_compress.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698