Skip to content

Commit c49f426

Browse files
committed
Merge master into release/1
--HG-- branch : release
2 parents 8d9d24c + cd7ed0f commit c49f426

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+456
-8800
lines changed

.hgtags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
25ee843f907eb7376ad6f1af1aa15d40622062bb release/1-alpha.1
2+
9692febc64935c4c6db640dd9c5c1244dec3d43c release/1-alpha.2

.vscode/c_cpp_properties.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"compilerPath": "/usr/bin/gcc",
66
"includePath": [
77
"${workspaceFolder}",
8-
"${workspaceFolder}/libcppunitx",
9-
"${workspaceFolder}/libltdl"
8+
"${workspaceFolder}/libcppunitx"
109
],
1110
"defines": [
1211
"HAVE_CONFIG_H"
@@ -25,8 +24,7 @@
2524
"intelliSenseMode": "msvc-x64",
2625
"includePath": [
2726
"${workspaceFolder}",
28-
"${workspaceFolder}/libcppunitx",
29-
"${workspaceFolder}/libltdl"
27+
"${workspaceFolder}/libcppunitx"
3028
],
3129
"defines": [
3230
],

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ACLOCAL_AMFLAGS = -Im4
44

55
EXTRA_DIST = README.md
66

7-
SUBDIRS = libltdl libcppunitx test doc
7+
SUBDIRS = libcppunitx test doc
88

99
dist-hook:: $(distdir)/SHA256SUMS
1010
if test -n "$$GPG_USERNAME"; then \

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# this notice are preserved. This file is offered as-is, without any warranty.
77
---
88
variables:
9-
package.distName: cppunitx-1-alpha.2
9+
package.distName: cppunitx-1-alpha.3
1010
trigger:
1111
- master
1212
- release/*

configure.ac

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Process this file with autoconf to produce a configure script.
22
AC_PREREQ([2.69])
3-
AC_INIT([C++UnitX], [1-alpha.2],
3+
AC_INIT([C++UnitX], [1-alpha.3],
44
[https://bitbucket.org/kazssym/cppunitx/issues/new], [cppunitx],
55
[https://www.vx68k.org/cppunitx])
66
AC_CONFIG_SRCDIR([libcppunitx/registry.cpp])
77
AC_CONFIG_AUX_DIR([build-aux])
88
AC_CONFIG_MACRO_DIR([m4])
99
LT_PREREQ([2.4.6])
10-
LT_INIT([dlopen])
11-
LT_CONFIG_LTDL_DIR([libltdl])
12-
LTDL_INIT([recursive])
10+
LT_INIT
1311
AM_INIT_AUTOMAKE([foreign no-define subdir-objects tar-ustar])
1412
# Checks for programs.
1513
AC_PROG_CC
1614
AC_PROG_CXX
1715
# Checks for libraries.
16+
AC_SEARCH_LIBS([dlopen], [dl])
1817
# Checks for header files.
18+
AC_CHECK_HEADERS([dlfcn.h])
1919
# Checks for typedefs, structures, and compiler characteristics.
2020
# Checks for library functions.
21+
AC_CHECK_FUNCS([dlopen])
2122
# Configuration actions.
2223
AC_CONFIG_FILES([Makefile libcppunitx/Makefile
23-
libltdl/Makefile test/Makefile doc/Makefile])
24+
test/Makefile doc/Makefile])
2425
AC_CONFIG_HEADERS([config.h])
2526
AC_OUTPUT

libcppunitx/Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## Process this file with automake to produce Makefile.in.
22

3-
AM_CPPFLAGS = -D_CPPUNITX_IMPLEMENTATION \
4-
$(LTDLINCL)
3+
AM_CPPFLAGS = -D_LIBCPPUNITX
54

65
pkgconfigdir = $(libdir)/pkgconfig
76

@@ -24,17 +23,18 @@ bits/cppunitx/registry.h \
2423
bits/cppunitx/test.h \
2524
bits/cppunitx/driver.h \
2625
bits/cppunitx/module.h
27-
noinst_HEADERS = ltdl_utility.h
26+
noinst_HEADERS = \
27+
module_loader.h
2828

2929
libcppunitx_la_LDFLAGS = -version-info 0:0:0
30-
libcppunitx_la_LIBADD = $(LIBLTDL)
3130
libcppunitx_la_SOURCES = \
3231
exception.cpp \
3332
assertion.cpp \
3433
registry.cpp \
3534
test.cpp \
3635
context.cpp \
37-
driver.cpp
36+
driver.cpp \
37+
module_loader.cpp
3838

3939
CLEANFILES = $(pkgconfig_DATA)
4040

libcppunitx/assertion.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,26 @@
2727

2828
using namespace cppunitx;
2929

30+
void assertion::fail(const char *message)
31+
{
32+
std::string description = "Assertion failed";
33+
if (message != nullptr) {
34+
description.append(": ");
35+
description.append(message);
36+
}
37+
throw AssertionFailedException(description);
38+
}
39+
3040
void assertion::assertNull(const volatile void *ptr, const char *message)
3141
{
3242
if (ptr != nullptr) {
33-
throw AssertionError("Pointer is not null");
43+
fail("Pointer is not null");
3444
}
3545
}
3646

3747
void assertion::assertNotNull(const volatile void *ptr, const char *message)
3848
{
3949
if (ptr == nullptr) {
40-
throw AssertionError("Pointer is null");
50+
fail("Pointer is null");
4151
}
4252
}

libcppunitx/bits/cppunitx.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,19 @@
1919
#ifndef _CPPUNITX_H
2020
#define _CPPUNITX_H 1
2121

22-
#ifndef _CPPUNITX_PUBLIC
2322
#if _WIN32
24-
#if CPPUNITX_DLL || _CPPUNITX_IMPLEMENTATION
23+
#if _LIBCPPUNITX && DLL_EXPORT
2524
#define _CPPUNITX_PUBLIC __declspec(dllexport)
2625
#else
2726
#define _CPPUNITX_PUBLIC __declspec(dllimport)
2827
#endif
29-
#else /* !_WIN32 */
28+
#else /* not _WIN32 */
3029
#if defined __has_attribute
3130
#if __has_attribute(visibility)
3231
#define _CPPUNITX_PUBLIC __attribute__((visibility("default")))
3332
#endif
3433
#endif /* defined __has_attribute */
35-
#endif /* !_WIN32 */
36-
#endif
34+
#endif /* not _WIN32 */
3735

3836
#ifndef _CPPUNITX_PUBLIC
3937
#define _CPPUNITX_PUBLIC

libcppunitx/bits/cppunitx/assert.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,68 @@
2222
#include <bits/cppunitx.h>
2323

2424
#include <memory>
25+
#include <string>
2526
#include <cstdint>
2627

2728
namespace cppunitx
2829
{
2930
namespace assertion
3031
{
32+
/**
33+
* Throws an `AssertionFailedException` object.
34+
*
35+
* @param message a message string to be given to the exception
36+
*/
37+
_CPPUNITX_PUBLIC void fail(const char *message = nullptr);
38+
39+
/**
40+
* Throws an `AssertionFailedException` object.
41+
*
42+
* @param message a message string to be given to the exception
43+
*/
44+
inline void fail(const std::string &message)
45+
{
46+
return fail(message.c_str());
47+
}
48+
49+
template<class T, class U>
50+
void assertEqual(T x, U y, const char *message = nullptr)
51+
{
52+
if (x != y) {
53+
std::string description = "Values must be equal";
54+
if (message != nullptr) {
55+
description.append(": ");
56+
description.append(message);
57+
}
58+
fail(description);
59+
}
60+
}
61+
62+
template<class T, class U>
63+
inline void assertEqual(T x, U y, const std::string &message)
64+
{
65+
assertEqual(x, y, message.c_str());
66+
}
67+
68+
template<class T, class U>
69+
void assertNotEqual(T x, U y, const char *message = nullptr)
70+
{
71+
if (x == y) {
72+
std::string description = "Values must not be equal";
73+
if (message != nullptr) {
74+
description.append(": ");
75+
description.append(message);
76+
}
77+
fail(description);
78+
}
79+
}
80+
81+
template<class T, class U>
82+
inline void assertNotEqual(T x, U y, const std::string &message)
83+
{
84+
assertNotEqual(x, y, message.c_str());
85+
}
86+
3187
_CPPUNITX_PUBLIC void assertNull(const volatile void *ptr,
3288
const char *message = nullptr);
3389

libcppunitx/bits/cppunitx/exception.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,25 @@
2525

2626
namespace cppunitx
2727
{
28-
class _CPPUNITX_PUBLIC AssertionError : public std::runtime_error
28+
class _CPPUNITX_PUBLIC AssertionFailedException: public std::runtime_error
2929
{
3030
using inherited = runtime_error;
3131

3232
public:
33-
explicit AssertionError(const char *message);
33+
explicit AssertionFailedException(const char *message);
3434

35-
explicit AssertionError(const std::string &message);
35+
explicit AssertionFailedException(const std::string &message);
36+
37+
AssertionFailedException(const AssertionFailedException &);
38+
39+
AssertionFailedException &operator =(const AssertionFailedException &);
3640

3741
public:
3842
/// Destructs an `AssertionError` object.
3943
///
4044
/// This destructor is defined out of line so that this class can be
4145
/// provided by a shared library.
42-
virtual ~AssertionError() noexcept;
46+
virtual ~AssertionFailedException() noexcept;
4347
};
4448
}
4549

libcppunitx/bits/cppunitx/module.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@
1919
#ifndef _CPPUNITX_MODULE_H
2020
#define _CPPUNITX_MODULE_H 1
2121

22-
#if !defined SUITE
23-
#error "The required macro 'SUITE' not defined"
22+
#if !defined MODULE
23+
#error "Macro 'MODULE' not defined"
2424
#endif
2525

2626
#include <cppunitx/framework>
2727
#include <bits/cppunitx.h>
2828

2929
#define _CPPUNITX_LT_NAME(M, F) __CPPUNITX_LT_NAME(M, F)
30-
#define __CPPUNITX_LT_NAME(M, F) M ## _LTX_ ## F
30+
#define __CPPUNITX_LT_NAME(M, F) F
3131

32-
#define cppunitx_registry _CPPUNITX_LT_NAME(SUITE, cppunitx_registry)
32+
#define cppunitx_registry _CPPUNITX_LT_NAME(MODULE, cppunitx_registry)
3333

3434
extern "C" cppunitx::TestRegistry *cppunitx_registry();
3535

3636
#if MODULE_MAIN
3737

38-
class SUITE;
38+
class MODULE;
3939

4040
cppunitx::TestRegistry *cppunitx_registry()
4141
{
42-
return cppunitx::TestRegistry::getInstance<class SUITE>().get();
42+
return cppunitx::TestRegistry::getInstance<MODULE>().get();
4343
}
4444

4545
#endif /* MODULE_MAIN */

libcppunitx/bits/cppunitx/registry.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#include <string>
2626
#include <bits/cppunitx.h>
2727

28-
#if defined SUITE
28+
#if defined MODULE
2929
// This makes the suite name available as a type name.
30-
class SUITE;
31-
#define _CPPUNITX_DEFAULT_SUITE class ::SUITE
30+
class MODULE;
31+
#define _CPPUNITX_TEST_SUITE class ::MODULE
3232
#endif
3333

34-
#ifndef _CPPUNITX_DEFAULT_SUITE
35-
#define _CPPUNITX_DEFAULT_SUITE void
34+
#ifndef _CPPUNITX_TEST_SUITE
35+
#define _CPPUNITX_TEST_SUITE void
3636
#endif
3737

3838
namespace cppunitx
@@ -134,7 +134,7 @@ namespace cppunitx
134134
protected:
135135
static std::shared_ptr<TestRegistry> getRegistry()
136136
{
137-
return TestRegistry::getInstance<_CPPUNITX_DEFAULT_SUITE>();
137+
return TestRegistry::getInstance<_CPPUNITX_TEST_SUITE>();
138138
}
139139

140140
public:

libcppunitx/driver.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <locale>
2828
#include <stdexcept>
2929
#include <cstdio>
30-
#include "ltdl_utility.h"
30+
#include "module_loader.h"
3131

3232
using std::string;
3333
using std::exception;
@@ -77,10 +77,13 @@ void TestDriver::run(const char *const suiteName)
7777
{
7878
using GetRegistryFunction = TestRegistry *();
7979

80-
ltdl::library_path path {"."};
81-
ltdl::module suite {suiteName};
80+
std::unique_ptr<ltmodule> suite {new ltmodule(suiteName)};
81+
if (not(*suite)) {
82+
throw runtime_error(string(suiteName) + ": File not loadable");
83+
}
84+
8285
auto getRegistry = reinterpret_cast<GetRegistryFunction *>(
83-
lt_dlsym(suite, "cppunitx_registry"));
86+
suite->sym("cppunitx_registry"));
8487
if (getRegistry == nullptr) {
8588
throw runtime_error(string(suiteName) + ": Not test suite module");
8689
}

libcppunitx/exception.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,35 @@
2424

2525
using namespace cppunitx;
2626

27-
AssertionError::AssertionError(const char *message)
28-
: inherited {message}
27+
AssertionFailedException::AssertionFailedException(const char *message)
28+
:
29+
inherited(message)
2930
{
31+
// Nothing to do.
3032
}
3133

32-
AssertionError::AssertionError(const std::string &message)
33-
: inherited {message}
34+
AssertionFailedException::AssertionFailedException(const std::string &message)
35+
:
36+
inherited(message)
3437
{
38+
// Nothing to do.
3539
}
3640

37-
AssertionError::~AssertionError() noexcept
41+
AssertionFailedException::AssertionFailedException(
42+
const AssertionFailedException &other)
43+
:
44+
inherited(other)
45+
{
46+
// Nothing to do.
47+
}
48+
49+
auto AssertionFailedException::operator =(const AssertionFailedException &other)
50+
-> AssertionFailedException &
51+
{
52+
*(inherited *)this = other;
53+
return *this;
54+
}
55+
56+
AssertionFailedException::~AssertionFailedException() noexcept
3857
{
3958
}

0 commit comments

Comments
 (0)