Skip to content

Commit

Permalink
more WebSocket tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 3, 2012
1 parent 6b803f9 commit 73234e3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion t/mojo/websocket_frames.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

# "Being eaten by crocodile is just like going to sleep...
# in a giant blender."
use Test::More tests => 98;
use Test::More tests => 105;

use Mojo::Transaction::WebSocket;

Expand Down Expand Up @@ -182,3 +182,16 @@ is $frame->[3], 0, 'rsv3 flag is not set';
is $frame->[4], 8, 'close frame';
is $frame->[5], '', 'no payload';
is $ws->build_frame(1, 0, 0, 0, 8, ''), $bytes, 'frames are equal';

# Masked empty binary frame roundtrip
$ws = Mojo::Transaction::WebSocket->new(masked => 1);
$bytes = $ws->build_frame(1, 0, 0, 0, 2, '');
$frame = $ws->parse_frame(\($dummy = $bytes));
is $frame->[0], 1, 'fin flag is set';
is $frame->[1], 0, 'rsv1 flag is not set';
is $frame->[2], 0, 'rsv2 flag is not set';
is $frame->[3], 0, 'rsv3 flag is not set';
is $frame->[4], 2, 'binary frame';
is $frame->[5], '', 'no payload';
isnt(Mojo::Transaction::WebSocket->new->build_frame(1, 0, 0, 0, 2, ''),
$bytes, 'frames are not equal');

0 comments on commit 73234e3

Please sign in to comment.