Comments (5)
Could you show us test code of this issue ? It is hard to understand without code.
from msgpack-perl.
package GenericPacker;
use strict;
use warnings;
use Data::MessagePack;
sub pack_bean {
my (@stream) = @_;
my $msgpack = Data::MessagePack->new();
my $needed = 1;
$msgpack->prefer_integer();
my $packed_bean = $msgpack->pack( \@stream );
return $packed_bean;
}
sub unpack_bean {
my ($unpackable_bean) = @_;
my $msgpack = Data::MessagePack->new()->utf8(1);
return $msgpack->unpack($unpackable_bean);
}
1;
Is the actual code being tested.
#!/usr/bin/perl -w
use strict;
use warnings;
use Encode qw(decode encode);
use Test::More tests => 1;
use Data::Dumper;
my $actual = TestHelper::create_sample_data();
my $packed_bean = GenericPacker::pack_bean($actual);
my $final = GenericPacker::unpack_bean($packed_bean);
ok(1);
Is the test code
from msgpack-perl.
What is TestHelper
module ?
from msgpack-perl.
Sorry for the number of iterations on the issue. I am providing a sample code similar to my main code, I couldn't link to the main code, because of some policies in my company.
package MainInput;
use strict;
use warnings;
sub new {
my $class = shift;
my $self = {
_field1 => shift,
_field2 => shift,
_field3 => shift
};
bless $self, $class;
return $self;
}
sub set_field1 {
my ( $self, $field1 ) = @_;
$self->{_field1} = $field1 if defined $field1;
}
sub get_field1 {
my ($self) = @_;
return $self->{_field1};
}
sub has_field1 {
my ($self) = @_;
if ( defined $self->{_field1} ) {
return 1;
} else {
return 0;
}
}
sub set_field2 {
my ( $self, $field2 ) = @_;
$self->{_field2} = $field2
if defined $field2;
}
sub get_field2 {
my ($self) = @_;
return $self->{_field2};
}
sub has_field2 {
my ($self) = @_;
if ( defined $self->{_field2} ) {
return 1;
} else {
return 0;
}
}
sub set_field3 {
my ( $self, $field3 ) = @_;
$self->{_field3} = $field3 if defined $field3;
}
sub get_field3 {
my ($self) = @_;
return $self->{_field3};
}
sub has_field3 {
my ($self) = @_;
if ( defined $self->{_field3} ) {
return 1;
} else {
return 0;
}
}
1;
package FieldInput;
use strict;
use warnings;
sub new {
my $class = shift;
my $self = {
_field1 => shift,
_field2 => shift
};
bless $self, $class;
return $self;
}
sub set_field1 {
my ( $self, $field1 ) = @_;
$self->{_field1} = $field1 if defined $field1;
}
sub get_field1 {
my ($self) = @_;
return $self->{_field1};
}
sub has_field1 {
my ($self) = @_;
if ( defined $self->{_field1} ) {
return 1;
} else {
return 0;
}
}
sub set_field2 {
my ( $self, $field2 ) = @_;
$self->{_field2} = $field2
if defined $field2;
}
sub get_field2 {
my ($self) = @_;
return $self->{_field2};
}
sub has_field2 {
my ($self) = @_;
if ( defined $self->{_field2} ) {
return 1;
} else {
return 0;
}
}
1;
Are the Pojo like modules.
package TestHelper;
use constant FIELD1 => 1;
use constant FIELD2 => 2;
use constant FIELD3 => 3;
sub create_sample_input {
my $actual = MainInput->new();
$actual->set_field2( "SomeText" );
my $rpc = FieldInput->new();
$rpc->set_operation( "SomeText" );
$rpc->set_service( "SomeText" );
$actual->set_field1($rpc);
my $auth = FieldInput->new();
$auth->set_encrypted(1);
$auth->set_signed(1);
$actual->set_field3($auth);
return $actual;
}
sub create_sample_value {
my $input = create_sample_input();
@stream = ();
push @stream, [];
if($input->has_field1()) {
push @stream, [FIELD1, [[], [FIELD1, $input->get_field1()->get_field1()], [FIELD2, $input->get_field1()->get_field2()]]];
}
if($input->has_field2()) {
push @stream, [FIELD2, $input->get_field2()];
}
if($input->has_field3()) {
push @stream, [FIELD3, [[], [FIELD1, $input->get_field3()->get_field1()], [FIELD2, $input->get_field3()->get_field2()]]];
}
return \@stream;
}
1;
Is the test helper.
from msgpack-perl.
Your test does not work.
TestHelper::create_sample_data
is not definedFieldInput::set_operation
is not definedFieldInput::set_service
is not definedFieldInput::set_encrypted
is not definedFieldInput::set_signed
is not defined- Your test passes blessed object type to Data::MessagePack methods. Data::MessagePack can take basic data types
- etc
Please create minimized test which works on everywhere. And write failing tests(What value is expected ? What is Data::MessagePack wrong ?). Your test is always passed because it uses only ok(1);
.
from msgpack-perl.
Related Issues (20)
- Cannot communicate with a Haskell based MsgPack RPC server HOT 5
- Invalid type 'Q' in pack at <...> HOT 9
- Minimal Perl version supported HOT 10
- failed test with perl5.19.1? HOT 6
- Use Types::Serialiser::Boolean for true/false HOT 5
- unpack with "extra bytes" HOT 2
- Problem parsing incoming data from Metasploit HOT 20
- Test failing on Mac with perl 5.22.0 HOT 10
- No msgpack in alpine HOT 6
- New Str encoding broke compatibility with 0.49 decoding HOT 5
- Support IEEE 754 HOT 3
- Potential issue in casting numbers HOT 2
- Fails Makefile.PL with no '.' in @INC HOT 1
- Should prefer IV when both IV and NV are OK HOT 1
- Can't install under strawberry perl 5.30.0 HOT 3
- Hook for blessed variables HOT 1
- FAIL under -Dusequadmath HOT 1
- Deserialization Error with MessagePack JavaScript Libraries HOT 4
- trying to unpack MessagePack from C failing with "extra bytes (length should be 145)" message HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-perl.