Sha256: 893f10f877c53a1cd2263a8ec0790941fc4f6772850776506256ad8d03f94d7c
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
require 'spec_helper' require 'ronin/formatting/extensions/binary/base64' describe Base64 do subject { described_class } if RUBY_VERSION < '1.9.' let(:string) { '>' * 64 } let(:base64) { "Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+\nPj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pg==\n" } let(:strict_base64) { "Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pg==" } let(:urlsafe_base64) { "Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pg==" } describe "strict_encode64" do it "should strictly encode a String" do expect(subject.strict_encode64(string)).to eq(strict_base64) end end describe "strict_decode64" do it "should strict decode an encoded Base64 String" do expect(subject.strict_decode64(strict_base64)).to eq(string) end it "should raise an ArgumentError for non-strictly encoded Base64" do expect { subject.strict_decode64(base64) }.to raise_error(ArgumentError) end end describe "urlsafe_encode64" do it "should encode URL-safe Base64 Strings" do expect(subject.urlsafe_encode64(string)).to eq(urlsafe_base64) end end describe "urlsafe_decode64" do it "should decode URL-safe Base64 String" do expect(subject.urlsafe_decode64(urlsafe_base64)).to eq(string) end it "should raise an ArgumentError for non-strictly encoded Base64" do expect { subject.urlsafe_decode64(base64) }.to raise_error(ArgumentError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ronin-support-0.5.2 | spec/formatting/binary/base64_spec.rb |