More stuff and tests integrated

This commit is contained in:
Emmanuel BENOîT 2017-11-01 22:07:41 +01:00
parent ccd7cc30ef
commit b9d77922ed
16 changed files with 92 additions and 119 deletions

View file

@ -2,11 +2,11 @@
/* FILES **********************************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_FILES
#define _H_LW_LIB_FILES
#include <lw/lib/Streams.hh>
#include <lw/lib/Strings.hh>
namespace lw {
#ifndef _H_EBCL_FILES
#define _H_EBCL_FILES
#include <ebcl/Streams.hh>
#include <ebcl/Strings.hh>
namespace ebcl {
/*= FILE ACCESS ==============================================================*/
@ -183,5 +183,5 @@ M_CLASS_POINTERS( FileOutputStream );
}
#endif // _H_LW_LIB_FILES
#include <lw/lib/inline/Files.hh>
#endif // _H_EBCL_FILES
#include <ebcl/inline/Files.hh>

View file

@ -2,9 +2,10 @@
/* MEMORY STREAMS *************************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Streams.hh>
namespace lw {
#ifndef _H_EBCL_MEMORYSTREAMS
#define _H_EBCL_MEMORYSTREAMS
#include <ebcl/Streams.hh>
namespace ebcl {
class T_MemoryInputStream final : public A_InputStream
@ -59,4 +60,5 @@ M_CLASS_POINTERS( MemoryOutputStream );
} // namespace
#include <lw/lib/inline/MemoryStreams.hh>
#include <ebcl/inline/MemoryStreams.hh>
#endif // _H_EBCL_MEMORYSTREAMS

View file

@ -232,7 +232,7 @@ template< typename T >
// M_DEFINE_SWAP( Type ) - Define the swap function for a given type
#define M_DEFINE_SWAP( Type ) \
void lw::swap( Type& lhs , Type& rhs ) noexcept
void swap( Type& lhs , Type& rhs ) noexcept
/*= ENDIAN DETECTION =========================================================*/

View file

@ -2,10 +2,10 @@
/* FILES - INLINE CODE ********************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_FILES
#define _H_LW_LIB_INLINE_FILES
#include <lw/lib/Files.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_FILES
#define _H_EBCL_INLINE_FILES
#include <ebcl/Files.hh>
namespace ebcl {
/*= T_File ===================================================================*/
@ -96,4 +96,4 @@ inline size_t T_FileOutputStream::offset( ) const noexcept
} // namespace
#endif // _H_LW_LIB_INLINE_FILES
#endif // _H_EBCL_INLINE_FILES

View file

@ -2,9 +2,10 @@
/* MEMORY STREAMS - INLINE CODE ***********************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/MemoryStreams.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_MEMORYSTREAMS
#define _H_EBCL_INLINE_MEMORYSTREAMS
#include <ebcl/MemoryStreams.hh>
namespace ebcl {
/*= T_MemoryInputStream ======================================================*/
@ -41,3 +42,4 @@ inline T_MemoryOutputStream::T_MemoryOutputStream( T_Buffer< T >& buffer )
} // namespace
#endif // _H_EBCL_INLINE_MEMORYSTREAMS

View file

@ -3,8 +3,8 @@
/******************************************************************************/
#include <lw/lib/Files.hh>
using namespace lw;
#include <ebcl/Files.hh>
using namespace ebcl;
/*= T_File ==================================================================*/
@ -41,20 +41,17 @@ void T_File::open( )
const T_Buffer< char > path( path_.toOSString( ) );
// Select the right mode
char const* mode;
switch ( mode_ ) {
case E_FileMode::READ_ONLY:
mode = "rb";
break;
case E_FileMode::READ_WRITE:
mode = "rb+";
break;
case E_FileMode::OVERWRITE:
mode = "wb+";
break;
}
char const* const mode( ([this]() {
switch ( mode_ ) {
case E_FileMode::READ_ONLY:
return "rb";
case E_FileMode::READ_WRITE:
return "rb+";
case E_FileMode::OVERWRITE:
return "wb+";
}
std::abort( );
})( ) );
// Open the file
#ifdef WIN32_

