Skip to content

Commit

Permalink
fix formatting bug (pxcomp)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwb committed Feb 9, 2023
1 parent b359a6d commit 0d0e7b9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/comp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ void CompTest::get_longest_taxon_label () {
void CompTest::return_freq_table () {
const int colWidth = 12;
// need to take into account longest_tax_label_
get_longest_taxon_label();
std::string pad = std::string(longest_tax_label_, ' ');
get_longest_taxon_label(); // label might be shorter than row label 'Total'
unsigned int longest_label = longest_tax_label_;
longest_label = std::max(longest_label, 5U);
std::string pad = std::string(longest_label, ' ');
// header
(*poos_) << "Observed character counts:" << std::endl;
(*poos_) << pad << " ";
Expand All @@ -131,7 +133,7 @@ void CompTest::return_freq_table () {
}
(*poos_) << std::right << std::setw(colWidth) << "Nchar" << std::endl;
for (size_t i = 0; i < static_cast<size_t>(num_taxa_); i++) {
unsigned int diff = longest_tax_label_ - static_cast<unsigned int>(taxon_labels_[i].size());
unsigned int diff = longest_label - static_cast<unsigned int>(taxon_labels_[i].size());
(*poos_) << taxon_labels_[i];
if (diff > 0) {
pad = std::string(diff, ' ');
Expand All @@ -143,7 +145,7 @@ void CompTest::return_freq_table () {
}
(*poos_) << std::right << std::setw(colWidth) << row_totals_[i] << std::endl;
}
unsigned int diff = longest_tax_label_ - 5;
unsigned int diff = longest_label - 5L;
pad = std::string(diff, ' ');
(*poos_) << "Total" << pad << " ";
for (unsigned int col_total : col_totals_) {
Expand Down

0 comments on commit 0d0e7b9

Please sign in to comment.