aboutsummaryrefslogtreecommitdiff
path: root/src/unit/sha1.unit
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/unit/sha1.unit
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/unit/sha1.unit')
-rw-r--r--src/unit/sha1.unit112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/unit/sha1.unit b/src/unit/sha1.unit
index d91b4c3..1151cfb 100644
--- a/src/unit/sha1.unit
+++ b/src/unit/sha1.unit
@@ -12,65 +12,65 @@
12 12
13suite Sha1 13suite Sha1
14{ 14{
15 test basics 15 test basics
16 { 16 {
17#define tryStr( a, b ) \ 17#define tryStr( a, b ) \
18 { Bu::Sha1 m; m.addData(a); unitTest( m.getHexResult() == b ); } (void)0 18 { Bu::Sha1 m; m.addData(a); unitTest( m.getHexResult() == b ); } (void)0
19 tryStr("", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); 19 tryStr("", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
20 tryStr("The quick brown fox jumps over the lazy dog", 20 tryStr("The quick brown fox jumps over the lazy dog",
21 "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"); 21 "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12");
22 tryStr("The quick brown fox jumps over the lazy cog", 22 tryStr("The quick brown fox jumps over the lazy cog",
23 "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3"); 23 "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3");
24 } 24 }
25 25
26 test twoChunks 26 test twoChunks
27 { 27 {
28 Bu::Sha1 m; 28 Bu::Sha1 m;
29 m.addData("The quick brown fo"); 29 m.addData("The quick brown fo");
30 m.addData("x jumps over the lazy dog"); 30 m.addData("x jumps over the lazy dog");
31 unitTest( m.getHexResult() == "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" ); 31 unitTest( m.getHexResult() == "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" );
32 } 32 }
33 33
34 test biggerBlocks 34 test biggerBlocks
35 { 35 {
36 const char *sums[41] = { 36 const char *sums[41] = {
37 "2356aab95478d8e3c2c918e36f383e46d06154c7", 37 "2356aab95478d8e3c2c918e36f383e46d06154c7",
38 "e3f663240c185a95111c4e00e20865dfbda390aa", 38 "e3f663240c185a95111c4e00e20865dfbda390aa",
39 "3f21881040b42f44476b610b6d2191f72afc1cb5", 39 "3f21881040b42f44476b610b6d2191f72afc1cb5",
40 "493fe9da6de598c52ea56962b15ccc4405a8dfda", 40 "493fe9da6de598c52ea56962b15ccc4405a8dfda",
41 "4684ff568f7c1198a258eb04d88209f4feab4e05", 41 "4684ff568f7c1198a258eb04d88209f4feab4e05",
42 "614101c1c164b8b6099f63165ea01078cbb6c77f", 42 "614101c1c164b8b6099f63165ea01078cbb6c77f",
43 "393f1c1a9f6384653029ab807756e85a13147029", 43 "393f1c1a9f6384653029ab807756e85a13147029",
44 "fd66443d68f8b0508b4f125f2cff1192bfc01913", 44 "fd66443d68f8b0508b4f125f2cff1192bfc01913",
45 "1ef66120e530731194554bb2cd51293779a0bcc7", 45 "1ef66120e530731194554bb2cd51293779a0bcc7",
46 "d77e0eda0037f51b0b6c197371c5fd801cc0eede", 46 "d77e0eda0037f51b0b6c197371c5fd801cc0eede",
47 "ce8b579bd3aa2ccac2e0205f52a8ed03777117ac", 47 "ce8b579bd3aa2ccac2e0205f52a8ed03777117ac",
48 "d9e9d7fc411de2f89329ab758dc8f4302f80ff23" 48 "d9e9d7fc411de2f89329ab758dc8f4302f80ff23"
49 }; 49 };
50 50
51 char block[128]; 51 char block[128];
52 for( int i = 0; i < 128; i++ ) 52 for( int i = 0; i < 128; i++ )
53 block[i] = i*2; 53 block[i] = i*2;
54 54
55 const char **curSum = sums; 55 const char **curSum = sums;
56 for( int j = 1; j < 4096; j*=2 ) 56 for( int j = 1; j < 4096; j*=2 )
57 { 57 {
58 /* 58 /*
59 Bu::File fOut("temp", Bu::File::WriteNew ); 59 Bu::File fOut("temp", Bu::File::WriteNew );
60 for( int b = 0; b < j; b++ ) 60 for( int b = 0; b < j; b++ )
61 { 61 {
62 fOut.write( block, 128 ); 62 fOut.write( block, 128 );
63 } 63 }
64 fOut.close(); 64 fOut.close();
65 system("sha1sum -b temp"); 65 system("sha1sum -b temp");
66 */ 66 */
67 Bu::Sha1 m; 67 Bu::Sha1 m;
68 for( int b = 0; b < j; b++ ) 68 for( int b = 0; b < j; b++ )
69 { 69 {
70 m.addData( block, 128 ); 70 m.addData( block, 128 );
71 } 71 }
72 unitTest( m.getHexResult() == *curSum ); 72 unitTest( m.getHexResult() == *curSum );
73 curSum++; 73 curSum++;
74 } 74 }
75 } 75 }
76} 76}