Fix GncOptionMultichoiceValue list tests

To conform to changes in 84eb084375.
This commit is contained in:
John Ralls
2023-07-20 21:24:31 -07:00
parent e5f9e4ea6d
commit c5181180ad
2 changed files with 12 additions and 6 deletions

View File

@@ -23,6 +23,7 @@
#include "gnc-option-impl.hpp"
#include "gnc-datetime.hpp"
#include "gnc-option-uitype.hpp"
#include "guid.hpp"
#include <cassert>
#include <sstream>
@@ -887,11 +888,15 @@ GncOptionAccountSelValue::deserialize(const std::string& str) noexcept
std::string
GncOptionMultichoiceValue::serialize() const noexcept
{
static const std::string no_value{"No Value"};
static const std::string no_value{""};
std::string retval;
bool first = true;
bool list_context = m_ui_type == GncOptionUIType::LIST;
if (m_value.empty())
return no_value;
if (list_context)
retval += '(';
for (auto index : m_value)
{
if (!first)
@@ -899,6 +904,8 @@ GncOptionMultichoiceValue::serialize() const noexcept
first = false;
retval += std::get<0>(m_choices[index]);
}
if (list_context)
retval += ')';
return retval;
}

View File

@@ -846,12 +846,11 @@ TEST_F(GncListOption, test_set_value)
TEST_F(GncListOption, test_list_out)
{
auto vec{m_option.get_value<GncMultichoiceOptionIndexVec>()};
std::string value{m_option.permissible_value(vec[0])};
value += " ";
value += m_option.permissible_value(vec[1]);
std::ostringstream oss;
std::ostringstream vss, oss;
vss << '(' << m_option.permissible_value(vec[0]) << " "
<< m_option.permissible_value(vec[1]) << ')';
oss << m_option;
EXPECT_EQ(oss.str(), value);
EXPECT_EQ(oss.str(), vss.str());
}
TEST_F(GncListOption, test_list_in)