[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c253b0a 1/3: Avoid UTF-16
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c253b0a 1/3: Avoid UTF-16 |
Date: |
Fri, 14 Sep 2018 14:43:01 -0400 (EDT) |
branch: master
commit c253b0a6b14bd0a242d2f588fc891d9a2e5382a3
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Avoid UTF-16
See:
https://lists.nongnu.org/archive/html/lmi/2018-09/msg00020.html
---
main_wx_test.cpp | 78 +++++++++++++++++++++++++++++---------------
wx_test_about_version.cpp | 9 +++--
wx_test_benchmark_census.cpp | 17 ++++++----
wx_test_default_input.cpp | 30 +++++++++--------
wx_test_expiry_dates.cpp | 16 +++++----
wx_test_input_sequences.cpp | 13 ++++----
6 files changed, 102 insertions(+), 61 deletions(-)
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 18315c1..6f125fb 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -33,7 +33,6 @@
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
-#include <wx/crt.h>
#include <wx/docview.h>
#include <wx/fileconf.h>
#include <wx/frame.h>
@@ -451,19 +450,32 @@ TestsResults application_test::run()
try
{
- wxPrintf("%s: started\n", name);
+ std::cout << name << ": started" << std::endl;
wxStopWatch sw;
i.run_test();
// Check that no messages were unexpectedly logged during this
// test execution.
wxLog::FlushActive();
- wxPrintf("time=%ldms (for %s)\n", sw.Time(), name);
- wxPrintf("%s: ok\n", name);
+ std::cout
+ << "time="
+ << sw.Time()
+ << "ms (for "
+ << name
+ << ")"
+ << std::endl
+ ;
+ std::cout << name << ": ok" << std::endl;
++results.passed;
}
catch(test_skipped_exception const& e)
{
- wxPrintf("%s: skipped (%s)\n", name, e.what());
+ std::cout
+ << name
+ << ": skipped ("
+ << e.what()
+ << ")"
+ << std::endl
+ ;
++results.skipped;
}
catch(std::exception const& e)
@@ -485,7 +497,13 @@ TestsResults application_test::run()
wxString one_line_error(error);
one_line_error.Replace("\n", " ");
- wxPrintf("%s: ERROR (%s)\n", name, one_line_error);
+ std::cout
+ << name
+ << ": ERROR ("
+ << one_line_error
+ << ")"
+ << std::endl
+ ;
}
}
}
@@ -834,7 +852,7 @@ void SkeletonTest::RunTheTests()
MainWin->SetFocus();
- wxPuts("NOTE: starting the test suite");
+ std::cout << "NOTE: starting the test suite" << std::endl;
wxStopWatch sw;
// Notice that it is safe to use simple variable assignment here instead of
@@ -844,41 +862,49 @@ void SkeletonTest::RunTheTests()
TestsResults const results = application_test::instance().run();
is_running_tests_ = false;
- wxPrintf("time=%ldms (for all tests)\n", sw.Time());
+ std::cout << "time=" << sw.Time() << "ms (for all tests)" << std::endl;
if(results.failed == 0)
{
if(results.passed == 0)
{
- wxPuts("WARNING: no tests have been executed.");
+ std::cout << "WARNING: no tests have been executed." << std::endl;
}
else
{
- wxPrintf
- ("SUCCESS: %d test%s successfully completed.\n"
- ,results.passed
- ,results.passed == 1 ? "" : "s"
- );
+ std::cout
+ << "SUCCESS: "
+ << results.passed
+ << " test"
+ << (results.passed == 1 ? "" : "s")
+ << " successfully completed."
+ << std::endl
+ ;
}
}
else
{
- wxPrintf
- ("FAILURE: %d out of %d test%s failed.\n"
- ,results.failed
- ,results.total
- ,results.total == 1 ? "" : "s"
- );
+ std::cout
+ << "FAILURE: "
+ << results.failed
+ << " out of "
+ << results.total
+ << " test"
+ << (results.total == 1 ? "" : "s")
+ << " failed."
+ << std::endl
+ ;
}
if(results.skipped)
{
- wxPrintf
- ("NOTE: %s skipped\n"
- ,results.skipped == 1
- ? wxString("1 test was")
- : wxString::Format("%d tests were", results.skipped)
- );
+ std::cout
+ << "NOTE: "
+ << results.skipped
+ << (results.skipped == 1 ? " test was" : " tests were")
+ << " skipped"
+ << std::endl
+ ;
}
}
diff --git a/wx_test_about_version.cpp b/wx_test_about_version.cpp
index 540275a..56ebfb4 100644
--- a/wx_test_about_version.cpp
+++ b/wx_test_about_version.cpp
@@ -26,13 +26,13 @@
#include "version.hpp"
#include "wx_test_case.hpp"
-#include <wx/crt.h>
#include <wx/dialog.h>
#include <wx/html/htmlwin.h>
#include <wx/testing.h>
#include <wx/uiaction.h>
#include <climits> // INT_MAX
+#include <iostream>
#include <regex>
/// Validate version string (timestamp) from "About" dialog title.
@@ -171,7 +171,12 @@ LMI_WX_TEST_CASE(about_dialog_version)
// Extract the last word of the dialog title.
wxString const last_word = d->GetTitle().AfterLast(' ');
- wxPrintf("About dialog version string is \"%s\".\n", last_word);
+ std::cout
+ << "About dialog version string is '"
+ << last_word
+ << "'."
+ << std::endl
+ ;
LMI_ASSERT_EQUAL(last_word, LMI_VERSION);
// Find the wxHtmlWindow showing the license notices.
diff --git a/wx_test_benchmark_census.cpp b/wx_test_benchmark_census.cpp
index 214457d..7b5060e 100644
--- a/wx_test_benchmark_census.cpp
+++ b/wx_test_benchmark_census.cpp
@@ -25,7 +25,6 @@
#include "wx_test_case.hpp"
#include "wx_test_statusbar.hpp"
-#include <wx/crt.h>
#include <wx/dialog.h>
#include <wx/frame.h>
#include <wx/scopeguard.h>
@@ -35,6 +34,7 @@
#include <boost/filesystem/operations.hpp>
#include <cmath> // fabs()
+#include <iostream>
namespace
{
@@ -81,12 +81,15 @@ class census_benchmark
long int time_real;
LMI_ASSERT(ms_text.ToLong(&time_real));
- wxPrintf
- ("%s for %s: %ldms elapsed\n"
- ,operation
- ,name_
- ,time_real
- );
+ std::cout
+ << operation
+ << " for "
+ << name_
+ << ": "
+ << time_real
+ << "ms elapsed"
+ << std::endl
+ ;
}
void close_window()
diff --git a/wx_test_default_input.cpp b/wx_test_default_input.cpp
index 6a8b1c8..d0d11d1 100644
--- a/wx_test_default_input.cpp
+++ b/wx_test_default_input.cpp
@@ -28,8 +28,7 @@
#include "wx_test_case.hpp"
#include "wx_test_date.hpp"
-#include <wx/crt.h>
-
+#include <iostream>
#include <sstream>
/// Test selected parameters in the user-customizable default cell.
@@ -68,14 +67,16 @@ LMI_WX_TEST_CASE(default_input)
calendar_date const first_of_next_month = get_first_next_month(today());
- wxPrintf
- ("EffectiveDate: %s; expected: %s\n"
- ,dump_date(effective_date)
- ,dump_date(first_of_next_month)
- );
+ std::cout
+ << "EffectiveDate: "
+ << dump_date(effective_date)
+ << "; expected: "
+ << dump_date(first_of_next_month)
+ << std::endl
+ ;
if(effective_date != first_of_next_month)
{
- wxPuts("WARNING: Effective date is different from the expected date.");
+ std::cout << "WARNING: Effective date != expected date." << std::endl;
}
std::string const general_account_rate = cell["GeneralAccountRate"].str();
@@ -83,10 +84,13 @@ LMI_WX_TEST_CASE(default_input)
std::string const product_name = cell["ProductName"].str();
- wxPrintf
- ("ProductName=\"%s\"; GeneralAccountRate=\"%s\"\n"
- ,product_name
- ,general_account_rate
- );
+ std::cout
+ << "ProductName='"
+ << product_name
+ << "'; GeneralAccountRate='"
+ << general_account_rate
+ << "'"
+ << std::endl
+ ;
}
diff --git a/wx_test_expiry_dates.cpp b/wx_test_expiry_dates.cpp
index c302400..242d0ae 100644
--- a/wx_test_expiry_dates.cpp
+++ b/wx_test_expiry_dates.cpp
@@ -28,11 +28,11 @@
#include "wx_test_case.hpp"
#include "wx_test_date.hpp"
-#include <wx/crt.h>
-
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
+#include <iostream>
+
/// Validate dates in the 'expiry' file.
///
/// Write the begin and end dates to stdout, as JDN and as YYYYMMDD,
@@ -76,11 +76,13 @@ LMI_WX_TEST_CASE(expiry_dates)
is >> begin >> end;
LMI_ASSERT_WITH_MSG(is, "Failed to read dates from \"expiry\" file");
- wxPrintf
- ("Expiry dates: begin=%s, end=%s\n"
- ,dump_date(begin)
- ,dump_date(end)
- );
+ std::cout
+ << "Expiry dates: begin="
+ << dump_date(begin)
+ << ", end="
+ << dump_date(end)
+ << std::endl
+ ;
LMI_ASSERT_WITH_MSG(is.eof(), "Unexpected extra data in \"expiry\" file");
diff --git a/wx_test_input_sequences.cpp b/wx_test_input_sequences.cpp
index 9f34f62..0805295 100644
--- a/wx_test_input_sequences.cpp
+++ b/wx_test_input_sequences.cpp
@@ -26,11 +26,11 @@
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
-#include <wx/crt.h>
#include <wx/testing.h>
#include <wx/uiaction.h>
#include <algorithm> // find()
+#include <iostream>
/// Validate a variety of input sequences in the GUI input dialog.
///
@@ -106,11 +106,12 @@ LMI_WX_TEST_CASE(input_sequences)
std::vector<std::string> const& names =
dummy_input.member_names();
if(std::find(names.begin(), names.end(), field_name) ==
names.end())
{
- wxPrintf
- ("WARNING: unknown field name \"%s\", \"test_cases\" "
- "array probably needs to be updated.\n"
- ,field_name
- );
+ std::cout
+ << "WARNING: unknown field name '"
+ << field_name
+ << "': 'test_cases' array probably needs to be
updated."
+ << std::endl
+ ;
}
// However, it is not an error if the field used by