source: trunk/include/Arm4DbTest.h @ 704

Revision 614, 4.6 KB checked in by dcarter, 4 years ago (diff)

see #111 - Build beta3

Line 
1/**********************************************************************
2 * Copyright (c) 2005-2008 David Carter <dcarter@arm4.org> and others.
3 * All rights reserved.   This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * David Carter - Initial API and implementation
10 **********************************************************************/
11
12#ifndef LIBARM4DBTEST_H /* Prevent multiple inclusion */
13#define LIBARM4DBTEST_H 1
14
15#include "Arm4db.h"
16#include "Arm4DbTestDaemon.h"
17
18#if LONG_MAX == 2147483647l
19#define UNINITIALIZED_HANDLE 0x1234567890123456ll
20#else
21#define UNINITIALIZED_HANDLE 0x1234567890123456l
22#endif
23
24class Arm4DbTest {
25public:
26        /* Constructors */
27        Arm4DbTest (const std::string &testProgramName);
28        Arm4DbTest (const std::string &config_name, const std::string &testProgramName);
29        Arm4DbTest ();
30
31        /* Destructors */
32        virtual ~Arm4DbTest ();
33
34        /* Accessors */
35        const std::string &getTest (void) const { return m_testName; }
36        const std::string &getTestGroup (void) const { return m_testGroupName; }
37        int getPassCount (void) const { return m_passCount; }
38        int getFailCount (void) const { return m_failCount; }
39
40        /* Mutators */
41        void setTest (const std::string &name) { m_testName = name; }
42        void clearTest (void) { m_testName = ""; }
43        void setTestGroup (const std::string &name) { m_testGroupName = name; }
44        void clearTestGroup (void) { m_testGroupName = ""; }
45        void clearCounters (void) { m_passCount = m_failCount = 0; }
46
47        /* Operations */
48        void setInstance (void);
49        void assertFailed (const std::string &description);
50        void assertPassed (const std::string &description);
51        bool assertPass (const std::string &description, int result) { return assertPass (description, (bool) result); }
52        bool assertPass (const std::string &description, bool result);
53        bool assertFail (const std::string &description, int result) { return assertFail (description, (bool) result); }
54        bool assertFail (const std::string &description, bool result);
55        bool assertEqual (const std::string &description, int result1, int result2);
56        bool assertEqual (const std::string &description, const std::string &result1, const std::string &result2);
57        bool assertEqual (const std::string &description, const arm_id_t &id1, const arm_id_t &id2);
58        bool assertNotEqual (const std::string &description, int result1, int result2);
59        bool assertNotEqual (const std::string &description, const std::string &result1, const std::string &result2);
60        bool assertNotEqual (const std::string &description, const arm_id_t &id1, const arm_id_t &id2);
61        bool assertEmpty (const std::string &description, const arm_id_t &id);
62        bool assertEmpty (const std::string &description, const arm_int64_t handle);
63        bool assertNotEmpty (const std::string &description, const arm_id_t &id);
64        bool assertNotEmpty (const std::string &description, const arm_int64_t handle);
65        bool assertValid (const std::string &description, const arm_id_t &id);
66        bool assertValid (const std::string &description, const arm_int64_t handle);
67        bool assertNotValid (const std::string &description, const arm_id_t &id);
68        bool assertNotValid (const std::string &description, const arm_int64_t handle);
69        bool assertNull (const std::string &description, const void *data_ptr);
70        bool assertNotNull (const std::string &description, const void *data_ptr);
71
72        void validateExports (Arm4DbTestDaemon &daemon);
73
74        void showResults (void) const;
75
76        static bool equal (const arm_id_t &id1, const arm_id_t &id2);
77        static bool empty (const arm_id_t &id);
78        static bool empty (const arm_int64_t handle);
79        static bool valid (const arm_id_t &id);
80        static bool valid (const arm_int64_t handle);
81        static void print (const arm_id_t &id);
82        static void initializeId (arm_id_t &id);
83        static void initializeHandle (arm_int64_t &handle);
84
85        static std::string testString (const char *string_ptr, int max_length);
86
87        /* Operators */
88
89protected:
90
91private:
92        /* Mark these as private to prevent their use */
93        Arm4DbTest (const Arm4DbTest &);
94        Arm4DbTest &operator= (const Arm4DbTest &);
95
96        const Arm4dbConfig &getConfig (void) { return Arm4dbConfig::getConfig (); }
97
98        void importTest (const std::string &testName, const std::string &reference_xml, Arm4DbTestDaemon &daemon);
99        void importDefinitionsTest (const std::string &testName, const std::string &reference_xml, Arm4DbTestDaemon &daemon);
100
101        std::string m_testName;
102        std::string m_testGroupName;
103        std::string m_testProgramName;
104        int m_passCount;
105        int m_failCount;
106
107        static arm_id_t m_fill;
108};
109
110#endif /* LIBARM4DBTEST_H */
Note: See TracBrowser for help on using the repository browser.