~ubuntu-branches/ubuntu/maverick/gnash/maverick

« back to all changes in this revision

Viewing changes to testsuite/libamf.all/test_number.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
3
// 
 
4
// This program is free software; you can redistribute it and/or modify
 
5
// it under the terms of the GNU General Public License as published by
 
6
// the Free Software Foundation; either version 3 of the License, or
 
7
// (at your option) any later version.
 
8
// 
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// GNU General Public License for more details.
 
13
// 
 
14
// You should have received a copy of the GNU General Public License
 
15
// along with this program; if not, write to the Free Software
 
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 
 
18
#ifdef HAVE_CONFIG_H
 
19
#include "gnashconfig.h"
 
20
#endif
 
21
 
 
22
#ifdef HAVE_DEJAGNU_H
 
23
 
 
24
//#include <netinet/in.h>
 
25
#include <string>
 
26
#include <sys/types.h>
 
27
#include <sys/stat.h>
 
28
 
 
29
extern "C"{
 
30
#include <unistd.h>
 
31
#ifdef HAVE_GETOPT_H
 
32
        #include <getopt.h>
 
33
#endif
 
34
#ifndef __GNUC__
 
35
extern int optind, getopt(int, char *const *, const char *);
 
36
#endif
 
37
}
 
38
 
 
39
#include <sys/types.h>
 
40
#include <sys/stat.h>
 
41
#include <fcntl.h>
 
42
#include <log.h>
 
43
#include <iostream>
 
44
#include <string>
 
45
 
 
46
#include "dejagnu.h"
 
47
#include "amf.h"
 
48
#include "element.h"
 
49
 
 
50
using namespace amf;
 
51
using namespace gnash;
 
52
using namespace std;
 
53
 
 
54
static void usage (void);
 
55
 
 
56
static int verbosity;
 
57
 
 
58
static TestState runtest;
 
59
 
 
60
bool test_amf();
 
61
 
 
62
int
 
63
main(int argc, char *argv[])
 
64
{
 
65
    int c;
 
66
 
 
67
    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
 
68
        switch (c) {
 
69
          case 'h':
 
70
            usage ();
 
71
            break;
 
72
            
 
73
          case 'v':
 
74
            verbosity++;
 
75
            break;
 
76
            
 
77
          default:
 
78
            usage ();
 
79
            break;
 
80
        }
 
81
    }
 
82
 
 
83
    test_amf();
 
84
}
 
85
 
 
86
bool
 
87
test_amf()
 
88
{
 
89
    AMF amf_obj;
 
90
    int fd, ret;
 
91
    double num;
 
92
    Element el;
 
93
    boost::uint8_t *ptr;
 
94
    
 
95
    char *buf[AMF_NUMBER_SIZE+1];
 
96
    memset(buf, 0, AMF_NUMBER_SIZE+1);
 
97
    string filespec = SRCDIR;
 
98
    filespec += "/f03f.amf";
 
99
    fd = open(filespec.c_str(), O_RDONLY);
 
100
    ret = read(fd, buf, AMF_NUMBER_SIZE);
 
101
    close(fd);
 
102
 
 
103
//    num = amf_obj.extractNumber(buf);
 
104
    ptr = amf_obj.extractVariable(&el, reinterpret_cast<boost::uint8_t *>(buf));
 
105
    
 
106
    if (el.getType() == Element::NUMBER) {
 
107
        runtest.pass("Extracted Number AMF object");
 
108
    } else {
 
109
        runtest.fail("Extracted Number AMF object");
 
110
    }
 
111
 
 
112
    void *out = amf_obj.encodeNumber(num);
 
113
 
 
114
    if (memcmp(out, buf, 9) == 0) {
 
115
        runtest.pass("Encoded AMF Number");
 
116
    } else {
 
117
        runtest.fail("Encoded AMF Number");
 
118
    }
 
119
}
 
120
 
 
121
static void
 
122
usage (void)
 
123
{
 
124
    cerr << "This program tests Number support in the AMF library." << endl;
 
125
    cerr << "Usage: test_number [hv]" << endl;
 
126
    cerr << "-h\tHelp" << endl;
 
127
    cerr << "-v\tVerbose" << endl;
 
128
    exit (-1);
 
129
}
 
130
 
 
131
#else
 
132
 
 
133
int
 
134
main(int /*argc*/, char /* *argv[]*/)
 
135
{
 
136
  // nop
 
137
  return 0;  
 
138
}
 
139
 
 
140
#endif