[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 76f5b23 3/3: Avoid gratuitous use of unsigned
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 76f5b23 3/3: Avoid gratuitous use of unsigned int |
Date: |
Fri, 8 Jun 2018 19:18:12 -0400 (EDT) |
branch: master
commit 76f5b2376b25cb430b5a70480699fc22305860a4
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Avoid gratuitous use of unsigned int
---
authenticity.cpp | 2 +-
single_choice_popup_menu.cpp | 4 +++-
wx_test_calculation_summary.cpp | 21 ++++++++++-----------
wx_test_paste_census.cpp | 9 +++++----
4 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/authenticity.cpp b/authenticity.cpp
index 1ad2c8d..03feefe 100644
--- a/authenticity.cpp
+++ b/authenticity.cpp
@@ -288,7 +288,7 @@ std::string md5_hex_string(std::vector<unsigned char>
const& vuc)
oss
<< std::setw(chars_per_formatted_hex_byte)
<< std::setfill('0')
- << static_cast<unsigned int>(j)
+ << static_cast<int>(j)
;
}
return oss.str();
diff --git a/single_choice_popup_menu.cpp b/single_choice_popup_menu.cpp
index 380074d..2c17f7f 100644
--- a/single_choice_popup_menu.cpp
+++ b/single_choice_popup_menu.cpp
@@ -23,6 +23,8 @@
#include "single_choice_popup_menu.hpp"
+#include "ssize_lmi.hpp"
+
#include <wx/evtloop.h>
#include <wx/toplevel.h>
@@ -37,7 +39,7 @@ SingleChoicePopupMenu::SingleChoicePopupMenu
{
menu_.SetTitle(title);
}
- for(unsigned int j = 0; j < choices.GetCount(); ++j)
+ for(int j = 0; j < lmi::ssize(choices); ++j)
{
wxString s = choices[j];
if(wxNOT_FOUND == s.Find('&'))
diff --git a/wx_test_calculation_summary.cpp b/wx_test_calculation_summary.cpp
index 6f300d5..0bf1cde 100644
--- a/wx_test_calculation_summary.cpp
+++ b/wx_test_calculation_summary.cpp
@@ -24,6 +24,7 @@
#include "assert_lmi.hpp"
#include "configurable_settings.hpp"
#include "mvc_controller.hpp"
+#include "ssize_lmi.hpp"
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
#include "wx_utility.hpp"
@@ -56,8 +57,7 @@ name_and_title const default_columns_info[] =
,{ "EOYDeathBft_Current" , "Curr EOY Death Benefit" }
};
-std::size_t const number_of_default_columns
- = sizeof default_columns_info / sizeof(default_columns_info[0]);
+int const number_of_default_columns = lmi::ssize(default_columns_info);
// Names and titles of the columns used when not using the built-in calculation
// summary.
@@ -66,8 +66,7 @@ name_and_title const custom_columns_info[] =
,{ "NewCashLoan" , "Annual Loan" }
};
-std::size_t const number_of_custom_columns
- = sizeof custom_columns_info / sizeof(custom_columns_info[0]);
+int const number_of_custom_columns = lmi::ssize(custom_columns_info);
// Special name used when the column is not used at all. This is the same
// string used in preferences_model.cpp, but we duplicate it here as we don't
@@ -76,7 +75,7 @@ char const* const empty_column_name = "[none]";
// Total number of configurable summary columns. This, again, duplicates the
// number [implicitly] used in preferences_model.cpp.
-std::size_t const total_number_of_columns = 12;
+int const total_number_of_columns = 12;
// Base class for all the tests working with the preferences dialog. It
// defines both a simpler interface for the derived classes to define the
@@ -153,7 +152,7 @@ class expect_preferences_dialog_base
}
}
- wxComboBox* focus_column_combobox(unsigned int n)
+ wxComboBox* focus_column_combobox(int n)
{
wxWindow* const column_window = wx_test_focus_controller_child
(*dialog_
@@ -314,10 +313,10 @@ LMI_WX_TEST_CASE(calculation_summary)
std::vector<std::string> const&
summary_columns = effective_calculation_summary_columns();
- for(unsigned int n = 0; n < number_of_custom_columns; ++n)
+ for(int n = 0; n < number_of_custom_columns; ++n)
{
wxString const& column =
focus_column_combobox(n)->GetValue();
- if(n < summary_columns.size())
+ if(n < lmi::ssize(summary_columns))
{
LMI_ASSERT_EQUAL(column, summary_columns[n]);
}
@@ -344,7 +343,7 @@ LMI_WX_TEST_CASE(calculation_summary)
set_use_builtin_summary(false);
wxUIActionSimulator ui;
- for(unsigned int n = 0; n < total_number_of_columns; ++n)
+ for(int n = 0; n < total_number_of_columns; ++n)
{
focus_column_combobox(n);
ui.Select(n == 2 ? "NewCashLoan" : empty_column_name);
@@ -375,7 +374,7 @@ LMI_WX_TEST_CASE(calculation_summary)
);
// And all the rest of the columns are (still) empty.
- for(unsigned int n = 1; n < total_number_of_columns; ++n)
+ for(int n = 1; n < total_number_of_columns; ++n)
{
LMI_ASSERT_EQUAL
(focus_column_combobox(n)->GetValue()
@@ -410,7 +409,7 @@ LMI_WX_TEST_CASE(calculation_summary)
,"NewCashLoan"
);
- for(unsigned int n = 1; n < total_number_of_columns; ++n)
+ for(int n = 1; n < total_number_of_columns; ++n)
{
LMI_ASSERT_EQUAL
(focus_column_combobox(n)->GetValue()
diff --git a/wx_test_paste_census.cpp b/wx_test_paste_census.cpp
index 52b10bb..a1a52d8 100644
--- a/wx_test_paste_census.cpp
+++ b/wx_test_paste_census.cpp
@@ -22,6 +22,7 @@
#include "pchfile_wx.hpp"
#include "assert_lmi.hpp"
+#include "bourn_cast.hpp"
#include "data_directory.hpp"
#include "mvc_controller.hpp"
#include "wx_test_case.hpp"
@@ -124,7 +125,7 @@ void check_list_columns
{
std::set<std::string> remaining(expected.begin(), expected.end());
- for(unsigned int n = 0; n < dvc->GetColumnCount(); ++n)
+ for(int n = 0; n < bourn_cast<int>(dvc->GetColumnCount()); ++n)
{
std::string const title = dvc->GetColumn(n)->GetTitle().ToStdString();
LMI_ASSERT_WITH_MSG
@@ -146,12 +147,12 @@ void check_list_columns
// Find the index of the column with the given title.
//
// Throws an exception if the column is not found.
-unsigned int find_model_column_by_title
+int find_model_column_by_title
(wxDataViewCtrl* dvc
,std::string const& title
)
{
- for(unsigned int n = 0; n < dvc->GetColumnCount(); ++n)
+ for(int n = 0; n < bourn_cast<int>(dvc->GetColumnCount()); ++n)
{
wxDataViewColumn const* column = dvc->GetColumn(n);
if(column->GetTitle().ToStdString() == title)
@@ -331,7 +332,7 @@ LMI_WX_TEST_CASE(paste_census)
);
// Verify that the "Gender" column value is "Unisex" in every row now.
- unsigned int const
+ int const
gender_column = find_model_column_by_title(list_window, "Gender");
LMI_ASSERT_EQUAL(list_model->GetCount(), number_of_rows);
// Only the first two rows are affected, because only they belong