Sha256: 24d1bcf5242c24ad6c235999e576f163d98f97be75b665bd76531662fb638709
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# encoding: UTF-8 require "spec" require "spec_helper" describe Integer do describe "#bencode" do it "should encode a positive integer" do 1.bencode.should == "i1e" end it "should encode a negative integer" do -1.bencode.should == "i-1e" end it "should encode a positive big integer" do 10_000_000_000.bencode.should == "i10000000000e" end it "should encode a negative big integer" do -10_000_000_000.bencode.should == "i-10000000000e" end end end describe Numeric do describe "#bencode" do it "should encode a positive float with precision loss" do 1.1.bencode.should == "i1e" end it "should encode a negative float with precision loss" do -1.1.bencode.should == "i-1e" end it "should encode an positive exponential float" do 1e10.bencode.should == "i10000000000e" end it "should encode an negative exponential float" do -1e10.bencode.should == "i-10000000000e" end end end describe Time do describe "#bencode" do it "should encode to bencoding" do Time.at(4).bencode.should == "i4e" end end end describe BEncode::Integer do describe "#register" do context "once an object has been registered as a BEncode integer" do before :all do BEncode::Integer.register NilClass end context "an instance of that object" do it "should respond to bencode" do nil.should respond_to :bencode end it "should encode to a bencoded integer" do nil.bencode.should == "i0e" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bencode_blatyo-1.0.1 | spec/bencode/integer_spec.rb |
bencode_blatyo-1.0.0 | spec/bencode/integer_spec.rb |