Skip to content

Commit

Permalink
Merge Richard Cohen's 'restore-test-gnc-option' into stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Jun 6, 2023
2 parents d7c797a + fde90c4 commit 0f35543
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
5 changes: 5 additions & 0 deletions libgnucash/engine/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ gtest-qofevent.cpp)
gnc_add_test(test-qofevent "${test_qofevent_SOURCES}"
gtest_engine_INCLUDES gtest_old_engine_LIBS)

set(test_gnc_option_SOURCES
gtest-gnc-option.cpp
gtest-gnc-optiondb.cpp)
gnc_add_test(test-gnc-option "${test_gnc_option_SOURCES}"
gtest_engine_INCLUDES gtest_old_engine_LIBS)

set(test_engine_SOURCES_DIST
gtest-gnc-euro.cpp
Expand Down
11 changes: 2 additions & 9 deletions libgnucash/engine/test/gtest-gnc-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ class GncOptionAccountTest : public ::testing::Test
return account;
};
auto assets = create_account(m_root, ACCT_TYPE_ASSET, "Assets");
auto liabilities = create_account(m_root, ACCT_TYPE_LIABILITY, "Liabilities");
auto expenses = create_account(m_root, ACCT_TYPE_EXPENSE, "Expenses");
create_account(assets, ACCT_TYPE_BANK, "Bank");
auto broker = create_account(assets, ACCT_TYPE_ASSET, "Broker");
Expand Down Expand Up @@ -569,12 +568,6 @@ class GncOptionAccountTest : public ::testing::Test
Account* m_root;
};

static bool
operator==(const GncGUID& l, const GncGUID& r)
{
return guid_equal(&l, &r);
}

TEST_F(GncOptionAccountTest, test_test_constructor_and_destructor)
{
EXPECT_TRUE(m_book != NULL);
Expand Down Expand Up @@ -777,9 +770,9 @@ TEST_F(GncMultichoiceOption, test_permissible_value_stuff)
EXPECT_STREQ("waldo", m_option.permissible_value(1));
EXPECT_STREQ("sausage", m_option.permissible_value_name(2));
});
EXPECT_THROW({ auto result = m_option.permissible_value(7); },
EXPECT_THROW({ m_option.permissible_value(7); },
std::out_of_range);
EXPECT_THROW({ auto result = m_option.permissible_value_name(9); },
EXPECT_THROW({ m_option.permissible_value_name(9); },
std::out_of_range);
EXPECT_EQ(std::numeric_limits<uint16_t>::max(),
m_option.permissible_value_index("xyzzy"));
Expand Down
10 changes: 0 additions & 10 deletions libgnucash/engine/test/gtest-gnc-optiondb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ struct GncOptionDBAccountTest : public ::testing::Test
return account;
};
auto assets = create_account(m_root, ACCT_TYPE_ASSET, "Assets");
auto liabilities = create_account(m_root, ACCT_TYPE_LIABILITY, "Liabilities");
auto expenses = create_account(m_root, ACCT_TYPE_EXPENSE, "Expenses");
create_account(assets, ACCT_TYPE_BANK, "Bank");
auto broker = create_account(assets, ACCT_TYPE_ASSET, "Broker");
Expand Down Expand Up @@ -288,12 +287,6 @@ TEST_F(GncOptionDBTest, test_register_start_date_option)

}

static bool
operator==(const GncGUID& l, const GncGUID& r)
{
return guid_equal(&l, &r);
}

class GncOptionDBIOTest : public ::testing::Test
{
protected:
Expand All @@ -315,7 +308,6 @@ class GncOptionDBIOTest : public ::testing::Test
return account;
};
auto assets = create_account(m_root, ACCT_TYPE_ASSET, "Assets");
auto liabilities = create_account(m_root, ACCT_TYPE_LIABILITY, "Liabilities");
auto expenses = create_account(m_root, ACCT_TYPE_EXPENSE, "Expenses");
create_account(assets, ACCT_TYPE_BANK, "Bank");
auto broker = create_account(assets, ACCT_TYPE_ASSET, "Broker");
Expand Down Expand Up @@ -384,14 +376,12 @@ TEST_F(GncOptionDBIOTest, test_option_kvp_save)
auto bar = "bar";
auto sausage = "sausage";
auto grault = "grault";
auto garply = "garply";
GSList foo_bar_tail{(void*)bar, nullptr};
GSList foo_bar_head{(void*)foo, &foo_bar_tail};
GSList foo_sausage_tail{(void*)sausage, nullptr};
GSList foo_sausage_head{(void*)foo, &foo_sausage_tail};
GSList qux_grault_tail{(void*)grault, nullptr};
GSList qux_grault_head{(void*)foo, &qux_grault_tail};
GSList qux_garply_tail{(void*)garply, nullptr};
GSList qux_garply_head{(void*)foo, &qux_grault_tail};
m_db->set_option("foo", "sausage", std::string{"pepper"});
m_db->save_to_kvp(m_book, true);
Expand Down

0 comments on commit 0f35543

Please sign in to comment.