11using System ;
22using System . IO ;
3- using System . Threading ;
4-
53using ICSharpCode . SharpZipLib . BZip2 ;
6-
74using ICSharpCode . SharpZipLib . Tests . TestSupport ;
8-
95using NUnit . Framework ;
106
117namespace ICSharpCode . SharpZipLib . Tests . BZip2
@@ -25,37 +21,33 @@ public void BasicRoundTrip()
2521 {
2622 var ms = new MemoryStream ( ) ;
2723 var outStream = new BZip2OutputStream ( ms ) ;
28-
24+
2925 byte [ ] buf = new byte [ 10000 ] ;
3026 var rnd = new Random ( ) ;
3127 rnd . NextBytes ( buf ) ;
32-
28+
3329 outStream . Write ( buf , 0 , buf . Length ) ;
3430 outStream . Close ( ) ;
3531 ms = new MemoryStream ( ms . GetBuffer ( ) ) ;
3632 ms . Seek ( 0 , SeekOrigin . Begin ) ;
37-
38- using ( BZip2InputStream inStream = new BZip2InputStream ( ms ) )
39- {
33+
34+ using ( BZip2InputStream inStream = new BZip2InputStream ( ms ) ) {
4035 byte [ ] buf2 = new byte [ buf . Length ] ;
41- int pos = 0 ;
42- while ( true )
43- {
36+ int pos = 0 ;
37+ while ( true ) {
4438 int numRead = inStream . Read ( buf2 , pos , 4096 ) ;
45- if ( numRead <= 0 )
46- {
39+ if ( numRead <= 0 ) {
4740 break ;
4841 }
4942 pos += numRead ;
5043 }
51-
52- for ( int i = 0 ; i < buf . Length ; ++ i )
53- {
44+
45+ for ( int i = 0 ; i < buf . Length ; ++ i ) {
5446 Assert . AreEqual ( buf2 [ i ] , buf [ i ] ) ;
5547 }
5648 }
5749 }
58-
50+
5951 /// <summary>
6052 /// Check that creating an empty archive is handled ok
6153 /// </summary>
@@ -67,34 +59,31 @@ public void CreateEmptyArchive()
6759 var outStream = new BZip2OutputStream ( ms ) ;
6860 outStream . Close ( ) ;
6961 ms = new MemoryStream ( ms . GetBuffer ( ) ) ;
70-
62+
7163 ms . Seek ( 0 , SeekOrigin . Begin ) ;
72-
73- using ( BZip2InputStream inStream = new BZip2InputStream ( ms ) )
74- {
64+
65+ using ( BZip2InputStream inStream = new BZip2InputStream ( ms ) ) {
7566 byte [ ] buffer = new byte [ 1024 ] ;
76- int pos = 0 ;
77- while ( true )
78- {
67+ int pos = 0 ;
68+ while ( true ) {
7969 int numRead = inStream . Read ( buffer , 0 , buffer . Length ) ;
80- if ( numRead <= 0 )
81- {
70+ if ( numRead <= 0 ) {
8271 break ;
8372 }
8473 pos += numRead ;
8574 }
86-
75+
8776 Assert . AreEqual ( pos , 0 ) ;
8877 }
8978 }
9079
91- readonly BZip2OutputStream outStream_ ;
92- BZip2InputStream inStream_ ;
80+ readonly BZip2OutputStream outStream_ ;
81+ BZip2InputStream inStream_ ;
9382 WindowedStream window_ ;
9483 long readTarget_ ;
9584 long writeTarget_ ;
96-
97- // TODO: Fix this
85+
86+ // TODO: Fix this
9887 //[Test]
9988 //[Category("BZip2")]
10089 //public void Performance()
@@ -115,19 +104,19 @@ public void CreateEmptyArchive()
115104 // DateTime startTime = DateTime.Now;
116105 // writer.Start();
117106
118- // inStream_ = new BZip2InputStream(window_);
107+ // inStream_ = new BZip2InputStream(window_);
119108
120- // reader.Start();
109+ // reader.Start();
121110
122111 // Assert.IsTrue(writer.Join(TimeSpan.FromMinutes(5.0D)));
123112 // Assert.IsTrue(reader.Join(TimeSpan.FromMinutes(5.0D)));
124113
125114 // DateTime endTime = DateTime.Now;
126115 // TimeSpan span = endTime - startTime;
127116 // Console.WriteLine("Time {0} throughput {1} KB/Sec", span, (Target / 1024) / span.TotalSeconds);
128-
117+
129118 //}
130-
119+
131120 void Reader ( )
132121 {
133122 const int Size = 8192 ;
@@ -136,19 +125,16 @@ void Reader()
136125
137126 long passifierLevel = readTarget_ - 0x10000000 ;
138127
139- while ( ( readTarget_ > 0 ) && ( readBytes > 0 ) )
140- {
128+ while ( ( readTarget_ > 0 ) && ( readBytes > 0 ) ) {
141129 int count = Size ;
142- if ( count > readTarget_ )
143- {
130+ if ( count > readTarget_ ) {
144131 count = ( int ) readTarget_ ;
145132 }
146133
147134 readBytes = inStream_ . Read ( buffer , 0 , count ) ;
148135 readTarget_ -= readBytes ;
149136
150- if ( readTarget_ <= passifierLevel )
151- {
137+ if ( readTarget_ <= passifierLevel ) {
152138 Console . WriteLine ( "Reader {0} bytes remaining" , readTarget_ ) ;
153139 passifierLevel = readTarget_ - 0x10000000 ;
154140 }
@@ -161,19 +147,17 @@ void Reader()
161147 Assert . AreEqual ( 0 , readBytes , "Stream should be empty" ) ;
162148 Assert . AreEqual ( 0 , window_ . Length , "Window should be closed" ) ;
163149 inStream_ . Close ( ) ;
164- }
150+ }
165151
166152 void WriteTargetBytes ( )
167153 {
168154 const int Size = 8192 ;
169155
170156 byte [ ] buffer = new byte [ Size ] ;
171157
172- while ( writeTarget_ > 0 )
173- {
158+ while ( writeTarget_ > 0 ) {
174159 int thisTime = Size ;
175- if ( thisTime > writeTarget_ )
176- {
160+ if ( thisTime > writeTarget_ ) {
177161 thisTime = ( int ) writeTarget_ ;
178162 }
179163
0 commit comments