mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move test-account and test-split into engine/test directory
This commit is contained in:
parent
13c7abc978
commit
3e7c8fa45a
@ -53,7 +53,11 @@ TESTS = \
|
||||
test-vendor \
|
||||
$(SCM_TESTS)
|
||||
|
||||
SCM_TESTS = test-test-extras
|
||||
SCM_TESTS = \
|
||||
test-test-extras \
|
||||
test-account \
|
||||
test-split
|
||||
|
||||
SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
|
||||
|
||||
GNC_TEST_DEPS = \
|
||||
|
@ -1,6 +1,6 @@
|
||||
(use-modules (gnucash engine))
|
||||
|
||||
(use-modules (gnucash report report-system test test-extras))
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
(use-modules (sw_engine))
|
||||
|
||||
(define (run-test)
|
||||
|
@ -4,9 +4,9 @@
|
||||
(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
|
||||
|
||||
(use-modules (gnucash engine))
|
||||
(use-modules (gnucash report report-system test test-extras))
|
||||
|
||||
(use-modules (gnucash report report-system))
|
||||
(use-modules (sw_engine))
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
(use-modules (gnucash app-utils))
|
||||
|
||||
(define (run-test)
|
||||
(test test-split-in-list?))
|
||||
|
46
src/engine/test/test-test-extras.scm
Normal file
46
src/engine/test/test-test-extras.scm
Normal file
@ -0,0 +1,46 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(debug-set! stack 50000)
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
(use-modules (ice-9 streams))
|
||||
(use-modules (gnucash engine))
|
||||
(use-modules (sw_engine))
|
||||
|
||||
(define (run-test)
|
||||
(and (logging-and #t)
|
||||
(logging-and)
|
||||
(not (logging-and #t #f))
|
||||
(test-create-account-structure)))
|
||||
|
||||
(define (test-create-account-structure)
|
||||
(let ((env (create-test-env)))
|
||||
(let ((accounts (env-create-account-structure env (list "Assets"
|
||||
(list (cons 'type ACCT-TYPE-ASSET))
|
||||
(list "Bank Account")
|
||||
(list "Savings"
|
||||
(list "Instant")
|
||||
(list "30 day notice"))))))
|
||||
(and (= 3 (length accounts))
|
||||
(equal? "Assets" (xaccAccountGetName (car accounts)))
|
||||
))))
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
(define-module (gnucash report report-system account))
|
||||
(use-modules (gnucash gnc-module))
|
||||
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
(define-module (gnucash report report-system split))
|
||||
(use-modules (gnucash gnc-module))
|
||||
|
||||
(gnc:module-begin-syntax (gnc:module-load "gnucash/engine" 0))
|
||||
|
||||
(use-modules (sw_engine))
|
||||
|
@ -22,8 +22,6 @@ SCM_TESTS = \
|
||||
test-collectors \
|
||||
test-list-extras \
|
||||
test-test-extras \
|
||||
test-account \
|
||||
test-split \
|
||||
test-report-utilities
|
||||
|
||||
SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
|
||||
|
@ -1,47 +0,0 @@
|
||||
(use-modules (gnucash engine))
|
||||
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
(use-modules (sw_engine))
|
||||
|
||||
(define (run-test)
|
||||
(test test-account-same?)
|
||||
(test test-account-in-list?)
|
||||
(test test-account-in-alist?)
|
||||
(test test-account-list-predicate))
|
||||
|
||||
(define (test-account-same?)
|
||||
(let* ((env (create-test-env))
|
||||
(account-alist (env-create-test-accounts env))
|
||||
(bank-account (cdr (assoc "Bank" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist))))
|
||||
(and (account-same? bank-account bank-account)
|
||||
(not (account-same? bank-account expense-account)))))
|
||||
|
||||
(define (test-account-in-alist?)
|
||||
(let* ((env (create-test-env))
|
||||
(account-alist (env-create-test-accounts env))
|
||||
(bank-account (cdr (assoc "Bank" account-alist)))
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist))))
|
||||
(let ((alist (list (cons bank-account "Bank") (cons expense-account "Expenses"))))
|
||||
(and (account-in-alist bank-account alist)
|
||||
(account-in-alist expense-account alist)
|
||||
(not (account-in-alist wallet-account alist))))))
|
||||
|
||||
(define (test-account-in-list?)
|
||||
(test-account-list-predicate-generic
|
||||
(lambda (accounts) (lambda (account) (account-in-list? account accounts)))))
|
||||
|
||||
(define (test-account-list-predicate)
|
||||
(test-account-list-predicate-generic account-in-list-pred))
|
||||
|
||||
(define (test-account-list-predicate-generic predicate)
|
||||
(let* ((env (create-test-env))
|
||||
(account-alist (env-create-test-accounts env))
|
||||
(bank-account (cdr (assoc "Bank" account-alist)))
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(other-account (cdr (assoc "Other" account-alist)))
|
||||
(bank-or-wallet? (predicate (list bank-account wallet-account))))
|
||||
(and (bank-or-wallet? bank-account)
|
||||
(bank-or-wallet? wallet-account)
|
||||
(not (bank-or-wallet? other-account)))))
|
@ -1,33 +0,0 @@
|
||||
(use-modules (gnucash gnc-module))
|
||||
(use-modules (srfi srfi-1))
|
||||
|
||||
(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
|
||||
|
||||
(use-modules (gnucash engine))
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
|
||||
(use-modules (gnucash report report-system))
|
||||
|
||||
(define (run-test)
|
||||
(test test-split-in-list?))
|
||||
|
||||
(define (test-split-in-list?)
|
||||
(let* ((env (create-test-env))
|
||||
(today (gnc:date->timepair (localtime (current-time))))
|
||||
(account-alist (env-create-test-accounts env))
|
||||
(bank-account (cdr (assoc "Bank" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(tx1 (env-create-transaction env today bank-account wallet-account (gnc:make-gnc-numeric 20 1)))
|
||||
(tx2 (env-create-transaction env today bank-account expense-account (gnc:make-gnc-numeric 10 1)))
|
||||
(splits-tx1 (xaccTransGetSplitList tx1))
|
||||
(splits-tx2 (xaccTransGetSplitList tx2)))
|
||||
(and (split-in-list? (first splits-tx1) splits-tx1)
|
||||
(split-in-list? (second splits-tx1) splits-tx1)
|
||||
(not (split-in-list? (first splits-tx1) splits-tx2))
|
||||
(not (split-in-list? (second splits-tx1) splits-tx2))
|
||||
(not (split-in-list? (first splits-tx1) '())))))
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user