CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/thrift/thrift_string_spec.rb
Views: 1904
1
# -*- coding: binary -*-
2
require 'spec_helper'
3
require 'rex/text'
4
5
RSpec.describe Rex::Proto::Thrift::ThriftString do
6
let(:value) { Rex::Text.rand_text_alphanumeric(10) }
7
let(:binary_s) { [value.length].pack('N') + value }
8
9
describe '#to_binary_s' do
10
it 'should correctly encode' do
11
expect(described_class.new(value).to_binary_s).to eq binary_s
12
end
13
end
14
15
describe '.read' do
16
it 'should correctly decode' do
17
expect(described_class.read(binary_s)).to eq value
18
end
19
end
20
end
21
22