[test-lots.cpp] add kvp getter/setter changes

This commit is contained in:
Christopher Lam 2021-08-31 00:27:30 +08:00
parent 323182c9f7
commit 1eb6709331

View File

@ -32,6 +32,7 @@ extern "C"
#include <ctype.h> #include <ctype.h>
#include "qof.h" #include "qof.h"
#include "Account.h" #include "Account.h"
#include "gnc-lot.h"
#include "Scrub3.h" #include "Scrub3.h"
#include "cashobjects.h" #include "cashobjects.h"
#include "test-stuff.h" #include "test-stuff.h"
@ -42,6 +43,48 @@ extern "C"
static gint transaction_num = 32; static gint transaction_num = 32;
static gint max_iterate = 1; static gint max_iterate = 1;
static void
test_lot_kvp ()
{
QofSession *sess = get_random_session ();
QofBook *book = qof_session_get_book (sess);
GNCLot *lot = gnc_lot_new (book);
// title
g_assert_cmpstr (gnc_lot_get_title (lot), ==, NULL);
gnc_lot_set_title (lot, "");
g_assert_cmpstr (gnc_lot_get_title (lot), ==, "");
gnc_lot_set_title (lot, "doc");
g_assert_cmpstr (gnc_lot_get_title (lot), ==, "doc");
gnc_lot_set_title (lot, "unset");
g_assert_cmpstr (gnc_lot_get_title (lot), ==, "unset");
gnc_lot_set_title (lot, NULL);
g_assert_cmpstr (gnc_lot_get_title (lot), ==, NULL);
// notes
g_assert_cmpstr (gnc_lot_get_notes (lot), ==, NULL);
gnc_lot_set_notes (lot, "");
g_assert_cmpstr (gnc_lot_get_notes (lot), ==, "");
gnc_lot_set_notes (lot, "doc");
g_assert_cmpstr (gnc_lot_get_notes (lot), ==, "doc");
gnc_lot_set_notes (lot, "unset");
g_assert_cmpstr (gnc_lot_get_notes (lot), ==, "unset");
gnc_lot_set_notes (lot, NULL);
g_assert_cmpstr (gnc_lot_get_notes (lot), ==, NULL);
gnc_lot_destroy (lot);
qof_session_end (sess);
}
static void static void
run_test (void) run_test (void)
{ {
@ -94,6 +137,9 @@ main (int argc, char **argv)
fflush(stdout); fflush(stdout);
run_test (); run_test ();
} }
test_lot_kvp ();
/* 'erase' the recurring tag line with dummy spaces. */ /* 'erase' the recurring tag line with dummy spaces. */
fprintf(stdout, "Lots: Test series complete.\n"); fprintf(stdout, "Lots: Test series complete.\n");
fflush(stdout); fflush(stdout);