aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/tests/int.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-09 17:20:11 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-09 17:20:11 +0000
commitd534a56d95bca7bdd812be024d9eacba4734e2b7 (patch)
treef9b98ee2b80e645a7b54e7934882be6c9f73c165 /c++-libbu++/src/tests/int.cpp
parent61ccc86fdf06f12cb72a8b7e65286f812cf62154 (diff)
downloadlibgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.gz
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.bz2
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.xz
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.zip
Many changes: tabconv'd the C++ code, added a license, BSD, and docs.
Diffstat (limited to 'c++-libbu++/src/tests/int.cpp')
-rw-r--r--c++-libbu++/src/tests/int.cpp65
1 files changed, 36 insertions, 29 deletions
diff --git a/c++-libbu++/src/tests/int.cpp b/c++-libbu++/src/tests/int.cpp
index c19df9c..25ef831 100644
--- a/c++-libbu++/src/tests/int.cpp
+++ b/c++-libbu++/src/tests/int.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "gats/integer.h" 8#include "gats/integer.h"
2 9
3#include <bu/sio.h> 10#include <bu/sio.h>
@@ -8,40 +15,40 @@ using namespace Bu;
8 15
9void hexdump( char *dat, int iSize ) 16void hexdump( char *dat, int iSize )
10{ 17{
11 static const char *hex="0123456789ABCDEF"; 18 static const char *hex="0123456789ABCDEF";
12 printf("----\n"); 19 printf("----\n");
13 for( int j = 0; j < iSize; j += 8 ) 20 for( int j = 0; j < iSize; j += 8 )
14 { 21 {
15 for( int k = j; /*k < iSize &&*/ k < j+8; k++ ) 22 for( int k = j; /*k < iSize &&*/ k < j+8; k++ )
16 printf((k<iSize)?"%c%c ":" ", hex[(dat[k]>>4)&0x0F], hex[dat[k]&0x0F] ); 23 printf((k<iSize)?"%c%c ":" ", hex[(dat[k]>>4)&0x0F], hex[dat[k]&0x0F] );
17 printf("| "); 24 printf("| ");
18 for( int k = j; k < iSize && k < j+8; k++ ) 25 for( int k = j; k < iSize && k < j+8; k++ )
19 printf("%c ", (dat[k]>13&&dat[k]<127)?(dat[k]):('.') ); 26 printf("%c ", (dat[k]>13&&dat[k]<127)?(dat[k]):('.') );
20 printf("\n"); 27 printf("\n");
21 } 28 }
22 printf("----\n"); 29 printf("----\n");
23} 30}
24 31
25int main( int argc, char *argv[] ) 32int main( int argc, char *argv[] )
26{ 33{
27 for( int j = 1; j < argc; j++ ) 34 for( int j = 1; j < argc; j++ )
28 { 35 {
29 int64_t i = strtoll( argv[j], NULL, 10 ); 36 int64_t i = strtoll( argv[j], NULL, 10 );
30 MemBuf mb; 37 MemBuf mb;
31 Gats::Integer::writePackedInt( mb, i ); 38 Gats::Integer::writePackedInt( mb, i );
32 hexdump( mb.getString().getStr(), mb.getString().getSize() ); 39 hexdump( mb.getString().getStr(), mb.getString().getSize() );
33 } 40 }
34/* 41/*
35 sio << "Before: " << i << sio.nl; 42 sio << "Before: " << i << sio.nl;
36 Gats::Integer::writePackedInt( mb, i ); 43 Gats::Integer::writePackedInt( mb, i );
37 mb.write("aaa", 3 ); 44 mb.write("aaa", 3 );
38 mb.setPos( 0 ); 45 mb.setPos( 0 );
39 Gats::Integer::readPackedInt( mb, i ); 46 Gats::Integer::readPackedInt( mb, i );
40 sio << "After: " << i << sio.nl; 47 sio << "After: " << i << sio.nl;
41 char buf[4]; 48 char buf[4];
42 buf[mb.read( buf, 3 )] = '\0'; 49 buf[mb.read( buf, 3 )] = '\0';
43 sio << "Extra: \"" << buf << "\"" << sio.nl; 50 sio << "Extra: \"" << buf << "\"" << sio.nl;
44*/ 51*/
45 return 0; 52 return 0;
46} 53}
47 54