testBase64Transcoder.C 1.29 KB
Newer Older
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
15 16 17 18 19 20 21 22 23 24 25 26 27
// testBase64Transcoder.C
//
////////////////////////////////////////////////////////////////////////////////

#include "Base64Transcoder.h"
#include <iostream>
using namespace std;

int main()
{
  const int n = 7;
  double a[n] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
  double c[n] = { 0, 0, 0, 0, 0, 0, 0 };
28

29
  Base64Transcoder xcdr;
30

31
  int nbytes = n * sizeof(double);
32

33
  int nchars = xcdr.nchars(nbytes);
34

35 36
  cout << " nbytes=" << nbytes << endl;
  cout << " nchars=" << nchars << endl;
37

38
  char* b = new char[nchars];
39

40
  xcdr.encode(nbytes,(unsigned char*) &a[0],b);
41

42
  cout << " b=" << b << endl;
43

44
  xcdr.decode(nchars,b,(unsigned char*) &c[0]);
45

46 47
  for ( int i = 0; i < n; i++ )
    assert(a[i]==c[i]);
48

49
  cout << " done" << endl;
50

51 52
  return 0;
}