summaryrefslogtreecommitdiff
path: root/sal/inc
diff options
context:
space:
mode:
authorsz <sz@openoffice.org>2001-09-24 12:31:34 +0000
committersz <sz@openoffice.org>2001-09-24 12:31:34 +0000
commitf087ef032a90bb3aa4daf712eab6be98cd5d6107 (patch)
tree6aa1da3150abe17ae0c6a2761b389da0470f15ef /sal/inc
parent157a9d1026c4a224063acc2dd594bf4205d86d5a (diff)
redesigned TestResult class for implementation hiding
Diffstat (limited to 'sal/inc')
-rw-r--r--sal/inc/rtl/tres.h107
-rw-r--r--sal/inc/rtl/tres.hxx219
2 files changed, 151 insertions, 175 deletions
diff --git a/sal/inc/rtl/tres.h b/sal/inc/rtl/tres.h
new file mode 100644
index 000000000000..45821ddfdf8b
--- /dev/null
+++ b/sal/inc/rtl/tres.h
@@ -0,0 +1,107 @@
+#ifndef _RTL_TRES_H_
+#define _RTL_TRES_H_
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _RTL_STRING_H_
+#include <rtl/string.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* comandline flags */
+#define rtl_tres_Flag_BOOM 0x00000001
+#define rtl_tres_Flag_VERBOSE 0x00000002
+#define rtl_tres_Flag_SKIP 0x00000004
+#define rtl_tres_Flag_LOG 0x00000010
+#define rtl_tres_Flag_HIS 0x00000100
+#define rtl_tres_Flag_TIME 0x00000200
+#define rtl_tres_Flag_MSG 0x00000400
+
+ /* state flags */
+#define rtl_tres_Flag_SUB 0x01000000
+#define rtl_tres_Flag_PASSED 0x10000000
+#define rtl_tres_Flag_OK 0x20000000
+
+ /* forward declaration and type definitions */
+struct _rtl_TestResult;
+typedef struct _rtl_TestResult rtl_TestResult;
+typedef void* rtl_funcstate;
+typedef void* rtl_cmpstate;
+
+ /* type definitions of function pointers wich can be overloaded */
+typedef sal_Bool (SAL_CALL *rtl_tres_state_ptr)(
+ rtl_TestResult*,
+ sal_Bool,
+ const sal_Char*,
+ const sal_Char*,
+ sal_Bool
+ );
+
+typedef void (SAL_CALL *rtl_tres_end_ptr)( rtl_TestResult*, const sal_Char* );
+typedef sal_Bool (SAL_CALL *rtl_tres_ispassed_ptr)( rtl_TestResult* );
+typedef sal_Bool (SAL_CALL *rtl_tres_isok_ptr)( rtl_TestResult* );
+typedef rtl_funcstate (SAL_CALL *rtl_tres_funcstate_ptr)( rtl_TestResult* );
+typedef sal_Bool (SAL_CALL *rtl_tres_isbit_ptr)( rtl_TestResult*,
+ sal_uInt32 );
+
+typedef rtl_funcstate (SAL_CALL *rtl_tres_getnextfuncstate_ptr)
+ ( rtl_funcstate );
+typedef rtl_funcstate (SAL_CALL *rtl_tres_getprevfuncstate_ptr)
+ ( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getflags_ptr)( rtl_funcstate );
+typedef sal_Char* (SAL_CALL *rtl_tres_getname_ptr)( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getstart_ptr)( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getstop_ptr)( rtl_funcstate );
+typedef rtl_cmpstate (SAL_CALL *rtl_tres_getcmpstate_ptr)( rtl_funcstate );
+
+typedef sal_Bool (SAL_CALL *rtl_tres_getstat_ptr)( rtl_cmpstate );
+typedef sal_Char* (SAL_CALL *rtl_tres_getmsg_ptr)( rtl_cmpstate );
+typedef rtl_cmpstate (SAL_CALL *rtl_tres_getnextcmpstate_ptr)( rtl_cmpstate );
+
+
+ /* type definition of vtable structure for testresult */
+typedef struct _rtl_TestResult_vtable
+{
+ sal_uInt32 vtablesize;
+ rtl_tres_state_ptr state_;
+ rtl_tres_end_ptr end_;
+ rtl_tres_ispassed_ptr ispassed;
+ rtl_tres_isok_ptr isok;
+ rtl_tres_funcstate_ptr funcstate;
+ rtl_tres_isbit_ptr isbit;
+ rtl_tres_getnextfuncstate_ptr nextfuncstate;
+ rtl_tres_getprevfuncstate_ptr prevfuncstate;
+ rtl_tres_getflags_ptr flags;
+ rtl_tres_getname_ptr name;
+ rtl_tres_getstart_ptr start;
+ rtl_tres_getstop_ptr stop;
+ rtl_tres_getcmpstate_ptr cmpstate;
+ rtl_tres_getstat_ptr stat;
+ rtl_tres_getmsg_ptr msg;
+ rtl_tres_getnextcmpstate_ptr nextcmpstate;
+
+} rtl_TestResult_vtable;
+
+ /* type definition of testresult structure */
+typedef struct _rtl_TestResult
+{
+ rtl_TestResult_vtable * pFuncs;
+ void * pExternalData;
+
+} rtl_TestResult;
+
+
+ /* exports */
+rtl_TestResult* SAL_CALL rtl_tres_create( const sal_Char* meth, sal_uInt32 flags );
+void SAL_CALL rtl_tres_destroy( rtl_TestResult* res );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TRES_H_ */
diff --git a/sal/inc/rtl/tres.hxx b/sal/inc/rtl/tres.hxx
index 6e6e678671f3..8aa2d3ec9bee 100644
--- a/sal/inc/rtl/tres.hxx
+++ b/sal/inc/rtl/tres.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: tres.hxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: mm $ $Date: 2001-08-22 12:46:46 $
+ * last change: $Author: sz $ $Date: 2001-09-24 13:31:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,216 +62,85 @@
#ifndef _RTL_TRES_HXX_
#define _RTL_TRES_HXX_
-#ifndef _OSL_DIAGNOSE_H_
-#include <osl/diagnose.h>
-#endif
-#include <stdarg.h>
+#ifndef _RTL_TRES_H_
+#include <rtl/tres.h>
+#endif
-//#define TST_BOOM(c, m) OSL_ENSURE(c, m)
+//#include <stdarg.h>
// <namespace_rtl>
-namespace rtl {
-
-class TestResult;
-/** Function prototype of the logging function.
-*/
-typedef void (SAL_CALL * rtl_logPrintf_Function)(
- TestResult *,
- const sal_Bool bTestCaseState,
- const char *pFormatStr, va_list pArgumentList
- );
-
-/**
- Structure to extent the TestResult class in a compatible way.
- Do not relay on the length of this structure. It might be extend
- in future versions.
-*/
-struct TestResultFunction
+namespace rtl
{
- sal_Int32 nStructLength;
- /// If set, the logging is active
- rtl_logPrintf_Function pLogPrintf;
-/*
- TestResultFunction()
- : nStructLength( (sal_Int32)sizeof( TestResultFunction ) )
- {
- }
-*/
-};
-
-
+/*==========================================================================*/
// <class_TestResult>
-class TestResult {
-
- // <private_members>
- sal_Char *m_name;
- sal_Char *m_result;
- sal_Char *m_msg;
- sal_Bool m_state;
- sal_Bool m_boom;
- TestResultFunction *m_pFunctions;
- // </private_members>
+class TestResult
+{
+ // pointer to testresult structure
+ rtl_TestResult* pData;
// <private_ctors>
TestResult();
TestResult( const TestResult& oRes );
// </private_ctors>
- // <private_methods>
- // <method_cpy>
- sal_Char* cpy( sal_Char** dest, const sal_Char* src ) {
-
- if ( *dest ) {
- delete [] *dest;
- }
- *dest = new sal_Char[ ln(src)+1 ];
- // set pointer
- sal_Char* pdest = *dest;
- const sal_Char* psrc = src;
-
- // copy string by char
- while( *pdest++ = *psrc++ );
-
- return ( *dest );
-
- } // </method_cpy>
-
- // <method_cat>
- sal_Char* cat( const sal_Char* str1, const sal_Char* str2 ) {
-
- // allocate memory for destination string
- sal_Char* dest = new sal_Char[ ln(str1)+ln(str2)+1 ];
-
- // set pointers
- sal_Char* pdest = dest;
- const sal_Char* psrc = str1;
-
- // copy string1 by char to dest
- while( *pdest++ = *psrc++ );
- pdest--;
- psrc = str2;
- while( *pdest++ = *psrc++ );
-
- return ( dest );
-
- } // </method_cat>
-
- // <method_ln>
- sal_uInt32 ln( const sal_Char* str ) {
-
- sal_uInt32 len = 0;
- const sal_Char* ptr = str;
-
- if( ptr ) {
- while( *ptr++ ) len++;
- }
-
- return(len);
- } // </method_ln>
-
- // </private_methods>
-
public:
+
// <public_ctors>
- TestResult( const sal_Char* meth, sal_Bool boom = sal_False, TestResultFunction *pFunctions = 0 )
- : m_name(0)
- , m_result(0)
- , m_msg(0)
- , m_state( sal_False )
- , m_boom( boom )
- , m_pFunctions(pFunctions) {
-
- cpy( &m_name, meth );
+ TestResult( const sal_Char* meth, sal_uInt32 flags = 0 )
+ {
+ pData = rtl_tres_create( meth, flags );
} // </public_ctors>
// <dtor>
- ~TestResult() {
- if( m_name )
- delete( m_name );
- if( m_result )
- delete( m_result );
- if( m_msg )
- delete( m_msg );
-
- } // </dtor>
+ ~TestResult()
+ {
+ rtl_tres_destroy( pData );
+ }
+ // </dtor>
// <public_methods>
-
+ rtl_TestResult* getData()
+ {
+ return pData;
+ }
// <method_state>
- inline void state( sal_Bool state, sal_Char* msg = 0 ) {
- m_state = state;
- if( msg ) {
- cpy( &m_msg, msg );
- }
- if( ! state && m_boom ) {
- char * pBoom;
- pBoom = 0;
- *pBoom = 'b';
- //TST_BOOM( m_state, m_msg );
- }
+ sal_Bool state(
+ sal_Bool tst_state,
+ const sal_Char* msg = 0,
+ const sal_Char* sub = 0,
+ sal_Bool verbose = sal_False
+ )
+ {
+ return pData->pFuncs->state_( pData, tst_state, msg, sub, verbose );
} // </method_state>
- // <method_getState>
- inline sal_Bool getState() {
- return m_state;
- } // </method_getState>
+ void end( sal_Char* msg = 0 )
+ {
+ pData->pFuncs->end_( pData, msg );
+ } // </method_state>
+}; // </class_TestResult>
+
+} // </namespace_rtl>
+#endif
+
+
+
- // <method_end>
- inline void end( sal_Char* msg = 0 ) {
- sal_Char* okStr = "#OK#";
- sal_Char* fdStr = "#FAILED#";
- if ( ! msg ) {
- msg = "PASSED";
- }
- if( m_state )
- cpy( &m_result, cat( msg, okStr ) );
- else
- cpy( &m_result, cat( msg, fdStr ) );
- } // </method_end>
- // <method_getName>
- sal_Char* getName() {
- return m_name;
- } // </method_getName>
- // <method_getResult>
- sal_Char* getResult() {
- return m_result;
- } // </method_getResult>
- // <method_getMsg>
- sal_Char* getMsg() {
- return m_msg;
- } // </method_getMsg>
- // <method_logPrintf>
- inline void logPrintf ( const sal_Bool bTestCaseState,
- const char *pFormatStr, ...
- )
- {
- if( m_pFunctions && m_pFunctions->pLogPrintf )
- {
- va_list vArgumentList;
- va_start ( vArgumentList, pFormatStr );
- m_pFunctions->pLogPrintf( this, bTestCaseState, pFormatStr, vArgumentList );
- va_end ( vArgumentList );
- }
- } // </method_logPrintf>
- // </public_methods>
-}; // </class_TestResult>
-} // </namespace_rtl>
-#endif