diff options
Diffstat (limited to 'third_party/rust/flate2/tests')
-rw-r--r-- | third_party/rust/flate2/tests/corrupt-gz-file.bin | bin | 0 -> 7128 bytes | |||
-rw-r--r-- | third_party/rust/flate2/tests/early-flush.rs | 20 | ||||
-rw-r--r-- | third_party/rust/flate2/tests/empty-read.rs | 82 | ||||
-rw-r--r-- | third_party/rust/flate2/tests/good-file.gz | bin | 0 -> 6766 bytes | |||
-rw-r--r-- | third_party/rust/flate2/tests/good-file.txt | 733 | ||||
-rw-r--r-- | third_party/rust/flate2/tests/gunzip.rs | 77 | ||||
-rw-r--r-- | third_party/rust/flate2/tests/multi.gz | bin | 0 -> 53 bytes | |||
-rw-r--r-- | third_party/rust/flate2/tests/multi.txt | 2 | ||||
-rw-r--r-- | third_party/rust/flate2/tests/zero-write.rs | 8 |
9 files changed, 922 insertions, 0 deletions
diff --git a/third_party/rust/flate2/tests/corrupt-gz-file.bin b/third_party/rust/flate2/tests/corrupt-gz-file.bin Binary files differnew file mode 100644 index 0000000000..159333b032 --- /dev/null +++ b/third_party/rust/flate2/tests/corrupt-gz-file.bin diff --git a/third_party/rust/flate2/tests/early-flush.rs b/third_party/rust/flate2/tests/early-flush.rs new file mode 100644 index 0000000000..e717adaa52 --- /dev/null +++ b/third_party/rust/flate2/tests/early-flush.rs @@ -0,0 +1,20 @@ +extern crate flate2; + +use std::io::{Read, Write}; + +use flate2::read::GzDecoder; +use flate2::write::GzEncoder; + +#[test] +fn smoke() { + let mut w = GzEncoder::new(Vec::new(), flate2::Compression::default()); + w.flush().unwrap(); + w.write_all(b"hello").unwrap(); + + let bytes = w.finish().unwrap(); + + let mut r = GzDecoder::new(&bytes[..]); + let mut s = String::new(); + r.read_to_string(&mut s).unwrap(); + assert_eq!(s, "hello"); +} diff --git a/third_party/rust/flate2/tests/empty-read.rs b/third_party/rust/flate2/tests/empty-read.rs new file mode 100644 index 0000000000..7551238336 --- /dev/null +++ b/third_party/rust/flate2/tests/empty-read.rs @@ -0,0 +1,82 @@ +extern crate flate2; + +use std::io::{Read, Write}; + +#[test] +fn deflate_decoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = + flate2::write::DeflateEncoder::new(Vec::new(), flate2::Compression::default()); + encoder.write_all(original).unwrap(); + let encoded: Vec<u8> = encoder.finish().unwrap(); + let mut decoder = flate2::read::DeflateDecoder::new(encoded.as_slice()); + assert_eq!(decoder.read(&mut []).unwrap(), 0); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} + +#[test] +fn deflate_encoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = flate2::read::DeflateEncoder::new(original, flate2::Compression::default()); + assert_eq!(encoder.read(&mut []).unwrap(), 0); + let mut encoded = Vec::new(); + encoder.read_to_end(&mut encoded).unwrap(); + let mut decoder = flate2::read::DeflateDecoder::new(encoded.as_slice()); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} + +#[test] +fn gzip_decoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = flate2::write::GzEncoder::new(Vec::new(), flate2::Compression::default()); + encoder.write_all(original).unwrap(); + let encoded: Vec<u8> = encoder.finish().unwrap(); + let mut decoder = flate2::read::GzDecoder::new(encoded.as_slice()); + assert_eq!(decoder.read(&mut []).unwrap(), 0); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} + +#[test] +fn gzip_encoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = flate2::read::GzEncoder::new(original, flate2::Compression::default()); + assert_eq!(encoder.read(&mut []).unwrap(), 0); + let mut encoded = Vec::new(); + encoder.read_to_end(&mut encoded).unwrap(); + let mut decoder = flate2::read::GzDecoder::new(encoded.as_slice()); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} + +#[test] +fn zlib_decoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = flate2::write::ZlibEncoder::new(Vec::new(), flate2::Compression::default()); + encoder.write_all(original).unwrap(); + let encoded: Vec<u8> = encoder.finish().unwrap(); + let mut decoder = flate2::read::ZlibDecoder::new(encoded.as_slice()); + assert_eq!(decoder.read(&mut []).unwrap(), 0); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} + +#[test] +fn zlib_encoder_empty_read() { + let original: &[u8] = b"Lorem ipsum dolor sit amet."; + let mut encoder = flate2::read::ZlibEncoder::new(original, flate2::Compression::default()); + assert_eq!(encoder.read(&mut []).unwrap(), 0); + let mut encoded = Vec::new(); + encoder.read_to_end(&mut encoded).unwrap(); + let mut decoder = flate2::read::ZlibDecoder::new(encoded.as_slice()); + let mut decoded = Vec::new(); + decoder.read_to_end(&mut decoded).unwrap(); + assert_eq!(decoded.as_slice(), original); +} diff --git a/third_party/rust/flate2/tests/good-file.gz b/third_party/rust/flate2/tests/good-file.gz Binary files differnew file mode 100644 index 0000000000..f968689cce --- /dev/null +++ b/third_party/rust/flate2/tests/good-file.gz diff --git a/third_party/rust/flate2/tests/good-file.txt b/third_party/rust/flate2/tests/good-file.txt new file mode 100644 index 0000000000..ee39ac53db --- /dev/null +++ b/third_party/rust/flate2/tests/good-file.txt @@ -0,0 +1,733 @@ +## ## +timestep simulated EIR patent hosts +0 0.136402 16855 +1 0.146872 18564 +2 0.150157 20334 +3 0.146358 22159 +4 0.136315 23655 +5 0.122354 24848 +6 0.104753 25887 +7 0.084439 26770 +8 0.06417 27238 +9 0.0450397 27349 +10 0.0295473 27274 +11 0.0184662 26909 +12 0.0110032 26324 +13 0.00634348 25513 +14 0.0036144 24469 +15 0.00208133 23383 +16 0.00122468 22345 +17 0.000752514 21342 +18 0.000545333 20416 +19 0.000546139 19657 +20 0.00054572 18806 +21 0.000545757 18015 +22 0.000545898 17349 +23 0.000546719 16594 +24 0.000547353 15955 +25 0.000547944 15374 +26 0.000547606 14765 +27 0.000594773 14212 +28 0.000969163 13677 +29 0.00168295 13180 +30 0.003059 12760 +31 0.00571599 12313 +32 0.0107918 11896 +33 0.0201943 11512 +34 0.0368013 11340 +35 0.0640629 11323 +36 0.104447 11769 +37 0.157207 12728 +38 0.216682 14261 +39 0.271159 16491 +40 0.303552 19274 +41 0.303678 22157 +42 0.271945 24875 +43 0.215445 27027 +44 0.154503 28690 +45 0.100717 30046 +46 0.0600343 30602 +47 0.0328576 30709 +48 0.016964 30315 +49 0.00841526 29310 +50 0.0040958 28058 +51 0.0019953 26662 +52 0.000986531 25259 +53 0.000545786 24049 +54 0.000546405 22966 +55 0.000546036 21933 +56 0.00054427 20953 +57 0.000542769 20057 +58 0.000541566 19304 +59 0.000541822 18477 +60 0.000541643 17695 +61 0.000541989 17002 +62 0.000769298 16391 +63 0.00150811 15805 +64 0.00295097 15172 +65 0.00566197 14690 +66 0.0105243 14206 +67 0.0186965 13791 +68 0.0313363 13470 +69 0.0490605 13377 +70 0.0711679 13631 +71 0.0953625 14209 +72 0.118026 15277 +73 0.134612 16760 +74 0.144311 18339 +75 0.146328 20124 +76 0.142936 21803 +77 0.134029 23435 +78 0.120562 24854 +79 0.103157 25880 +80 0.0834054 26597 +81 0.0632474 27226 +82 0.0447785 27294 +83 0.0295654 27169 +84 0.0184081 26803 +85 0.0109489 26265 +86 0.00631234 25375 +87 0.00359978 24306 +88 0.00206967 23260 +89 0.00122197 22225 +90 0.000751031 21277 +91 0.000544507 20295 +92 0.000543897 19417 +93 0.000543483 18623 +94 0.000542926 17837 +95 0.000542685 17070 +96 0.000542387 16424 +97 0.000541194 15838 +98 0.000540427 15177 +99 0.000540774 14608 +100 0.000588312 14066 +101 0.000959183 13499 +102 0.00166774 12979 +103 0.00303278 12545 +104 0.00567457 12067 +105 0.0107272 11712 +106 0.0200606 11368 +107 0.0364637 11207 +108 0.063339 11238 +109 0.103717 11660 +110 0.156884 12621 +111 0.217072 14151 +112 0.272311 16358 +113 0.305046 19005 +114 0.304927 21926 +115 0.272427 24662 +116 0.216478 27080 +117 0.155168 29064 +118 0.10079 30370 +119 0.0599659 30992 +120 0.0331287 30975 +121 0.017235 30317 +122 0.00860221 29455 +123 0.00419286 28172 +124 0.00203361 26809 +125 0.000998847 25476 +126 0.000551418 24230 +127 0.000551119 23106 +128 0.000552786 22147 +129 0.000553814 21183 +130 0.000553743 20280 +131 0.000554428 19423 +132 0.000555022 18598 +133 0.000555921 17864 +134 0.000556687 17187 +135 0.000789996 16527 +136 0.00154597 15870 +137 0.00302776 15226 +138 0.00581484 14685 +139 0.010812 14234 +140 0.0191832 13818 +141 0.0321572 13571 +142 0.050328 13538 +143 0.072817 13812 +144 0.0974321 14368 +145 0.120225 15436 +146 0.137418 16988 +147 0.147086 18775 +148 0.149165 20563 +149 0.144943 22223 +150 0.136631 23741 +151 0.123355 24920 +152 0.105401 25779 +153 0.0851918 26781 +154 0.0641702 27265 +155 0.0450746 27505 +156 0.0294136 27416 +157 0.0183811 27028 +158 0.0109285 26260 +159 0.00634296 25451 +160 0.00364513 24472 +161 0.0021051 23427 +162 0.00123693 22403 +163 0.000759531 21393 +164 0.000551727 20485 +165 0.000552256 19660 +166 0.000552303 18862 +167 0.000550927 18094 +168 0.000551098 17378 +169 0.000551093 16691 +170 0.000551885 16050 +171 0.000552282 15420 +172 0.000552591 14878 +173 0.00060109 14357 +174 0.000980446 13768 +175 0.00170301 13241 +176 0.003096 12745 +177 0.00579971 12294 +178 0.010976 11879 +179 0.0205422 11636 +180 0.0374515 11431 +181 0.0649916 11517 +182 0.106008 11966 +183 0.159983 12918 +184 0.221127 14484 +185 0.276503 16696 +186 0.310316 19518 +187 0.311205 22301 +188 0.276769 25047 +189 0.220506 27360 +190 0.159123 29133 +191 0.103761 30440 +192 0.0613797 31087 +193 0.033583 31037 +194 0.0173275 30555 +195 0.00861968 29617 +196 0.00419503 28292 +197 0.00203304 26944 +198 0.00100126 25569 +199 0.000553511 24349 +200 0.000554687 23257 +201 0.00055586 22204 +202 0.000555419 21176 +203 0.000556032 20316 +204 0.000555974 19509 +205 0.000556859 18746 +206 0.000556996 17978 +207 0.000557102 17288 +208 0.000790187 16672 +209 0.00154711 16057 +210 0.00303521 15449 +211 0.00584201 14915 +212 0.0108854 14397 +213 0.0193386 14010 +214 0.0324346 13730 +215 0.0507192 13674 +216 0.0736661 13874 +217 0.0987887 14515 +218 0.122411 15693 +219 0.139964 17265 +220 0.149125 18894 +221 0.151434 20662 +222 0.148067 22442 +223 0.138894 24116 +224 0.125436 25367 +225 0.107664 26360 +226 0.0865709 27044 +227 0.0655588 27428 +228 0.0459664 27714 +229 0.0301384 27687 +230 0.0186481 27262 +231 0.01103 26677 +232 0.00636957 25722 +233 0.00366188 24662 +234 0.00212213 23575 +235 0.00125358 22520 +236 0.000768665 21480 +237 0.000556393 20563 +238 0.000555892 19706 +239 0.00055534 18914 +240 0.000555027 18165 +241 0.000555062 17432 +242 0.000553766 16733 +243 0.000552984 16070 +244 0.000553634 15396 +245 0.000554286 14867 +246 0.000603759 14362 +247 0.000982974 13867 +248 0.00170532 13379 +249 0.00310471 12907 +250 0.00582577 12446 +251 0.0110122 12018 +252 0.0206284 11730 +253 0.0375835 11546 +254 0.0652192 11605 +255 0.10646 11981 +256 0.160858 12949 +257 0.223122 14478 +258 0.279678 16810 +259 0.312171 19452 +260 0.311778 22391 +261 0.276966 25204 +262 0.22251 27379 +263 0.159246 29248 +264 0.104109 30532 +265 0.0617903 30995 +266 0.0338421 31042 +267 0.0174647 30620 +268 0.00867821 29589 +269 0.00419968 28293 +270 0.00203244 26916 +271 0.00100204 25464 +272 0.000555586 24219 +273 0.000555599 23207 +274 0.00055582 22187 +275 0.00055516 21136 +276 0.000555436 20243 +277 0.000555618 19426 +278 0.000556778 18635 +279 0.000556976 17870 +280 0.000557162 17190 +281 0.0007904 16506 +282 0.00154557 15837 +283 0.00302973 15234 +284 0.00584543 14717 +285 0.0108796 14225 +286 0.0192919 13810 +287 0.032329 13605 +288 0.0505293 13536 +289 0.0733417 13760 +290 0.0982413 14378 +291 0.121477 15400 +292 0.138636 17017 +293 0.14875 18764 +294 0.150515 20516 +295 0.146372 22389 +296 0.137332 23975 +297 0.124076 25120 +298 0.106469 26137 +299 0.0862987 26973 +300 0.0650552 27584 +301 0.0456456 27741 +302 0.0300744 27565 +303 0.0187879 27212 +304 0.0112085 26432 +305 0.00648306 25501 +306 0.00370346 24466 +307 0.00213399 23472 +308 0.00125463 22415 +309 0.000765794 21427 +310 0.000552587 20533 +311 0.000553175 19632 +312 0.000553525 18831 +313 0.000554941 18119 +314 0.000556327 17336 +315 0.000556008 16721 +316 0.00055593 16086 +317 0.000556421 15516 +318 0.000557308 14918 +319 0.00060681 14402 +320 0.000990746 13849 +321 0.00172359 13355 +322 0.00313688 12902 +323 0.0058708 12425 +324 0.0110637 12087 +325 0.0206777 11743 +326 0.0376394 11531 +327 0.0656182 11582 +328 0.107414 12034 +329 0.162101 12955 +330 0.223525 14571 +331 0.279935 16842 +332 0.314601 19566 +333 0.313556 22575 +334 0.279571 25279 +335 0.221638 27642 +336 0.158038 29275 +337 0.102505 30638 +338 0.0608328 31209 +339 0.0335531 31260 +340 0.0173332 30520 +341 0.00861545 29604 +342 0.00419454 28370 +343 0.00202587 26940 +344 0.000994029 25614 +345 0.000549339 24445 +346 0.000551477 23239 +347 0.000552891 22300 +348 0.000551775 21280 +349 0.000552425 20424 +350 0.000552135 19571 +351 0.000552542 18753 +352 0.000552863 18058 +353 0.000554438 17348 +354 0.000786735 16671 +355 0.00153958 16047 +356 0.00301482 15500 +357 0.00580589 14883 +358 0.0108227 14347 +359 0.0192357 13947 +360 0.0321613 13672 +361 0.050229 13606 +362 0.0729462 13815 +363 0.0978564 14566 +364 0.120879 15674 +365 0.137663 17049 +366 0.147092 18813 +367 0.150184 20578 +368 0.146971 22245 +369 0.136769 23723 +370 0.12367 24905 +371 0.106187 25871 +372 0.0860921 26687 +373 0.0645899 27375 +374 0.0453473 27635 +375 0.0298122 27551 +376 0.0185448 27134 +377 0.0110517 26468 +378 0.00640294 25661 +379 0.00367011 24653 +380 0.00211832 23556 +381 0.00125246 22513 +382 0.00076891 21568 +383 0.000557384 20672 +384 0.000557295 19811 +385 0.000556837 18982 +386 0.000557433 18179 +387 0.000557376 17457 +388 0.000557751 16720 +389 0.000556844 16112 +390 0.000555603 15479 +391 0.000554871 14809 +392 0.00060335 14275 +393 0.000982808 13757 +394 0.00170757 13221 +395 0.00310351 12758 +396 0.0058181 12286 +397 0.010991 11906 +398 0.0205342 11557 +399 0.0373486 11393 +400 0.0647659 11487 +401 0.105589 11887 +402 0.15967 12798 +403 0.220945 14260 +404 0.277122 16477 +405 0.310108 19295 +406 0.308854 22110 +407 0.274911 24915 +408 0.218618 27273 +409 0.156618 29189 +410 0.101775 30572 +411 0.0607503 31174 +412 0.0334708 31316 +413 0.0173443 30731 +414 0.00865633 29636 +415 0.00421141 28342 +416 0.00204387 26991 +417 0.00100602 25595 +418 0.000555131 24336 +419 0.000555037 23251 +420 0.000555559 22267 +421 0.000554916 21212 +422 0.000554432 20306 +423 0.000554751 19488 +424 0.00055638 18727 +425 0.000556727 17927 +426 0.000556368 17198 +427 0.000788004 16578 +428 0.00154404 15944 +429 0.00302383 15315 +430 0.00582586 14786 +431 0.0108457 14290 +432 0.0192962 13815 +433 0.0323072 13561 +434 0.0505101 13456 +435 0.0732162 13811 +436 0.0978737 14403 +437 0.121405 15460 +438 0.138202 16993 +439 0.1482 18710 +440 0.149707 20578 +441 0.146945 22256 +442 0.137785 23713 +443 0.123767 25058 +444 0.105989 26087 +445 0.085483 26759 +446 0.0646144 27375 +447 0.0454389 27680 +448 0.0299337 27531 +449 0.018663 27041 +450 0.0111347 26416 +451 0.00644197 25614 +452 0.00369229 24666 +453 0.00211986 23647 +454 0.00124761 22650 +455 0.000769104 21642 +456 0.000558796 20693 +457 0.000559908 19746 +458 0.000559562 18952 +459 0.00056042 18100 +460 0.000559447 17401 +461 0.000557893 16756 +462 0.000557137 16148 +463 0.000557269 15504 +464 0.000557596 14974 +465 0.000606298 14408 +466 0.000987712 13909 +467 0.00171257 13402 +468 0.00311667 12891 +469 0.00584794 12433 +470 0.0110774 11980 +471 0.0207006 11713 +472 0.037673 11583 +473 0.0654988 11677 +474 0.106982 12072 +475 0.161926 12898 +476 0.224327 14548 +477 0.281709 16796 +478 0.314567 19512 +479 0.313419 22428 +480 0.278962 25186 +481 0.221864 27755 +482 0.158559 29556 +483 0.103532 30572 +484 0.0611592 31162 +485 0.0337539 31197 +486 0.0175096 30619 +487 0.00865906 29606 +488 0.00420125 28271 +489 0.00203207 26856 +490 0.00100238 25542 +491 0.000554405 24306 +492 0.00055373 23160 +493 0.0005552 22152 +494 0.000553776 21192 +495 0.000553636 20302 +496 0.000553165 19505 +497 0.000554014 18719 +498 0.00055519 17993 +499 0.000556582 17233 +500 0.000788165 16569 +501 0.00154132 15953 +502 0.00302099 15350 +503 0.00581186 14752 +504 0.0108291 14267 +505 0.0192368 13946 +506 0.0322191 13677 +507 0.0503789 13594 +508 0.0730706 13768 +509 0.0980646 14416 +510 0.121601 15634 +511 0.139046 17110 +512 0.147779 18876 +513 0.149612 20734 +514 0.145796 22414 +515 0.136936 23884 +516 0.123807 25078 +517 0.106212 26066 +518 0.0855482 26779 +519 0.0643386 27340 +520 0.0452926 27530 +521 0.0298659 27573 +522 0.0185447 27169 +523 0.0110178 26489 +524 0.00635235 25588 +525 0.00362881 24549 +526 0.00209238 23528 +527 0.00123133 22541 +528 0.000755917 21498 +529 0.000546368 20607 +530 0.000547382 19712 +531 0.000547084 18975 +532 0.000546453 18178 +533 0.000546062 17452 +534 0.000546085 16749 +535 0.000546151 16135 +536 0.000545628 15567 +537 0.000545969 14968 +538 0.000594606 14392 +539 0.000968849 13854 +540 0.00168489 13360 +541 0.00306337 12899 +542 0.00573505 12407 +543 0.0108348 12017 +544 0.02025 11713 +545 0.0368201 11517 +546 0.0639795 11556 +547 0.104882 11941 +548 0.158923 12854 +549 0.219796 14396 +550 0.275801 16733 +551 0.307622 19367 +552 0.30785 22230 +553 0.272898 24873 +554 0.217351 27152 +555 0.156138 29108 +556 0.101477 30379 +557 0.0601091 30971 +558 0.0331551 31126 +559 0.017167 30418 +560 0.00853886 29430 +561 0.00415201 28190 +562 0.00201849 26849 +563 0.000991957 25528 +564 0.000546751 24180 +565 0.00054534 23090 +566 0.000544403 22096 +567 0.00054368 21140 +568 0.000543407 20213 +569 0.000544421 19405 +570 0.000545241 18625 +571 0.000546995 17868 +572 0.000547101 17102 +573 0.00077428 16423 +574 0.00151348 15783 +575 0.00296212 15220 +576 0.00569555 14602 +577 0.0106307 14154 +578 0.0188783 13743 +579 0.0316572 13538 +580 0.0495211 13467 +581 0.0718936 13665 +582 0.0961304 14240 +583 0.119127 15341 +584 0.136233 16912 +585 0.145327 18567 +586 0.146983 20301 +587 0.143022 21953 +588 0.134931 23439 +589 0.121892 24750 +590 0.103955 25688 +591 0.0833804 26253 +592 0.0625106 26918 +593 0.0440419 27279 +594 0.0290823 27159 +595 0.0180758 26786 +596 0.0107654 26049 +597 0.00622673 25202 +598 0.00356716 24168 +599 0.00205866 23122 +600 0.00121254 22076 +601 0.000745744 21100 +602 0.000537789 20207 +603 0.000537982 19340 +604 0.000537795 18527 +605 0.000537955 17768 +606 0.000539259 17117 +607 0.00053942 16425 +608 0.000540477 15701 +609 0.000540424 15134 +610 0.000540084 14558 +611 0.00058571 14069 +612 0.00095364 13498 +613 0.00165505 13054 +614 0.00300205 12616 +615 0.00561724 12142 +616 0.0106079 11720 +617 0.0198178 11410 +618 0.0360368 11231 +619 0.0623418 11314 +620 0.101856 11688 +621 0.15376 12623 +622 0.213046 14078 +623 0.267285 16225 +624 0.299225 18856 +625 0.299517 21756 +626 0.26697 24652 +627 0.2119 27051 +628 0.151393 28925 +629 0.098869 30065 +630 0.0593653 30570 +631 0.0327177 30483 +632 0.0170081 29735 +633 0.0084493 28844 +634 0.00409333 27665 +635 0.00197466 26356 +636 0.000967996 25009 +637 0.000533137 23839 +638 0.000532992 22721 +639 0.000534258 21676 +640 0.000534251 20709 +641 0.000534556 19798 +642 0.000535287 19008 +643 0.000536214 18278 +644 0.000536647 17547 +645 0.000536556 16901 +646 0.000761043 16256 +647 0.00149108 15621 +648 0.00292808 15032 +649 0.0056527 14504 +650 0.0105421 14010 +651 0.0186823 13646 +652 0.0312164 13356 +653 0.0485643 13404 +654 0.0704061 13612 +655 0.0945219 14230 +656 0.117178 15374 +657 0.134568 16843 +658 0.144475 18492 +659 0.146915 20238 +660 0.14393 21958 +661 0.134621 23537 +662 0.121737 24773 +663 0.104744 25772 +664 0.0846226 26427 +665 0.0639754 27040 +666 0.0448457 27279 +667 0.029482 27106 +668 0.0183036 26853 +669 0.0108721 26178 +670 0.00627116 25425 +671 0.0035776 24326 +672 0.00206466 23279 +673 0.00122064 22191 +674 0.000751578 21231 +675 0.000542574 20323 +676 0.000540396 19496 +677 0.000538805 18651 +678 0.00053881 17920 +679 0.000537801 17217 +680 0.000537866 16520 +681 0.000538522 15876 +682 0.000538795 15229 +683 0.000539519 14656 +684 0.000587348 14121 +685 0.000955855 13626 +686 0.00165656 13086 +687 0.00301095 12666 +688 0.00564993 12250 +689 0.0106767 11869 +690 0.0199729 11524 +691 0.03641 11331 +692 0.0632378 11402 +693 0.103483 11788 +694 0.156399 12682 +695 0.215591 14337 +696 0.269462 16547 +697 0.303615 19239 +698 0.304506 22023 +699 0.273068 24769 +700 0.21682 27223 +701 0.154934 29029 +702 0.100495 30241 +703 0.0597382 30801 +704 0.0329221 30881 +705 0.0170591 30288 +706 0.00845353 29329 +707 0.00408176 28108 +708 0.00198037 26715 +709 0.000977102 25340 +710 0.000541566 24039 +711 0.000542333 22965 +712 0.000542417 21858 +713 0.000541182 20952 +714 0.00054038 20049 +715 0.000539725 19192 +716 0.000539603 18409 +717 0.000539754 17700 +718 0.000539679 16960 +719 0.000763508 16287 +720 0.00149327 15637 +721 0.00292609 15057 +722 0.00563308 14524 +723 0.0104893 14003 +724 0.0185874 13625 +725 0.0310985 13319 +726 0.0487417 13278 +727 0.0707124 13502 +728 0.0947795 14147 +729 0.117155 15183 +730 0.133995 16622 diff --git a/third_party/rust/flate2/tests/gunzip.rs b/third_party/rust/flate2/tests/gunzip.rs new file mode 100644 index 0000000000..c3820328af --- /dev/null +++ b/third_party/rust/flate2/tests/gunzip.rs @@ -0,0 +1,77 @@ +extern crate flate2; + +use flate2::read::GzDecoder; +use flate2::read::MultiGzDecoder; +use std::fs::File; +use std::io::prelude::*; +use std::io::{self, BufReader}; +use std::path::Path; + +// test extraction of a gzipped file +#[test] +fn test_extract_success() { + let content = extract_file(Path::new("tests/good-file.gz")).unwrap(); + let mut expected = Vec::new(); + File::open("tests/good-file.txt") + .unwrap() + .read_to_end(&mut expected) + .unwrap(); + assert!(content == expected); +} +// +// test partial extraction of a multistream gzipped file +#[test] +fn test_extract_success_partial_multi() { + let content = extract_file(Path::new("tests/multi.gz")).unwrap(); + let mut expected = String::new(); + BufReader::new(File::open("tests/multi.txt").unwrap()) + .read_line(&mut expected) + .unwrap(); + assert_eq!(content, expected.as_bytes()); +} + +// test extraction fails on a corrupt file +#[test] +fn test_extract_failure() { + let result = extract_file(Path::new("tests/corrupt-gz-file.bin")); + assert_eq!(result.err().unwrap().kind(), io::ErrorKind::InvalidInput); +} + +//test complete extraction of a multistream gzipped file +#[test] +fn test_extract_success_multi() { + let content = extract_file_multi(Path::new("tests/multi.gz")).unwrap(); + let mut expected = Vec::new(); + File::open("tests/multi.txt") + .unwrap() + .read_to_end(&mut expected) + .unwrap(); + assert_eq!(content, expected); +} + +// Tries to extract path into memory (assuming a .gz file). +fn extract_file(path_compressed: &Path) -> io::Result<Vec<u8>> { + let mut v = Vec::new(); + let f = File::open(path_compressed)?; + GzDecoder::new(f).read_to_end(&mut v)?; + Ok(v) +} + +// Tries to extract path into memory (decompressing all members in case +// of a multi member .gz file). +fn extract_file_multi(path_compressed: &Path) -> io::Result<Vec<u8>> { + let mut v = Vec::new(); + let f = File::open(path_compressed)?; + MultiGzDecoder::new(f).read_to_end(&mut v)?; + Ok(v) +} + +#[test] +fn empty_error_once() { + let data: &[u8] = &[]; + let cbjson = GzDecoder::new(data); + let reader = BufReader::new(cbjson); + let mut stream = reader.lines(); + assert!(stream.next().unwrap().is_err()); + assert!(stream.next().is_none()); +} diff --git a/third_party/rust/flate2/tests/multi.gz b/third_party/rust/flate2/tests/multi.gz Binary files differnew file mode 100644 index 0000000000..cabc89630f --- /dev/null +++ b/third_party/rust/flate2/tests/multi.gz diff --git a/third_party/rust/flate2/tests/multi.txt b/third_party/rust/flate2/tests/multi.txt new file mode 100644 index 0000000000..66a52ee7a1 --- /dev/null +++ b/third_party/rust/flate2/tests/multi.txt @@ -0,0 +1,2 @@ +first +second diff --git a/third_party/rust/flate2/tests/zero-write.rs b/third_party/rust/flate2/tests/zero-write.rs new file mode 100644 index 0000000000..f0db86cb8d --- /dev/null +++ b/third_party/rust/flate2/tests/zero-write.rs @@ -0,0 +1,8 @@ +extern crate flate2; + +#[test] +fn zero_write_is_error() { + let mut buf = [0u8]; + let writer = flate2::write::DeflateEncoder::new(&mut buf[..], flate2::Compression::default()); + assert!(writer.finish().is_err()); +} |