Skip to content

Commit

Permalink
Handle some minor differences between libc++ (clang) and libstdc++ (g…
Browse files Browse the repository at this point in the history
…cc).
  • Loading branch information
jralls committed Jul 11, 2021
1 parent cd6ccbe commit 20b3ef8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 3 additions & 0 deletions libgnucash/app-utils/gnc-option.hpp
Expand Up @@ -409,7 +409,10 @@ gnc_option_from_scheme (std::istream& iss, OptType& opt)
{
iss.ignore(strlen(commodity_scm_intro) + 1, '"');
std::getline(iss, name_space, '"');
// libc++ doesn't consume the end character, libstdc++ does
#ifdef _LIBCPP_VERSION
iss.ignore(1, '"');
#endif
}
else
name_space = GNC_COMMODITY_NS_CURRENCY;
Expand Down
8 changes: 8 additions & 0 deletions libgnucash/app-utils/gnc-optiondb.cpp
Expand Up @@ -256,7 +256,11 @@ scan_scheme_symbol_from_streambuf(std::streambuf* sbuf)
return retval;
}

#ifdef _LIBCPP_VERSION
static inline void constexpr
#else
static inline void
#endif
consume_scheme_comment(std::streambuf* sbuf)
{
while (sbuf->in_avail() && !is_eol(sbuf->sgetc()))
Expand All @@ -273,7 +277,11 @@ scan_scheme_string_from_streambuf(std::streambuf* sbuf)
return retval;
}

#ifdef _LIBCPP_VERSION
static inline void constexpr
#else
static inline void
#endif
consume_scheme_whitespace(std::streambuf* sbuf)
{
while (sbuf->in_avail() && is_whitespace(sbuf->sgetc()))
Expand Down
15 changes: 8 additions & 7 deletions libgnucash/app-utils/test/gtest-gnc-option.cpp
Expand Up @@ -667,9 +667,9 @@ TEST_F(GncOptionAccountTest, test_test_constructor_and_destructor)
EXPECT_TRUE(m_root != NULL);
EXPECT_TRUE(GNC_IS_ACCOUNT(m_root));
GncOptionAccountList list{list_of_types({ACCT_TYPE_BANK})};
EXPECT_EQ(2, list.size());
EXPECT_EQ(2U, list.size());
list = list_of_types({ACCT_TYPE_ASSET, ACCT_TYPE_STOCK});
EXPECT_EQ(6, list.size());
EXPECT_EQ(6U, list.size());
}

TEST_F(GncOptionAccountTest, test_option_no_value_constructor)
Expand All @@ -685,8 +685,8 @@ TEST_F(GncOptionAccountTest, test_option_value_constructor)
GncOptionAccountList acclist{list_of_types({ACCT_TYPE_BANK})};
GncOptionAccountValue option{"foo", "bar", "baz", "Bogus Option",
GncOptionUIType::ACCOUNT_LIST, acclist};
EXPECT_EQ(2, option.get_value().size());
EXPECT_EQ(2, option.get_default_value().size());
EXPECT_EQ(2U, option.get_value().size());
EXPECT_EQ(2U, option.get_default_value().size());
EXPECT_EQ(acclist[0], option.get_value()[0]);
}

Expand All @@ -695,7 +695,8 @@ 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",
GncOptionUIType::ACCOUNT_LIST, {ACCT_TYPE_BANK}};
GncOptionUIType::ACCOUNT_LIST,
GncOptionAccountTypeList{ACCT_TYPE_BANK}};
EXPECT_TRUE(option.get_value().empty());
EXPECT_TRUE(option.get_default_value().empty());
EXPECT_EQ(true, option.validate(acclistgood));
Expand Down Expand Up @@ -919,13 +920,13 @@ TEST_F(GncMultichoiceOption, test_set_value)

TEST_F(GncMultichoiceOption, test_num_permissible)
{
EXPECT_EQ(4, m_option.num_permissible_values());
EXPECT_EQ(4U, m_option.num_permissible_values());
}

TEST_F(GncMultichoiceOption, test_permissible_value_stuff)
{
EXPECT_NO_THROW({
EXPECT_EQ(3, m_option.permissible_value_index("corge"));
EXPECT_EQ(3U, m_option.permissible_value_index("corge"));
EXPECT_STREQ("waldo", m_option.permissible_value(1).c_str());
EXPECT_STREQ("sausage", m_option.permissible_value_name(2).c_str());
EXPECT_STREQ("thud",
Expand Down
10 changes: 5 additions & 5 deletions libgnucash/app-utils/test/gtest-gnc-optiondb.cpp
Expand Up @@ -129,7 +129,7 @@ TEST_F(GncOptionDBTest, test_register_account_list_option)
auto acclist{gnc_account_list_from_types(book.m_book, {ACCT_TYPE_STOCK})};
gnc_register_account_list_option(m_db, "foo", "bar", "baz", "Phony Option",
acclist);
EXPECT_EQ(4, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(4U, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(acclist[3], m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().at(3));
}

Expand All @@ -140,7 +140,7 @@ TEST_F(GncOptionDBTest, test_register_account_list_limited_option)
gnc_register_account_list_limited_option(m_db, "foo", "bar", "baz",
"Phony Option", acclist,
{ACCT_TYPE_STOCK});
EXPECT_EQ(4, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(4U, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(acclist[3], m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().at(3));
}

Expand All @@ -152,7 +152,7 @@ TEST_F(GncOptionDBTest, test_register_account_sel_limited_option)
gnc_register_account_list_limited_option(m_db, "foo", "bar", "baz",
"Phony Option", accsel,
{ACCT_TYPE_STOCK});
EXPECT_EQ(1, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(1U, m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(accsel[0], m_db->find_option("foo", "bar")->get().get_value<GncOptionAccountList>().at(0));
}

Expand Down Expand Up @@ -408,7 +408,7 @@ TEST_F(GncOptionDBIOTest, test_account_list_option_scheme_input)
EXPECT_EQ(acclist[1], m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>()[0]);
m_db->load_option_scheme(iss);
EXPECT_EQ(acclist[2], m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>()[1]);
EXPECT_EQ(2, m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(2U, m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>().size());

}

Expand Down Expand Up @@ -448,7 +448,7 @@ TEST_F(GncOptionDBIOTest, test_multiple_options_scheme_input)
EXPECT_STREQ("pepper", m_db->lookup_string_option("foo", "sausage").c_str());
EXPECT_EQ(time1, m_db->find_option("pork", "garply")->get().get_value<time64>());
EXPECT_EQ(acclist[2], m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>()[1]);
EXPECT_EQ(2, m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>().size());
EXPECT_EQ(2U, m_db->find_option("quux", "xyzzy")->get().get_value<GncOptionAccountList>().size());

}

Expand Down

0 comments on commit 20b3ef8

Please sign in to comment.