Make automated FSCommand invocation tests show player-side output.
[gnash.git] / testsuite / libcore.all / CodeStreamTest.cpp
blob485d61697b8199032a4c0535c682b69320b7d6bb
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifdef HAVE_CONFIG_H
20 #include "gnashconfig.h"
21 #endif
23 #include "CodeStream.h"
24 #include "log.h"
26 #include <iostream>
27 #include <sstream>
28 #include <cassert>
29 #include <cmath>
30 #include <string>
32 #include "check.h"
34 #include "utility.h"
36 using namespace gnash;
37 using std::cout;
38 using std::endl;
40 int
41 main(int /*argc*/, char** /*argv*/)
43 char data[10] = {0x4,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9};
45 CodeStream* stream = new CodeStream(std::string(data,10));
47 //Test read_as30p()
48 std::uint8_t opcode;
49 int i = 0;
50 while(opcode = stream->read_as3op()){
51 check_equals(opcode,data[i]);
52 i++;
55 //Make sure we stopped at the right spot.
56 check_equals(i,10);
58 //Reset stream.
59 stream->seekTo(0);
60 stream->clear();
62 //Test seekTo
63 stream->seekTo(5);
65 opcode = stream->read_as3op();
66 check_equals(opcode,data[5]);
68 //Reset stream.
69 stream->seekTo(0);
70 stream->clear();
72 //Test read_u8.
73 i=0;
74 while(i<10){
75 opcode = stream->read_u8();
76 check_equals(opcode,data[i]);
77 i++;
80 char newData[6] = {0x5,0xC5,0x0,0x0,0x1,0x2};
81 CodeStream* streamA = new CodeStream(std::string(newData,6));
83 std::uint8_t byteA = streamA->read_u8();
84 check_equals(byteA,newData[0]);
86 //Test read_S24.
87 std::int32_t byteB = streamA->read_S24();
88 check_equals(byteB,197);
92 return 0;