View file

@ -2,8 +2,8 @@
/* MEMORY STREAMS *************************************************************/
/******************************************************************************/
#include <lw/lib/MemoryStreams.hh>
using namespace lw;
#include <ebcl/MemoryStreams.hh>
using namespace ebcl;
/*= T_MemoryInputStream ======================================================*/

View file

@ -1,5 +1,7 @@
LIB_SOURCES = \
src/Files.cc \
src/HashIndex.cc \
src/MemoryStreams.cc \
src/Pointers.cc \
src/Streams.cc \
src/Strings.cc \
@ -8,8 +10,6 @@ LIB_SOURCES = \
# END
#
# src/Files.cc \
# src/MemoryStreams.cc \
# src/SRDBinary.cc \
# src/SRDData.cc \
# src/SRDDefinitions.cc \

View file

@ -1,10 +1,11 @@
#include <lw/lib/BinaryStreams.hh>
#include <lw/lib/MemoryStreams.hh>
#include <ebcl/BinaryStreams.hh>
#include <ebcl/MemoryStreams.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
/* - StreamReaderTest ---------------------------------------------------{{{-*/
/* - StreamReaderTest -------------------------------------------------------*/
class StreamReaderTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( StreamReaderTest );
@ -40,7 +41,7 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION( StreamReaderTest );
void StreamReaderTest::testNumericBigEndian8( ) // {{{
void StreamReaderTest::testNumericBigEndian8( )
{
const uint8_t data[] = { 0x12 };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -49,8 +50,7 @@ void StreamReaderTest::testNumericBigEndian8( ) // {{{
rd.readNumericBigEndian< uint8_t >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian8( ) // {{{
void StreamReaderTest::testNumericLittleEndian8( )
{
const uint8_t data[] = { 0x12 };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -59,8 +59,7 @@ void StreamReaderTest::testNumericLittleEndian8( ) // {{{
rd.readNumericLittleEndian< uint8_t >( ) );
}
// }}}
void StreamReaderTest::testNumericBigEndian16( ) // {{{
void StreamReaderTest::testNumericBigEndian16( )
{
const uint8_t data[] = { 0xbe , 0xef };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -69,8 +68,7 @@ void StreamReaderTest::testNumericBigEndian16( ) // {{{
rd.readNumericBigEndian< uint16_t >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian16( ) // {{{
void StreamReaderTest::testNumericLittleEndian16( )
{
const uint8_t data[] = { 0xbe , 0xef };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -79,8 +77,7 @@ void StreamReaderTest::testNumericLittleEndian16( ) // {{{
rd.readNumericLittleEndian< uint16_t >( ) );
}
// }}}
void StreamReaderTest::testNumericBigEndian32( ) // {{{
void StreamReaderTest::testNumericBigEndian32( )
{
const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -89,8 +86,7 @@ void StreamReaderTest::testNumericBigEndian32( ) // {{{
rd.readNumericBigEndian< uint32_t >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian32( ) // {{{
void StreamReaderTest::testNumericLittleEndian32( )
{
const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -99,8 +95,7 @@ void StreamReaderTest::testNumericLittleEndian32( ) // {{{
rd.readNumericLittleEndian< uint32_t >( ) );
}
// }}}
void StreamReaderTest::testNumericBigEndian32f( ) // {{{
void StreamReaderTest::testNumericBigEndian32f( )
{
const uint8_t data[] = { 0x3f , 0x80 , 0x00 , 0x00 };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -108,8 +103,7 @@ void StreamReaderTest::testNumericBigEndian32f( ) // {{{
CPPUNIT_ASSERT_EQUAL( 1.0f , rd.readNumericBigEndian< float >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian32f( ) // {{{
void StreamReaderTest::testNumericLittleEndian32f( )
{
const uint8_t data[] = { 0x00 , 0x00 , 0x80 , 0x3f };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -117,8 +111,7 @@ void StreamReaderTest::testNumericLittleEndian32f( ) // {{{
CPPUNIT_ASSERT_EQUAL( 1.0f , rd.readNumericLittleEndian< float >( ) );
}
// }}}
void StreamReaderTest::testNumericBigEndian64( ) // {{{
void StreamReaderTest::testNumericBigEndian64( )
{
const uint8_t data[] = {
0xba , 0xdb , 0xa7 , 0x5e , 0xa7 , 0xba , 0xb1 , 0x35
@ -129,8 +122,7 @@ void StreamReaderTest::testNumericBigEndian64( ) // {{{
rd.readNumericBigEndian< uint64_t >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian64( ) // {{{
void StreamReaderTest::testNumericLittleEndian64( )
{
const uint8_t data[] = {
0x35 , 0xb1 , 0xba , 0xa7 , 0x5e , 0xa7 , 0xdb , 0xba ,
@ -141,8 +133,7 @@ void StreamReaderTest::testNumericLittleEndian64( ) // {{{
rd.readNumericLittleEndian< uint64_t >( ) );
}
// }}}
void StreamReaderTest::testNumericBigEndian64f( ) // {{{
void StreamReaderTest::testNumericBigEndian64f( )
{
const uint8_t data[] = { 0x3f , 0xf0 , 0 , 0 , 0 , 0 , 0 , 0 };
T_MemoryInputStream ms( data , sizeof( data ) );
@ -150,15 +141,10 @@ void StreamReaderTest::testNumericBigEndian64f( ) // {{{
CPPUNIT_ASSERT_EQUAL( 1.0 , rd.readNumericBigEndian< double >( ) );
}
// }}}
void StreamReaderTest::testNumericLittleEndian64f( ) // {{{
void StreamReaderTest::testNumericLittleEndian64f( )
{
const uint8_t data[] = { 0 , 0 , 0 , 0 , 0 , 0 , 0xf0 , 0x3f };
T_MemoryInputStream ms( data , sizeof( data ) );
T_BinaryReader rd( ms );
CPPUNIT_ASSERT_EQUAL( 1.0 , rd.readNumericLittleEndian< double >( ) );
}
// }}}
/*------------------------------------------------------------------------}}}-*/

View file

@ -1,10 +1,11 @@
#include <lw/lib/BinaryStreams.hh>
#include <lw/lib/MemoryStreams.hh>
#include <ebcl/BinaryStreams.hh>
#include <ebcl/MemoryStreams.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
/* - BinaryWriterTest ---------------------------------------------------{{{-*/
/* - BinaryWriterTest -------------------------------------------------------*/
class BinaryWriterTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( BinaryWriterTest );
@ -40,7 +41,7 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION( BinaryWriterTest );
void BinaryWriterTest::testNumericBigEndian8( ) // {{{
void BinaryWriterTest::testNumericBigEndian8( )
{
const uint8_t data[] = { 0x12 };
T_Buffer< uint8_t > buffer;
@ -54,8 +55,7 @@ void BinaryWriterTest::testNumericBigEndian8( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian8( ) // {{{
void BinaryWriterTest::testNumericLittleEndian8( )
{
const uint8_t data[] = { 0x12 };
T_Buffer< uint8_t > buffer;
@ -69,8 +69,7 @@ void BinaryWriterTest::testNumericLittleEndian8( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericBigEndian16( ) // {{{
void BinaryWriterTest::testNumericBigEndian16( )
{
const uint8_t data[] = { 0xbe , 0xef };
T_Buffer< uint8_t > buffer;
@ -84,8 +83,7 @@ void BinaryWriterTest::testNumericBigEndian16( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian16( ) // {{{
void BinaryWriterTest::testNumericLittleEndian16( )
{
const uint8_t data[] = { 0xbe , 0xef };
T_Buffer< uint8_t > buffer;
@ -99,8 +97,7 @@ void BinaryWriterTest::testNumericLittleEndian16( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericBigEndian32( ) // {{{
void BinaryWriterTest::testNumericBigEndian32( )
{
const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef };
T_Buffer< uint8_t > buffer;
@ -114,8 +111,7 @@ void BinaryWriterTest::testNumericBigEndian32( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian32( ) // {{{
void BinaryWriterTest::testNumericLittleEndian32( )
{
const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef };
T_Buffer< uint8_t > buffer;
@ -129,8 +125,7 @@ void BinaryWriterTest::testNumericLittleEndian32( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericBigEndian32f( ) // {{{
void BinaryWriterTest::testNumericBigEndian32f( )
{
const uint8_t data[] = { 0x3f , 0x80 , 0x00 , 0x00 };
T_Buffer< uint8_t > buffer;
@ -144,8 +139,7 @@ void BinaryWriterTest::testNumericBigEndian32f( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian32f( ) // {{{
void BinaryWriterTest::testNumericLittleEndian32f( )
{
const uint8_t data[] = { 0x00 , 0x00 , 0x80 , 0x3f };
T_Buffer< uint8_t > buffer;
@ -159,8 +153,7 @@ void BinaryWriterTest::testNumericLittleEndian32f( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericBigEndian64( ) // {{{
void BinaryWriterTest::testNumericBigEndian64( )
{
const uint8_t data[] = {
0xba , 0xdb , 0xa7 , 0x5e , 0xa7 , 0xba , 0xb1 , 0x35
@ -176,8 +169,7 @@ void BinaryWriterTest::testNumericBigEndian64( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian64( ) // {{{
void BinaryWriterTest::testNumericLittleEndian64( )
{
const uint8_t data[] = {
0x35 , 0xb1 , 0xba , 0xa7 , 0x5e , 0xa7 , 0xdb , 0xba ,
@ -193,8 +185,7 @@ void BinaryWriterTest::testNumericLittleEndian64( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericBigEndian64f( ) // {{{
void BinaryWriterTest::testNumericBigEndian64f( )
{
const uint8_t data[] = { 0x3f , 0xf0 , 0 , 0 , 0 , 0 , 0 , 0 };
T_Buffer< uint8_t > buffer;
@ -208,8 +199,7 @@ void BinaryWriterTest::testNumericBigEndian64f( ) // {{{
}
}
// }}}
void BinaryWriterTest::testNumericLittleEndian64f( ) // {{{
void BinaryWriterTest::testNumericLittleEndian64f( )
{
const uint8_t data[] = { 0 , 0 , 0 , 0 , 0 , 0 , 0xf0 , 0x3f };
T_Buffer< uint8_t > buffer;
@ -222,7 +212,3 @@ void BinaryWriterTest::testNumericLittleEndian64f( ) // {{{
CPPUNIT_ASSERT_EQUAL( data[ i ] , buffer[ i ] );
}
}
// }}}
/*------------------------------------------------------------------------}}}-*/

View file

@ -1,6 +1,6 @@
#include <lw/lib/Buffers.hh>
#include <ebcl/Buffers.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class FixedBufferTest : public CppUnit::TestFixture

View file

@ -1,4 +1,5 @@
TESTS = \
buffers \
ptr-owned \
ptr-shared \
ptr-weak \
@ -8,6 +9,12 @@ TESTS = \
arrays-static-objects \
arrays-auto \
arrays-multi \
strings \
strings-iterator \
strings-storage \
strings-builder \
binary-reader \
binary-writer \
optional \
union \
variant \
@ -18,14 +25,7 @@ TESTS = \
#TESTS = \
# alloc-pool \
# buffers \
# ring-buffer \
# strings \
# strings-iterator \
# strings-storage \
# strings-builder \
# binary-reader \
# binary-writer \
# stream-file-input \
# srd-bin-reader \
# srd-bin-writer \

View file

@ -1,7 +1,7 @@
#include <lw/lib/Strings.hh>
#include <ebcl/Strings.hh>
#include <limits>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class StringsBuilderTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Strings.hh>
#include <ebcl/Strings.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class StringsIteratorTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Strings.hh>
#include <ebcl/Strings.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
/*= StringsDynamicTest ========================================================*/

View file

@ -1,6 +1,6 @@
#include <lw/lib/Strings.hh>
#include <ebcl/Strings.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class StringsTest : public CppUnit::TestFixture