Separate GncOptionAccountValue into GncOptionAccountListValue and GncOptionAccountSelValue.

They have different get_value() return types so can't cohabit comfortably.
This commit is contained in:
John Ralls 2021-07-31 17:43:48 -07:00
parent dd8e8b4efa
commit 18997db720
10 changed files with 293 additions and 54 deletions

View File

@ -37,7 +37,7 @@ const std::string GncOptionMultichoiceValue::c_empty_string{""};
const std::string GncOptionMultichoiceValue::c_list_string{"multiple values"};
bool
GncOptionAccountValue::validate(const GncOptionAccountList& values) const
GncOptionAccountListValue::validate(const GncOptionAccountList& values) const
{
if (values.empty())
return true;
@ -54,6 +54,42 @@ GncOptionAccountValue::validate(const GncOptionAccountList& values) const
return true;
}
GncOptionAccountList
GncOptionAccountListValue::get_value() const
{
return !m_value.empty() ? m_value : get_default_value();
}
GncOptionAccountList
GncOptionAccountListValue::get_default_value() const
{
if (!m_default_value.empty())
return m_default_value;
/* If no default has been set and there's an allowed set then find the first
* account that matches one of the allowed account types.
*/
GncOptionAccountList retval{};
if (m_allowed.empty())
return retval;
auto root{gnc_get_current_root_account()};
auto account_list{gnc_account_get_descendants_sorted(root)};
if (!account_list)
return retval;
for (auto node = account_list; node; node = g_list_next (node))
if (std::find(m_allowed.begin(), m_allowed.end(),
xaccAccountGetType(GNC_ACCOUNT(node->data))) != m_allowed.end())
{
retval.push_back(GNC_ACCOUNT(node->data));
break;
}
g_list_free(account_list);
return retval;
}
/**
* Create a GList of account types to pass to gnc_account_sel_set_acct_filters.
* gnc_account_sel_set_acct_filters copies the list so the intermediary caller
@ -62,7 +98,73 @@ GncOptionAccountValue::validate(const GncOptionAccountList& values) const
* @return an allocated GList* or nullptr if the list is empty.
*/
GList*
GncOptionAccountValue::account_type_list() const noexcept
GncOptionAccountListValue::account_type_list() const noexcept
{
if (m_allowed.empty())
return nullptr;
GList* retval;
for (auto type : m_allowed)
retval = g_list_prepend(retval, GINT_TO_POINTER(type));
return g_list_reverse(retval);
}
bool
GncOptionAccountSelValue::validate(const Account* value) const
{
if (m_allowed.empty() || !value)
return true;
if (std::find(m_allowed.begin(), m_allowed.end(),
xaccAccountGetType(value)) == m_allowed.end())
return false;
return true;
}
const Account*
GncOptionAccountSelValue::get_value() const
{
return m_value ? m_value : get_default_value();
}
const Account*
GncOptionAccountSelValue::get_default_value() const
{
if (m_default_value)
return m_default_value;
/* If no default has been set and there's an allowed set then find the first
* account that matches one of the allowed account types.
*/
if (m_allowed.empty())
return nullptr;
const Account* retval{nullptr};
auto root{gnc_get_current_root_account()};
auto account_list{gnc_account_get_descendants_sorted(root)};
if (!account_list)
return nullptr;
for (auto node = account_list; node; node = g_list_next (node))
if (std::find(m_allowed.begin(), m_allowed.end(),
xaccAccountGetType(GNC_ACCOUNT(node->data))) != m_allowed.end())
{
retval = GNC_ACCOUNT(node->data);
break;
}
g_list_free(account_list);
return retval;
}
/**
* Create a GList of account types to pass to gnc_account_sel_set_acct_filters.
* gnc_account_sel_set_acct_filters copies the list so the intermediary caller
* is responsible for freeing the list.
*
* @return an allocated GList* or nullptr if the list is empty.
*/
GList*
GncOptionAccountSelValue::account_type_list() const noexcept
{
if (m_allowed.empty())
return nullptr;

View File

@ -908,30 +908,30 @@ using GncOptionAccountTypeList = std::vector<GNCAccountType>;
*/
class GncOptionAccountValue : public OptionClassifier
class GncOptionAccountListValue : public OptionClassifier
{
public:
GncOptionAccountValue(const char* section, const char* name,
GncOptionAccountListValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type, bool multi=true) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{}, m_default_value{}, m_allowed{}, m_multiselect{multi} {}
GncOptionAccountValue(const char* section, const char* name,
GncOptionAccountListValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
const GncOptionAccountList& value, bool multi=true) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{value}, m_default_value{std::move(value)}, m_allowed{},
m_multiselect{multi} {}
GncOptionAccountValue(const char* section, const char* name,
GncOptionAccountListValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
GncOptionAccountTypeList&& allowed, bool multi=true) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{}, m_default_value{}, m_allowed{std::move(allowed)},
m_multiselect{multi} {}
GncOptionAccountValue(const char* section, const char* name,
GncOptionAccountListValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
const GncOptionAccountList& value,
@ -945,8 +945,8 @@ public:
m_default_value = std::move(value);
}
const GncOptionAccountList& get_value() const { return m_value; }
const GncOptionAccountList& get_default_value() const { return m_default_value; }
GncOptionAccountList get_value() const;
GncOptionAccountList get_default_value() const;
bool validate (const GncOptionAccountList& values) const;
void set_value (const GncOptionAccountList& values) {
if (validate(values))
@ -973,8 +973,8 @@ private:
};
template<> inline std::ostream&
operator<< <GncOptionAccountValue>(std::ostream& oss,
const GncOptionAccountValue& opt)
operator<< <GncOptionAccountListValue>(std::ostream& oss,
const GncOptionAccountListValue& opt)
{
auto values{opt.get_value()};
bool first = true;
@ -990,8 +990,8 @@ operator<< <GncOptionAccountValue>(std::ostream& oss,
}
template<> inline std::istream&
operator>> <GncOptionAccountValue>(std::istream& iss,
GncOptionAccountValue& opt)
operator>> <GncOptionAccountListValue>(std::istream& iss,
GncOptionAccountListValue& opt)
{
GncOptionAccountList values;
while (true)
@ -1010,7 +1010,7 @@ operator>> <GncOptionAccountValue>(std::istream& iss,
template<class OptType,
typename std::enable_if_t<std::is_same_v<std::decay_t<OptType>,
GncOptionAccountValue>,
GncOptionAccountListValue>,
int> = 0>
inline std::ostream&
gnc_option_to_scheme(std::ostream& oss, const OptType& opt)
@ -1032,7 +1032,7 @@ gnc_option_to_scheme(std::ostream& oss, const OptType& opt)
template<class OptType,
typename std::enable_if_t<std::is_same_v<std::decay_t<OptType>,
GncOptionAccountValue>,
GncOptionAccountListValue>,
int> = 0>
inline std::istream&
gnc_option_from_scheme(std::istream& iss, OptType& opt)
@ -1056,6 +1056,129 @@ gnc_option_from_scheme(std::istream& iss, OptType& opt)
return iss;
}
class GncOptionAccountSelValue : public OptionClassifier
{
public:
GncOptionAccountSelValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{}, m_default_value{}, m_allowed{} {}
GncOptionAccountSelValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
const Account* value) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{const_cast<Account*>(value)},
m_default_value{const_cast<Account*>(value)}, m_allowed{} {}
GncOptionAccountSelValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
GncOptionAccountTypeList&& allowed) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{}, m_default_value{}, m_allowed{std::move(allowed)} {}
GncOptionAccountSelValue(const char* section, const char* name,
const char* key, const char* doc_string,
GncOptionUIType ui_type,
const Account* value,
GncOptionAccountTypeList&& allowed) :
OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
m_value{}, m_default_value{}, m_allowed{std::move(allowed)} {
if (!validate(value))
throw std::invalid_argument("Supplied Value not in allowed set.");
m_value = const_cast<Account*>(value);
m_default_value = const_cast<Account*>(value);
}
const Account* get_value() const;
const Account* get_default_value() const;
bool validate (const Account* value) const;
void set_value (const Account* value) {
if (validate(value))
//throw!
m_value = const_cast<Account*>(value);
}
void set_default_value (const Account* value) {
if (validate(value))
//throw!
m_value = m_default_value = const_cast<Account*>(value);
}
GList* account_type_list() const noexcept;
void reset_default_value() { m_value = m_default_value; }
bool is_changed() const noexcept { return m_value != m_default_value; }
GncOptionUIType get_ui_type() const noexcept { return m_ui_type; }
void make_internal() { m_ui_type = GncOptionUIType::INTERNAL; }
private:
GncOptionUIType m_ui_type;
Account* m_value;
Account* m_default_value;
GncOptionAccountTypeList m_allowed;
};
template<> inline std::ostream&
operator<< <GncOptionAccountSelValue>(std::ostream& oss,
const GncOptionAccountSelValue& opt)
{
auto value{opt.get_value()};
oss << qof_instance_to_string(QOF_INSTANCE(value));
return oss;
}
template<> inline std::istream&
operator>> <GncOptionAccountSelValue>(std::istream& iss,
GncOptionAccountSelValue& opt)
{
const Account* value;
std::string str;
std::getline(iss, str, ' ');
if (!str.empty())
value = (Account*)qof_instance_from_string(str, opt.get_ui_type());
opt.set_value(value);
iss.clear();
return iss;
}
template<class OptType,
typename std::enable_if_t<std::is_same_v<std::decay_t<OptType>,
GncOptionAccountSelValue>,
int> = 0>
inline std::ostream&
gnc_option_to_scheme(std::ostream& oss, const OptType& opt)
{
auto value{opt.get_value()};
oss << "'(\"";
oss << qof_instance_to_string(QOF_INSTANCE(value)) << '"';
oss << ')';
return oss;
}
template<class OptType,
typename std::enable_if_t<std::is_same_v<std::decay_t<OptType>,
GncOptionAccountSelValue>,
int> = 0>
inline std::istream&
gnc_option_from_scheme(std::istream& iss, OptType& opt)
{
const Account* value;
iss.ignore(3, '"');
while (true)
{
std::string str;
std::getline(iss, str, '"');
if (!str.empty())
{
value = (Account*)qof_instance_from_string(str, opt.get_ui_type());
iss.ignore(2, '"');
}
else
break;
}
opt.set_value(value);
iss.ignore(1, ')');
return iss;
}
/** Date options
* A legal date value is a pair of either and a RelativeDatePeriod, the absolute
* flag and a time64, or for legacy purposes the absolute flag and a timespec.

View File

@ -279,7 +279,7 @@ GncOption::is_multiselect() const noexcept
{
return std::visit([](const auto& option)->bool {
if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
GncOptionAccountValue>)
GncOptionAccountListValue>)
return option.is_multiselect();
else
return false;
@ -367,7 +367,7 @@ GncOption::account_type_list() const noexcept
{
return std::visit([] (const auto& option) -> GList* {
if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
GncOptionAccountValue>)
GncOptionAccountListValue>)
return option.account_type_list();
else
return nullptr;
@ -423,7 +423,7 @@ GncOption::to_scheme(std::ostream& oss) const
return std::visit([&oss](auto& option) ->std::ostream& {
if constexpr
((std::is_same_v<std::decay_t<decltype(option)>,
GncOptionAccountValue>) ||
GncOptionAccountListValue>) ||
(std::is_same_v<std::decay_t<decltype(option)>,
GncOptionMultichoiceValue>) ||
std::is_same_v<std::decay_t<decltype(option)>,
@ -464,7 +464,7 @@ GncOption::from_scheme(std::istream& iss)
return std::visit([&iss](auto& option) -> std::istream& {
if constexpr
((std::is_same_v<std::decay_t<decltype(option)>,
GncOptionAccountValue>) ||
GncOptionAccountListValue>) ||
(std::is_same_v<std::decay_t<decltype(option)>,
GncOptionMultichoiceValue>) ||
std::is_same_v<std::decay_t<decltype(option)>,

View File

@ -49,7 +49,8 @@ using QofQuery = _QofQuery;
struct QofInstance_s;
using QofInstance = QofInstance_s;
template <typename ValueType> class GncOptionValue;
class GncOptionAccountValue;
class GncOptionAccountListValue;
class GncOptionAccountSelValue;
class GncOptionMultichoiceValue;
template <typename ValueType> class GncOptionRangeValue;
template <typename ValueType> class GncOptionValidatedValue;
@ -62,7 +63,8 @@ using GncOptionVariant = std::variant<GncOptionValue<std::string>,
GncOptionValue<const QofQuery*>,
GncOptionValue<const GncOwner*>,
GncOptionValue<SCM>,
GncOptionAccountValue,
GncOptionAccountListValue,
GncOptionAccountSelValue,
GncOptionMultichoiceValue,
GncOptionRangeValue<int>,
GncOptionRangeValue<double>,

View File

@ -923,7 +923,7 @@ gnc_register_account_list_option(GncOptionDB* db, const char* section,
const char* doc_string,
const GncOptionAccountList& value)
{
GncOption option{GncOptionAccountValue{section, name, key, doc_string,
GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
GncOptionUIType::ACCOUNT_LIST, value}};
db->register_option(section, std::move(option));
}
@ -938,7 +938,7 @@ gnc_register_account_list_limited_option(GncOptionDB* db,
{
try
{
GncOption option{GncOptionAccountValue{section, name, key, doc_string,
GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
GncOptionUIType::ACCOUNT_LIST, value, std::move(allowed)}};
db->register_option(section, std::move(option));
}
@ -979,12 +979,12 @@ void
gnc_register_account_sel_limited_option(GncOptionDB* db,
const char* section, const char* name,
const char* key, const char* doc_string,
const GncOptionAccountList& value,
const Account* value,
GncOptionAccountTypeList&& allowed)
{
try
{
GncOption option{GncOptionAccountValue{section, name, key, doc_string,
GncOption option{GncOptionAccountSelValue{section, name, key, doc_string,
GncOptionUIType::ACCOUNT_SEL, value, std::move(allowed)}};
db->register_option(section, std::move(option));
}

View File

@ -351,7 +351,7 @@ void gnc_register_account_sel_limited_option(GncOptionDB* db,
const char* section,
const char* name, const char* key,
const char* doc_string,
const GncOptionAccountList& value,
const Account* value,
GncOptionAccountTypeList&& allowed);
/**
@ -361,7 +361,7 @@ inline void gnc_register_account_sel_limited_option(GncOptionDBPtr& db,
const char* section,
const char* name, const char* key,
const char* doc_string,
const GncOptionAccountList& value,
const Account* value,
GncOptionAccountTypeList&& allowed)
{
gnc_register_account_sel_limited_option(db.get(), section, name, key,

View File

@ -206,6 +206,12 @@ scm_from_value<QofInstance*>(QofInstance* value)
return scm_from_value<const QofInstance*>(value);
}
template <> inline SCM
scm_from_value<const Account*>(const Account* value)
{
return scm_from_value<const QofInstance*>(QOF_INSTANCE(value));
}
template <> inline SCM
scm_from_value<const QofQuery*>(const QofQuery* value)
{
@ -299,6 +305,12 @@ scm_to_value<const QofInstance*>(SCM new_value)
return static_cast<const QofInstance*>(ptr);
}
template <> inline const Account*
scm_to_value<const Account*>(SCM new_value)
{
return GNC_ACCOUNT(scm_to_value<const QofInstance*>(new_value));
}
template <> inline const QofQuery*
scm_to_value<const QofQuery*>(SCM new_value)
{
@ -580,7 +592,7 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
%ignore gnc_register_pixmap_option(GncOptionDB*, const char*, const char*, const char*, const char*, std::string);
%ignore gnc_register_account_list_limited_option(GncOptionDB*, const char*, const char*, const char*, const char*, const GncOptionAccountList&, GncOptionAccountTypeList&&);
%ignore gnc_register_account_list_option(GncOptionDB*, const char*, const char*, const char*, const char*, const GncOptionAccountList&);
%ignore gnc_register_account_sel_limited_option(GncOptionDB*, const char*, const char*, const char*, const char*, const GncOptionAccountList&, GncOptionAccountTypeList&&);
%ignore gnc_register_account_sel_limited_option(GncOptionDB*, const char*, const char*, const char*, const char*, const Account*, GncOptionAccountTypeList&&);
%ignore gnc_register_multichoice_option(GncOptionDB*, const char*, const char*, const char*, const char*, const char*, GncMultichoiceOptionChoices&&);
%ignore gnc_register_list_option(GncOptionDB*, const char*, const char*, const char*, const char*, const char*, GncMultichoiceOptionChoices&&);
%ignore gnc_register_number_Plot_size_option(GncOptionDB*, const char*, const char*, const char*, const char*, int);
@ -939,7 +951,7 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
const GncOptionAccountList& value)
{
try {
return new GncOption{GncOptionAccountValue{section, name, key,
return new GncOption{GncOptionAccountListValue{section, name, key,
doc_string, GncOptionUIType::ACCOUNT_LIST, value}};
}
catch (const std::exception& err)
@ -958,7 +970,7 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
{
try
{
return new GncOption{GncOptionAccountValue{section, name, key,
return new GncOption{GncOptionAccountListValue{section, name, key,
doc_string, GncOptionUIType::ACCOUNT_LIST, value,
std::move(allowed)}};
}
@ -973,12 +985,12 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
const char* name,
const char* key,
const char* doc_string,
const GncOptionAccountList& value,
const Account* value,
GncOptionAccountTypeList&& allowed)
{
try
{
return new GncOption{GncOptionAccountValue{section, name, key,
return new GncOption{GncOptionAccountSelValue{section, name, key,
doc_string, GncOptionUIType::ACCOUNT_SEL, value,
std::move(allowed)}};
}

View File

@ -184,10 +184,10 @@
(gnc-make-account-list-limited-option section name key docstring (default) permitted))
(define-public (gnc:make-account-sel-limited-option section name key docstring default validator permitted)
(issue-deprecation-warning "gnc:make-account-sel-limited-option is deprecated. Make and register the option in one command with gnc-register-account-sel-limited-option.")
(let ((defval (if default (default) #f)))
(let ((defval (if default (default) '())))
(gnc-make-account-sel-limited-option section name key docstring defval permitted)))
(define-public (gnc:make-account-sel-option section name key docstring default validator)
(let ((defval (if default (default) #f)))
(let ((defval (if default (default) '())))
(gnc-make-account-sel-limited-option section name key docstring defval '())))
(define-public (gnc:make-multichoice-option section name key docstring default multichoice)
(issue-deprecation-warning "gnc:make-multichoice-option is deprecated. Make and register the option in one command with gnc-register-multichoice-option.")

View File

@ -736,7 +736,7 @@ TEST_F(GncOptionAccountTest, test_test_constructor_and_destructor)
TEST_F(GncOptionAccountTest, test_option_no_value_constructor)
{
GncOptionAccountValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST};
EXPECT_TRUE(option.get_value().empty());
EXPECT_TRUE(option.get_default_value().empty());
@ -745,7 +745,7 @@ TEST_F(GncOptionAccountTest, test_option_no_value_constructor)
TEST_F(GncOptionAccountTest, test_option_value_constructor)
{
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOptionAccountValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST, acclist};
EXPECT_EQ(2U, option.get_value().size());
EXPECT_EQ(2U, option.get_default_value().size());
@ -756,11 +756,11 @@ TEST_F(GncOptionAccountTest, test_option_no_value_limited_constructor)
{
GncOptionAccountList acclistgood{list_of_types({ACCT_TYPE_BANK})};
GncOptionAccountList acclistbad{list_of_types({ACCT_TYPE_STOCK})};
GncOptionAccountValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
GncOptionAccountTypeList{ACCT_TYPE_BANK}};
EXPECT_TRUE(option.get_value().empty());
EXPECT_TRUE(option.get_default_value().empty());
EXPECT_EQ(1U, option.get_value().size());
EXPECT_EQ(1U, option.get_default_value().size());
EXPECT_EQ(true, option.validate(acclistgood));
EXPECT_EQ(false, option.validate(acclistbad));
}
@ -770,21 +770,21 @@ TEST_F(GncOptionAccountTest, test_option_value_limited_constructor)
GncOptionAccountList acclistgood{list_of_types({ACCT_TYPE_BANK})};
GncOptionAccountList acclistbad{list_of_types({ACCT_TYPE_STOCK})};
EXPECT_THROW({
GncOptionAccountValue option("foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option("foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclistbad,
GncOptionAccountTypeList{ACCT_TYPE_BANK});
}, std::invalid_argument);
EXPECT_THROW({
GncOptionAccountValue option("foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option("foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_SEL,
acclistgood,
GncOptionAccountTypeList{ACCT_TYPE_BANK});
}, std::invalid_argument);
EXPECT_NO_THROW({
GncOptionAccountValue option("foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option("foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclistgood,
GncOptionAccountTypeList{ACCT_TYPE_BANK});
@ -792,12 +792,12 @@ TEST_F(GncOptionAccountTest, test_option_value_limited_constructor)
EXPECT_NO_THROW({
GncOptionAccountList accsel{acclistgood[0]};
GncOptionAccountValue option("foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option("foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
accsel,
GncOptionAccountTypeList{ACCT_TYPE_BANK});
});
GncOptionAccountValue option {"foo", "bar", "baz", "Bogus Option",
GncOptionAccountListValue option {"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST, acclistgood,
GncOptionAccountTypeList{ACCT_TYPE_BANK}};
EXPECT_FALSE(option.get_value().empty());
@ -809,7 +809,7 @@ TEST_F(GncOptionAccountTest, test_option_value_limited_constructor)
TEST_F(GncOptionAccountTest, test_account_list_out)
{
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOption option{GncOptionAccountValue{"foo", "bar", "baz", "Bogus Option",
GncOption option{GncOptionAccountListValue{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclist}};
std::ostringstream oss;
@ -821,7 +821,7 @@ TEST_F(GncOptionAccountTest, test_account_list_out)
EXPECT_EQ(acc_guids, oss.str());
GncOptionAccountList accsel{acclist[0]};
GncOption sel_option{GncOptionAccountValue{"foo", "bar", "baz",
GncOption sel_option{GncOptionAccountListValue{"foo", "bar", "baz",
"Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
accsel,
@ -836,7 +836,7 @@ TEST_F(GncOptionAccountTest, test_account_list_out)
TEST_F(GncOptionAccountTest, test_account_list_in)
{
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOption option{GncOptionAccountValue{"foo", "bar", "baz", "Bogus Option",
GncOption option{GncOptionAccountListValue{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclist}};
std::string acc_guids{gnc::GUID{*qof_instance_get_guid(acclist[0])}.to_string()};
@ -848,7 +848,7 @@ TEST_F(GncOptionAccountTest, test_account_list_in)
EXPECT_EQ(acclist, option.get_value<GncOptionAccountList>());
GncOptionAccountList accsel{acclist[0]};
GncOption sel_option{GncOptionAccountValue{"foo", "bar", "baz",
GncOption sel_option{GncOptionAccountListValue{"foo", "bar", "baz",
"Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
accsel,
@ -894,7 +894,7 @@ make_account_list_SCM_str(const GncOptionAccountList& acclist)
TEST_F(GncOptionAccountTest, test_account_list_to_scheme)
{
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOption option{GncOptionAccountValue {"foo", "bar", "baz", "Bogus Option",
GncOption option{GncOptionAccountListValue {"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclist}};
std::ostringstream oss;
@ -904,7 +904,7 @@ TEST_F(GncOptionAccountTest, test_account_list_to_scheme)
EXPECT_EQ(acc_guids, oss.str());
GncOptionAccountList accsel{acclist[0]};
GncOption sel_option{GncOptionAccountValue{"foo", "bar", "baz",
GncOption sel_option{GncOptionAccountListValue{"foo", "bar", "baz",
"Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
accsel,
@ -919,7 +919,7 @@ TEST_F(GncOptionAccountTest, test_account_list_to_scheme)
TEST_F(GncOptionAccountTest, test_account_list_from_scheme)
{
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOption option{GncOptionAccountValue{"foo", "bar", "baz", "Bogus Option",
GncOption option{GncOptionAccountListValue{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
acclist}};
@ -929,7 +929,7 @@ TEST_F(GncOptionAccountTest, test_account_list_from_scheme)
EXPECT_EQ(acclist, option.get_value<GncOptionAccountList>());
GncOptionAccountList accsel{acclist[0]};
GncOption sel_option{GncOptionAccountValue{"foo", "bar", "baz",
GncOption sel_option{GncOptionAccountListValue{"foo", "bar", "baz",
"Bogus Option",
GncOptionUIType::ACCOUNT_LIST,
accsel,

View File

@ -135,9 +135,9 @@
(list ACCT-TYPE-STOCK))))
(gnc-register-account-sel-limited-option
option-db "salt" "pork" "baz"
"Phony Option" (list (cadr acctlist)) (list ACCT-TYPE-STOCK))
"Phony Option" (cadr acctlist) (list ACCT-TYPE-STOCK))
(let ((acct (gnc-option-value option-db "salt" "pork")))
(test-equal (list (cadr acctlist)) acct)))))
(test-equal (cadr acctlist) acct)))))
(let* ((book (gnc-option-test-book-new))
(root-account (gnc-account-create-root book)))