testBase64Transcoder.C 1.31 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
// testBase64Transcoder.C
//
////////////////////////////////////////////////////////////////////////////////

#include "Base64Transcoder.h"
#include <iostream>
Francois Gygi committed
21
#include <cassert>
22 23 24 25 26 27 28
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 };
29

30
  Base64Transcoder xcdr;
31

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

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

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

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

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

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

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

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

50
  cout << " done" << endl;
51

52 53
  return 0;
}