tests: add fake_support

fake_support allows to test compilation of gmio_support
is successful. It provides fake sources of the required
3rd party libraries (Qt and OpenCascade).
Fake sources allows to quickly check if nothing is broken
in gmio_support after API changes.
It will also be useful for CI.
This commit is contained in:
Hugues Delorme 2015-09-02 12:07:17 +02:00
parent 56bb6d8e65
commit 36a4fd281e
15 changed files with 478 additions and 12 deletions

View File

@ -52,12 +52,12 @@ static void occmesh_get_triangle(
meshCookie->mesh()->Triangles(meshCookie->domainId());
const Handle_StlMesh_MeshTriangle& occTri =
occTriangles.Value(tri_id + 1);
Standard_Integer v1;
Standard_Integer v2;
Standard_Integer v3;
Standard_Real xN;
Standard_Real yN;
Standard_Real zN;
int v1;
int v2;
int v3;
double xN;
double yN;
double zN;
occTri->GetVertexAndOrientation(v1, v2, v3, xN, yN, zN);
triangle->normal.x = float(xN);
triangle->normal.y = float(yN);

View File

@ -28,12 +28,12 @@ static gmio_bool_t gmio_stream_qiodevice_at_end(void* cookie)
static int gmio_stream_qiodevice_error(void* cookie)
{
const QIODevice* device = static_cast<QIODevice*>(cookie);
const QFile* file = dynamic_cast<const QFile*>(device);
const QFile* file = qobject_cast<const QFile*>(device);
if (file != NULL) {
return file->error();
}
else {
const QString err_str = static_cast<QIODevice*>(cookie)->errorString();
const QString err_str = device->errorString();
return !err_str.isEmpty() ? 1 : 0;
}
return 0;

View File

@ -41,10 +41,38 @@ add_executable(
test_stl_io.c)
target_link_libraries(test_stl gmio)
# GCC and Clang requires lm
# fake_support
if(GMIO_BUILD_TESTS_FAKE_SUPPORT)
add_executable(
fake_support
EXCLUDE_FROM_ALL
fake_support/main.cpp
fake_support/opencascade/gp_XYZ.hxx
fake_support/opencascade/Handle_StlMesh_Mesh.hxx
fake_support/opencascade/Handle_StlMesh_MeshTriangle.hxx
fake_support/opencascade/StlMesh_Mesh.hxx
fake_support/opencascade/StlMesh_MeshTriangle.hxx
fake_support/opencascade/StlMesh_SequenceOfMeshTriangle.hxx
fake_support/opencascade/TColgp_SequenceOfXYZ.hxx
fake_support/qt/QtCore/QFile
fake_support/qt/QtCore/QIODevice
fake_support/qt/QtCore/QString
fake_support/qt/QtCore/QtGlobal
../src/gmio_support/stl_occ.cpp
../src/gmio_support/stream_qt.cpp)
target_link_libraries(test_stl gmio)
set_property(
TARGET fake_support
APPEND PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/fake_support/opencascade
${CMAKE_CURRENT_SOURCE_DIR}/fake_support/qt)
endif()
# For some targets, GCC and Clang requires -lm
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
target_link_libraries(test_internal m) # -lm
target_link_libraries(test_stl m) # -lm
target_link_libraries(test_internal m)
target_link_libraries(test_stl m)
endif()
# Declare tests
@ -56,4 +84,5 @@ add_dependencies(
check
test_internal
test_platform
test_stl)
test_stl
fake_support)

View File

@ -0,0 +1,18 @@
#include "../../src/gmio_stl/stl_io.h"
#include "../../src/gmio_support/stl_occ.h"
#include <QtCore/QFile>
#include "../../src/gmio_support/stream_qt.h"
int main()
{
// OpenCascade
Handle_StlMesh_Mesh stlMesh;
gmio_stl_occmesh_creator(stlMesh);
// Qt
QFile file;
gmio_stream_qiodevice(&file);
return 0;
}

View File

@ -0,0 +1,18 @@
#ifndef _Handle_StlMesh_Mesh_HeaderFile
#define _Handle_StlMesh_Mesh_HeaderFile
#include <cstddef>
class StlMesh_Mesh;
class Handle_StlMesh_Mesh
{
public:
StlMesh_Mesh* operator->() const
{ return NULL; }
Handle_StlMesh_Mesh& operator=(const StlMesh_Mesh*)
{ return *this; }
};
#endif // _Handle_StlMesh_Mesh_HeaderFile

View File

@ -0,0 +1,15 @@
#ifndef _Handle_StlMesh_MeshTriangle_HeaderFile
#define _Handle_StlMesh_MeshTriangle_HeaderFile
#include <cstddef>
class StlMesh_MeshTriangle;
class Handle_StlMesh_MeshTriangle
{
public:
StlMesh_MeshTriangle* operator->() const
{ return NULL; }
};
#endif // _Handle_StlMesh_MeshTriangle_HeaderFile

View File

@ -0,0 +1,44 @@
#ifndef _StlMesh_Mesh_HeaderFile
#define _StlMesh_Mesh_HeaderFile
#include <Handle_StlMesh_Mesh.hxx>
#include <StlMesh_SequenceOfMeshTriangle.hxx>
#include <TColgp_SequenceOfXYZ.hxx>
class StlMesh_Mesh
{
public:
StlMesh_Mesh()
{ }
virtual void AddDomain()
{ }
virtual int AddTriangle(
const int /*V1*/, const int /*V2*/, const int /*V3*/,
const double /*Xn*/, const double /*Yn*/, const double /*Zn*/)
{ return -1; }
virtual int AddOnlyNewVertex(
const double /*X*/, const double /*Y*/, const double /*Z*/)
{ return -1; }
virtual int NbTriangles(const int DomainIndex) const
{ return 0; }
virtual const StlMesh_SequenceOfMeshTriangle& Triangles(
const int /*DomainIndex = 1*/) const
{
static StlMesh_SequenceOfMeshTriangle triSeq;
return triSeq;
}
virtual const TColgp_SequenceOfXYZ& Vertices(
const int /*DomainIndex = 1*/) const
{
static TColgp_SequenceOfXYZ vertSeq;
return vertSeq;
}
};
#endif // _StlMesh_Mesh_HeaderFile

View File

@ -0,0 +1,15 @@
#ifndef _StlMesh_MeshTriangle_HeaderFile
#define _StlMesh_MeshTriangle_HeaderFile
#include <Handle_StlMesh_MeshTriangle.hxx>
class StlMesh_MeshTriangle
{
public:
void GetVertexAndOrientation(
int& /*V1*/, int& /*V2*/, int& /*V3*/,
double& /*Xn*/, double& /*Yn*/, double& /*Zn*/) const
{ }
};
#endif // _StlMesh_MeshTriangle_HeaderFile

View File

@ -0,0 +1,16 @@
#ifndef _StlMesh_SequenceOfMeshTriangle_HeaderFile
#define _StlMesh_SequenceOfMeshTriangle_HeaderFile
#include <Handle_StlMesh_MeshTriangle.hxx>
class StlMesh_SequenceOfMeshTriangle
{
public:
const Handle_StlMesh_MeshTriangle& Value(const int /*Index*/) const
{
static Handle_StlMesh_MeshTriangle meshTri;
return meshTri;
}
};
#endif // _StlMesh_SequenceOfMeshTriangle_HeaderFile

View File

@ -0,0 +1,16 @@
#ifndef _TColgp_SequenceOfXYZ_HeaderFile
#define _TColgp_SequenceOfXYZ_HeaderFile
#include <gp_XYZ.hxx>
class TColgp_SequenceOfXYZ
{
public:
const gp_XYZ& Value(const int /*Index*/) const
{
static gp_XYZ val;
return val;
}
};
#endif // _TColgp_SequenceOfXYZ_HeaderFile

View File

@ -0,0 +1,17 @@
#ifndef _gp_XYZ_HeaderFile
#define _gp_XYZ_HeaderFile
class gp_XYZ
{
public:
double X() const
{ return 0.; }
double Y() const
{ return 0.; }
double Z() const
{ return 0.; }
};
#endif // _gp_XYZ_HeaderFile

View File

@ -0,0 +1,17 @@
#ifndef QFILE_H
#define QFILE_H
#include <QtCore/QIODevice>
class QFile : public QIODevice
{
public:
enum FileError {
NoError = 0
};
FileError error() const
{ return NoError; }
};
#endif // QFILE_H

View File

@ -0,0 +1,29 @@
#ifndef QIODEVICE_H
#define QIODEVICE_H
#include <QtCore/QtGlobal>
#include <QtCore/QString>
class QIODevice
{
public:
virtual bool atEnd() const
{ return false; }
QString errorString() const
{ return QString(); }
qint64 read(char* /*data*/, qint64 /*maxlen*/)
{ return 0; }
qint64 write(const char* /*data*/, qint64 /*len*/)
{ return 0; }
virtual qint64 size() const
{ return 0; }
virtual bool seek(qint64 /*pos*/)
{ return true; }
};
#endif // QIODEVICE_H

View File

@ -0,0 +1,11 @@
#ifndef QSTRING_H
#define QSTRING_H
class QString
{
public:
bool isEmpty() const
{ return false; }
};
#endif // QSTRING_H

View File

@ -0,0 +1,221 @@
#ifndef QGLOBAL_H
#define QGLOBAL_H
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
#define QT_PREPEND_NAMESPACE(name) name
#define QT_USE_NAMESPACE
template<typename T, typename U>
T qobject_cast(U ptr)
{
return static_cast<T>(ptr);
}
/* BEGIN corelib/global/qsystemdetection.h */
#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
# define Q_OS_DARWIN
# define Q_OS_BSD4
# ifdef __LP64__
# define Q_OS_DARWIN64
# else
# define Q_OS_DARWIN32
# endif
#elif defined(ANDROID)
# define Q_OS_ANDROID
# define Q_OS_LINUX
#elif defined(__CYGWIN__)
# define Q_OS_CYGWIN
#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
# if defined(WINCE) || defined(_WIN32_WCE)
# define Q_OS_WINCE
# elif defined(WINAPI_FAMILY)
# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
# define Q_OS_WINPHONE
# define Q_OS_WINRT
# elif WINAPI_FAMILY==WINAPI_FAMILY_APP
# define Q_OS_WINRT
# else
# define Q_OS_WIN32
# endif
# else
# define Q_OS_WIN32
# endif
#elif defined(__sun) || defined(sun)
# define Q_OS_SOLARIS
#elif defined(hpux) || defined(__hpux)
# define Q_OS_HPUX
#elif defined(__ultrix) || defined(ultrix)
# define Q_OS_ULTRIX
#elif defined(sinix)
# define Q_OS_RELIANT
#elif defined(__native_client__)
# define Q_OS_NACL
#elif defined(__linux__) || defined(__linux)
# define Q_OS_LINUX
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
# ifndef __FreeBSD_kernel__
# define Q_OS_FREEBSD
# endif
# define Q_OS_FREEBSD_KERNEL
# define Q_OS_BSD4
#elif defined(__NetBSD__)
# define Q_OS_NETBSD
# define Q_OS_BSD4
#elif defined(__OpenBSD__)
# define Q_OS_OPENBSD
# define Q_OS_BSD4
#elif defined(__bsdi__)
# define Q_OS_BSDI
# define Q_OS_BSD4
#elif defined(__sgi)
# define Q_OS_IRIX
#elif defined(__osf__)
# define Q_OS_OSF
#elif defined(_AIX)
# define Q_OS_AIX
#elif defined(__Lynx__)
# define Q_OS_LYNX
#elif defined(__GNU__)
# define Q_OS_HURD
#elif defined(__DGUX__)
# define Q_OS_DGUX
#elif defined(__QNXNTO__)
# define Q_OS_QNX
#elif defined(_SEQUENT_)
# define Q_OS_DYNIX
#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */
# define Q_OS_SCO
#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */
# define Q_OS_UNIXWARE
#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */
# define Q_OS_UNIXWARE
#elif defined(__INTEGRITY)
# define Q_OS_INTEGRITY
#elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
# define Q_OS_VXWORKS
#elif defined(__MAKEDEPEND__)
#else
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
#if defined(Q_OS_DARWIN)
# define Q_OS_MAC
# if defined(Q_OS_DARWIN64)
# define Q_OS_MAC64
# elif defined(Q_OS_DARWIN32)
# define Q_OS_MAC32
# endif
# include <TargetConditionals.h>
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
# define Q_OS_IOS
# elif defined(TARGET_OS_MAC) && TARGET_OS_MAC
# define Q_OS_OSX
# define Q_OS_MACX // compatibility synonym
# endif
#endif
#if defined(Q_OS_WIN)
# undef Q_OS_UNIX
#elif !defined(Q_OS_UNIX)
# define Q_OS_UNIX
#endif
#ifdef Q_OS_DARWIN
# include <Availability.h>
# include <AvailabilityMacros.h>
#
# ifdef Q_OS_OSX
# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
# undef __MAC_OS_X_VERSION_MIN_REQUIRED
# define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_6
# endif
# if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
# undef MAC_OS_X_VERSION_MIN_REQUIRED
# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
# endif
# endif
#
# // Numerical checks are preferred to named checks, but to be safe
# // we define the missing version names in case Qt uses them.
#
# if !defined(__MAC_10_7)
# define __MAC_10_7 1070
# endif
# if !defined(__MAC_10_8)
# define __MAC_10_8 1080
# endif
# if !defined(__MAC_10_9)
# define __MAC_10_9 1090
# endif
# if !defined(MAC_OS_X_VERSION_10_7)
# define MAC_OS_X_VERSION_10_7 1070
# endif
# if !defined(MAC_OS_X_VERSION_10_8)
# define MAC_OS_X_VERSION_10_8 1080
# endif
# if !defined(MAC_OS_X_VERSION_10_9)
# define MAC_OS_X_VERSION_10_9 1090
# endif
#
# if !defined(__IPHONE_4_3)
# define __IPHONE_4_3 40300
# endif
# if !defined(__IPHONE_5_0)
# define __IPHONE_5_0 50000
# endif
# if !defined(__IPHONE_5_1)
# define __IPHONE_5_1 50100
# endif
# if !defined(__IPHONE_6_0)
# define __IPHONE_6_0 60000
# endif
# if !defined(__IPHONE_6_1)
# define __IPHONE_6_1 60100
# endif
# if !defined(__IPHONE_7_0)
# define __IPHONE_7_0 70000
# endif
#endif
#ifdef __LSB_VERSION__
# if __LSB_VERSION__ < 40
# error "This version of the Linux Standard Base is unsupported"
# endif
#ifndef QT_LINUXBASE
# define QT_LINUXBASE
#endif
#endif
/* END corelib/global/qsystemdetection.h */
typedef signed char qint8; /* 8 bit signed */
typedef unsigned char quint8; /* 8 bit unsigned */
typedef short qint16; /* 16 bit signed */
typedef unsigned short quint16; /* 16 bit unsigned */
typedef int qint32; /* 32 bit signed */
typedef unsigned int quint32; /* 32 bit unsigned */
#if defined(Q_OS_WIN) && !defined(Q_CC_GNU)
# define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
# define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
typedef __int64 qint64; /* 64 bit signed */
typedef unsigned __int64 quint64; /* 64 bit unsigned */
#else
# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
typedef long long qint64; /* 64 bit signed */
typedef unsigned long long quint64; /* 64 bit unsigned */
#endif
typedef qint64 qlonglong;
typedef quint64 qulonglong;
#endif /* QGLOBAL_H */