forked from cheng/wallet
Spent far too much time fixing <=> to operate over ranges
This commit is contained in:
parent
4e671723fe
commit
97c98cf1e5
2
app.h
2
app.h
@ -47,7 +47,7 @@ static constexpr wxCmdLineEntryDesc g_cmdLineDesc[] =
|
|||||||
"If the log is displayed, then does not exit on completion of unit test.",
|
"If the log is displayed, then does not exit on completion of unit test.",
|
||||||
wxCMD_LINE_VAL_NONE, wxCMD_LINE_SWITCH_NEGATABLE},
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_SWITCH_NEGATABLE},
|
||||||
{ wxCMD_LINE_SWITCH, "f", "focus", "-f or --focus causes focus events to be logged for debugging purposes. "
|
{ wxCMD_LINE_SWITCH, "f", "focus", "-f or --focus causes focus events to be logged for debugging purposes. "
|
||||||
"Usually used as -lf or -lft, as logging them without displaying them is useless.",
|
"implies log",
|
||||||
wxCMD_LINE_VAL_NONE, wxCMD_LINE_SWITCH_NEGATABLE},
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_SWITCH_NEGATABLE},
|
||||||
{ wxCMD_LINE_PARAM, "", "", "mywallet.wallet",
|
{ wxCMD_LINE_PARAM, "", "", "mywallet.wallet",
|
||||||
wxCMD_LINE_VAL_NONE, /*wxCMD_LINE_PARAM_MULTIPLE|*/wxCMD_LINE_PARAM_OPTIONAL},
|
wxCMD_LINE_VAL_NONE, /*wxCMD_LINE_PARAM_MULTIPLE|*/wxCMD_LINE_PARAM_OPTIONAL},
|
||||||
|
@ -83,10 +83,12 @@ try {
|
|||||||
m_pLogWindow->GetFrame()->SetName(sz_unit_test_log);
|
m_pLogWindow->GetFrame()->SetName(sz_unit_test_log);
|
||||||
m_pLogWindow->GetFrame()->SetIcon(wxICON(AAArho));
|
m_pLogWindow->GetFrame()->SetIcon(wxICON(AAArho));
|
||||||
if (singletonApp->m_unit_test) {
|
if (singletonApp->m_unit_test) {
|
||||||
wxLogMessage(_T("Command line specified unit test with%s exit on completion of unit test."),
|
wxLogMessage(_T("Command line specified %s unit test with%s exit on completion of unit test."),
|
||||||
|
singletonApp->m_complete_unit_test?_T("complete"): singletonApp->m_quick_unit_test?_T("quick"):_T(""),
|
||||||
singletonApp->m_display ? _T("out") : _T(""));
|
singletonApp->m_display ? _T("out") : _T(""));
|
||||||
wxLogMessage(_T("If an error occurs during unit test, the program will return a non zero "
|
wxLogMessage(_T("If an error occurs during unit test, the program will return a non zero "
|
||||||
"error number on exit."));
|
"error number on exit."));
|
||||||
|
wxLogMessage(_T(""));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
wxLog::EnableLogging(false);
|
wxLog::EnableLogging(false);
|
||||||
@ -97,7 +99,10 @@ try {
|
|||||||
wxEVT_IDLE,
|
wxEVT_IDLE,
|
||||||
&UnitTest
|
&UnitTest
|
||||||
);
|
);
|
||||||
if (singletonApp->m_log_focus_events)wxLogMessage(_T("Logging focus events"));
|
if (singletonApp->m_log_focus_events) {
|
||||||
|
wxLogMessage(_T("Logging focus events"));
|
||||||
|
wxLogMessage(_T(""));
|
||||||
|
}
|
||||||
if (singletonApp->m_params.empty()) {
|
if (singletonApp->m_params.empty()) {
|
||||||
wxLogMessage(_T("No wallet specified. Attempting to open last used wallet"));
|
wxLogMessage(_T("No wallet specified. Attempting to open last used wallet"));
|
||||||
}else {
|
}else {
|
||||||
|
@ -59,7 +59,61 @@ namespace ro {
|
|||||||
junction<has_constructor<T, _Types>...>::value;
|
junction<has_constructor<T, _Types>...>::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::span<byte>& operator^=(std::span<byte>& lhs, byte* rhs) {
|
/*spaceship operator for any pair of types that take an index
|
||||||
for (auto& j : lhs) { j ^= *rhs++; }
|
*
|
||||||
return lhs;
|
* noexistent values of the shorter array are considered zero if of
|
||||||
|
* arithmetic type, otherwise, considered greater than zero */
|
||||||
|
template<class T, class U >
|
||||||
|
decltype(std::declval<T>()[0] <=> std::declval<U>()[0]) operator <=> (
|
||||||
|
const T& lh, const U& rh
|
||||||
|
) {
|
||||||
|
typedef decltype(lh[0] <=> rh[0]) spaceship_return_type;
|
||||||
|
auto slh{ std::span(lh) };
|
||||||
|
auto srh{ std::span(rh) };
|
||||||
|
auto minsize{ std::min(slh.size(), srh.size()) };
|
||||||
|
spaceship_return_type retval{ spaceship_return_type::equivalent };
|
||||||
|
auto plh{ slh.begin() };
|
||||||
|
auto prh{ srh.begin() };
|
||||||
|
auto common_end{ plh + minsize };
|
||||||
|
while (
|
||||||
|
plh < common_end
|
||||||
|
&&
|
||||||
|
(
|
||||||
|
std::is_eq(retval = plh[0] <=> prh[0])
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
plh++;
|
||||||
|
prh++;
|
||||||
|
}
|
||||||
|
if (std::is_eq(retval)) {
|
||||||
|
if (slh.size() > srh.size()) {
|
||||||
|
assert(prh == srh.end() && plh < slh.end());
|
||||||
|
if constexpr (std::is_arithmetic<std::remove_cvref<decltype(std::declval<T>()[0])>::type>::value) {
|
||||||
|
while (
|
||||||
|
plh < slh.end()
|
||||||
|
&& std::is_eq(retval = plh[0] <=> 0)
|
||||||
|
) {
|
||||||
|
plh++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = spaceship_return_type::greater;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (slh.size() < srh.size()) {
|
||||||
|
assert(plh == slh.end() && prh < srh.end());
|
||||||
|
if constexpr (std::is_arithmetic<std::remove_cvref<decltype(std::declval<U>()[0])>::type>::value) {
|
||||||
|
while (
|
||||||
|
prh < srh.end()
|
||||||
|
&& std::is_eq(retval = prh[0] <=> 0)
|
||||||
|
) {
|
||||||
|
prh++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = spaceship_return_type::less;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
}
|
}
|
@ -26,6 +26,8 @@ namespace testbed {
|
|||||||
and can safely be thrown away
|
and can safely be thrown away
|
||||||
|
|
||||||
This is a playground, where you can do stuff without worrying you might inadvertently break something that matters
|
This is a playground, where you can do stuff without worrying you might inadvertently break something that matters
|
||||||
|
|
||||||
|
No mechanism for input is available, but you generally do not need it because you hard code the testing data, but, of course, it can post a dialog using postmessage, then immediately return, and the dialog can then call anything.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void testbed() {
|
void testbed() {
|
||||||
|
Loading…
Reference in New Issue
Block a user