Sha256: 162e743a502607e4e03eb6af277326419436532a7261c22df7a44a14628d1cc2
Contents?: true
Size: 941 Bytes
Versions: 3
Compression:
Stored size: 941 Bytes
Contents
require 'dirge' require ~'spec_helper' describe Anybase, "to" do it "should translate base to a number from a string " do Anybase.new("012345678").to_native(1827).should == "2450" end it "should never return an empty string for 0" do Anybase.new("012345678").to_native(0).should == "0" end it "should zeropad" do result = Anybase.new("012345678").to_native(1234, :zero_pad => 8) result.size.should == 8 result.should == '00001621' end it "create random numbers" do srand(10) result = Anybase.new("012345678").random(10) result.should == '4010180864' srand(39) Anybase.new("012345678").random(10, :zero_pad => false).should == '463048140' end it "return a zero if thats all it can for a random number" do result = Anybase.new("0").random(10) result.should == '0000000000' result = Anybase.new("0").random(10, :zero_pad => false) result.should == '0' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
anybase-0.0.10 | spec/to_spec.rb |
anybase-0.0.9 | spec/to_spec.rb |
anybase-0.0.8 | spec/to_spec.rb |