diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/library/zlib/adler32_spec.rb | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) | |
download | ruby-1d15d5f08032acf1b7bceacbb450d617ff6e0931.tar.gz |
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
[Misc #13792] [ruby-core:82287]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/zlib/adler32_spec.rb')
-rw-r--r-- | spec/ruby/library/zlib/adler32_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/ruby/library/zlib/adler32_spec.rb b/spec/ruby/library/zlib/adler32_spec.rb new file mode 100644 index 0000000000..1767dc2011 --- /dev/null +++ b/spec/ruby/library/zlib/adler32_spec.rb @@ -0,0 +1,46 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'zlib' + +describe "Zlib.adler32" do + it "calculates Adler checksum for string" do + Zlib.adler32("").should == 1 + Zlib.adler32(" ").should == 2162721 + Zlib.adler32("123456789").should == 152961502 + Zlib.adler32("!@#\{$\}%^&**()").should == 365495023 + Zlib.adler32("to be or not to be" * 22).should == 3979904837 + Zlib.adler32("0").should == 3211313 + Zlib.adler32((2**32).to_s).should == 193331739 + Zlib.adler32((2**64).to_s).should == 723452953 + end + + it "calculates Adler checksum for string and initial Adler value" do + test_string = "This is a test string! How exciting!%?" + Zlib.adler32(test_string, 0).should == 63900955 + Zlib.adler32(test_string, 1).should == 66391324 + Zlib.adler32(test_string, 2**8).should == 701435419 + Zlib.adler32(test_string, 2**16).should == 63966491 + lambda { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError) + end + + it "calculates the Adler checksum for string and initial Adler value for Bignums" do + test_string = "This is a test string! How exciting!%?" + Zlib.adler32(test_string, 2**30).should == 1137642779 + end + + it "assumes that the initial value is given to adler, if adler is omitted" do + orig_crc = Zlib.adler32 + Zlib.adler32("").should == Zlib.adler32("", orig_crc) + Zlib.adler32(" ").should == Zlib.adler32(" ", orig_crc) + Zlib.adler32("123456789").should == Zlib.adler32("123456789", orig_crc) + Zlib.adler32("!@#\{$\}%^&**()").should == Zlib.adler32("!@#\{$\}%^&**()", orig_crc) + Zlib.adler32("to be or not to be" * 22).should == Zlib.adler32("to be or not to be" * 22, orig_crc) + Zlib.adler32("0").should == Zlib.adler32("0", orig_crc) + Zlib.adler32((2**32).to_s).should == Zlib.adler32((2**32).to_s, orig_crc) + Zlib.adler32((2**64).to_s).should == Zlib.adler32((2**64).to_s, orig_crc) + end + + it "it returns the CRC initial value, if string is omitted" do + Zlib.adler32.should == 1 + end + +end |