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