Skip to content

Commit

Permalink
DEBUG: revert to using UnicodeString ...
Browse files Browse the repository at this point in the history
  • Loading branch information
roubert committed Dec 30, 2024
1 parent 34917a7 commit d2f4a03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion icu4c/source/tools/ctestfw/tstdtmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@
#include <stdarg.h>

#include "unicode/tstdtmod.h"
#include "unicode/unistr.h"
#include "cmemory.h"
#include <stdio.h>
#include "cstr.h"
#include "cstring.h"

TestLog::~TestLog() {}

IcuTestErrorCode::IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName)
: errorCode(U_ZERO_ERROR),
testClass(callingTestClass), testName(callingTestName), scopeMessage(new UnicodeString) {
if (scopeMessage == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
}
}

IcuTestErrorCode::~IcuTestErrorCode() {
// Safe because our errlog() does not throw exceptions.
if(isFailure()) {
errlog(false, u"destructor: expected success", nullptr);
}
scopeMessage.reset();
delete scopeMessage;
}

UErrorCode IcuTestErrorCode::reset() {
Expand Down
11 changes: 8 additions & 3 deletions icu4c/source/tools/ctestfw/unicode/testlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ class T_CTEST_EXPORT_API TestLog {
// unit tests that work without U_SHOW_CPLUSPLUS_API.
// So instead we *copy* the ErrorCode API.

U_NAMESPACE_BEGIN
class UnicodeString;
U_NAMESPACE_END

class T_CTEST_EXPORT_API IcuTestErrorCode {
public:
IcuTestErrorCode(const IcuTestErrorCode&) = delete;
IcuTestErrorCode& operator=(const IcuTestErrorCode&) = delete;

IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName)
#if 0
: errorCode(U_ZERO_ERROR),
testClass(callingTestClass), testName(callingTestName)
#if 1
, scopeMessage(std::make_unique<std::u16string>())
#endif
{}
#endif
;
virtual ~IcuTestErrorCode();

// ErrorCode API
Expand Down Expand Up @@ -83,7 +88,7 @@ class T_CTEST_EXPORT_API IcuTestErrorCode {
TestLog &testClass;
const char *const testName;
#if 1
std::unique_ptr<std::u16string> scopeMessage;
UnicodeString *const scopeMessage;
#endif

void errlog(UBool dataErr, const UnicodeString& mainMessage, const char* extraMessage) const;
Expand Down

0 comments on commit d2f4a03

Please sign in to comment.