static void test_bool_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gboolean), gboolean (*get) (const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gboolean num = get_random_boolean (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, FALSE); set (employee, TRUE); set (employee, num); /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); /* Employee record should be not dirty */ /* Skip, because will always fail without a backend. * It's not possible to load a backend in the engine code * without having circular dependencies. */ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_gint_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gint), gint (*get) (GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gint num = 17; do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_numeric_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gnc_numeric), gnc_numeric (*get)(const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gnc_numeric num = gnc_numeric_create (17, 1); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (gnc_numeric_equal (get (employee), num), message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_string_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, const char *str), const char * (*get)(const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); char const *str = get_random_string (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, str); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (safe_strcmp (get (employee), str) == 0, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_bool_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gboolean), gboolean (*get) (const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gboolean num = get_random_boolean (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, FALSE); set (employee, TRUE); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }