mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Provide scheme function new-gnc-optiondb.
Wraps creating a GncOptionDBPtr, freeing up gnc_option_db_new() to return a GncOptionDB* for use in C code. Convert gnc_option_db_new() calls in gtest-gnc-optiondb to call std::make_unique() as well.
This commit is contained in:
parent
f9e136dbac
commit
6feb92d4e8
@ -415,6 +415,13 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
|
||||
}
|
||||
GncOption_set_value_from_scm(db_opt, new_value);
|
||||
}
|
||||
|
||||
GncOptionDBPtr
|
||||
new_gnc_optiondb()
|
||||
{
|
||||
auto db_ptr{std::make_unique<GncOptionDB>()};
|
||||
return db_ptr;
|
||||
}
|
||||
%}
|
||||
|
||||
#endif //SWIGGUILE
|
||||
|
@ -36,7 +36,7 @@ extern "C"
|
||||
class GncOptionDBTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
GncOptionDBTest() : m_db{gnc_option_db_new()} {}
|
||||
GncOptionDBTest() : m_db{std::make_unique<GncOptionDB>()} {}
|
||||
|
||||
GncOptionDBPtr m_db;
|
||||
};
|
||||
@ -271,7 +271,9 @@ TEST_F(GncOptionDBTest, test_register_start_date_option)
|
||||
class GncOptionDBIOTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
GncOptionDBIOTest() : m_book{gnc_get_current_book()}, m_root{gnc_account_create_root(m_book)}, m_db{gnc_option_db_new()}
|
||||
GncOptionDBIOTest() :
|
||||
m_book{gnc_get_current_book()}, m_root{gnc_account_create_root(m_book)},
|
||||
m_db{std::make_unique<GncOptionDB>()}
|
||||
{
|
||||
auto create_account = [this](Account* parent, GNCAccountType type,
|
||||
const char* name)->Account* {
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
(define (test-gnc-make-text-option)
|
||||
(test-begin "test-gnc-test-string-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(string-opt (gnc-register-string-option option-db "foo" "bar" "baz"
|
||||
"Phony Option" "waldo")))
|
||||
(test-equal "waldo" (gnc-option-value option-db "foo" "bar"))
|
||||
@ -89,7 +89,7 @@
|
||||
|
||||
(define (test-make-account-list-option book)
|
||||
(test-group "test-make-account-list-option"
|
||||
(let ((optiondb (gnc-option-db-new))
|
||||
(let ((optiondb (new-gnc-optiondb))
|
||||
(acctlist (gnc-account-list-from-types book
|
||||
(list ACCT-TYPE-STOCK))))
|
||||
(gnc-register-account-list-option optiondb "foo" "bar" "baz"
|
||||
@ -100,7 +100,7 @@
|
||||
|
||||
(define (test-make-account-list-limited-option book)
|
||||
(test-group "test-make-account-list-option"
|
||||
(let ((optiondb (gnc-option-db-new))
|
||||
(let ((optiondb (new-gnc-optiondb))
|
||||
(acctlist (gnc-account-list-from-types book
|
||||
(list ACCT-TYPE-STOCK))))
|
||||
(gnc-register-account-list-limited-option optiondb "foo" "bar" "baz"
|
||||
@ -115,7 +115,7 @@
|
||||
|
||||
(define (test-make-account-sel-limited-option book)
|
||||
(test-group "test-make-account-list-option"
|
||||
(let ((optiondb (gnc-option-db-new))
|
||||
(let ((optiondb (new-gnc-optiondb))
|
||||
(acctlist (gnc-account-list-from-types book
|
||||
(list ACCT-TYPE-STOCK))))
|
||||
(gnc-register-account-sel-limited-option optiondb "salt" "pork" "baz"
|
||||
@ -148,7 +148,7 @@
|
||||
(assq-ref (assq-ref keylist key) info))
|
||||
|
||||
(test-begin "test-gnc-test-multichoice-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(multilist (list
|
||||
(list "plugh" (cons 'text "xyzzy") (cons 'tip "thud"))
|
||||
(list "waldo" (cons 'text "pepper") (cons 'tip "salt"))
|
||||
@ -166,7 +166,7 @@
|
||||
|
||||
(define (test-gnc-make-list-option)
|
||||
(test-begin "test-gnc-test-list-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(value-list (list (vector "AvgBalPlot" "Average" "Average Balance")
|
||||
(vector "GainPlot" "Profit" "Profit (Gain minus Loss)")
|
||||
(vector "GLPlot" "Gain/Loss" "Gain and Loss")))
|
||||
@ -181,7 +181,7 @@
|
||||
|
||||
(define (test-gnc-make-date-option)
|
||||
(test-begin "test-gnc-test-date-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(date-opt (gnc-register-date-option option-db "foo" "bar"
|
||||
"baz" "Phony Option"
|
||||
(RelativeDatePeriod-today)))
|
||||
@ -193,7 +193,7 @@
|
||||
|
||||
(define (test-gnc-make-date-set-option)
|
||||
(test-begin "test-gnc-test-date-set-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(date-opt (gnc-register-date-option-set
|
||||
option-db "foo" "bar" "baz" "Phony Option"
|
||||
(list (RelativeDatePeriod-today)
|
||||
@ -210,7 +210,7 @@
|
||||
|
||||
(define (test-gnc-make-number-range-option)
|
||||
(test-begin "test-gnc-number-range-option")
|
||||
(let* ((option-db (gnc-option-db-new))
|
||||
(let* ((option-db (new-gnc-optiondb))
|
||||
(number-opt (gnc-register-number-range-option option-db "foo" "bar"
|
||||
"baz" "Phony Option"
|
||||
15 5 30 1)))
|
||||
|
Loading…
Reference in New Issue
Block a user