In an effort to learn the gnucash code, I am looking at adding more
coverage in the test framework.

I am working on full coverage of the libgnucash/engine/qofid.c file.
(It did not have full coverage, and looked like it depended on the
least other stuffl.  I think the gtest is one that y'all consider
appropriate for new tests.)

I get extra output when testing the error handling.  In particular, in
the this test....

TEST(QofIDTest, collection_add)
{
    auto col = qof_collection_new(QOF_ID_BOOK);
    auto book = qof_book_new();
    auto job = gncJobCreate(book);
    gncJobBeginEdit(job);

    EXPECT_FALSE(qof_collection_add_entity(NULL, NULL));
    EXPECT_FALSE(qof_collection_add_entity(col, NULL));
    EXPECT_FALSE(qof_collection_add_entity(NULL, QOF_INSTANCE(book)));

    EXPECT_TRUE(qof_collection_add_entity(col, QOF_INSTANCE(book)));
    EXPECT_FALSE(qof_collection_add_entity(col, QOF_INSTANCE(book)));
    EXPECT_FALSE(qof_collection_add_entity(col, QOF_INSTANCE(job)));

    gncJobDestroy(job);
    qof_collection_destroy(col);
}

I get extra output for the check jince I cannot add a job to a
collection of books.  When running I get:

53: Test command: /home/sk/gnucash/build-debug/bin/test-qofid
53: Working Directory: /home/sk/gnucash/build-debug/libgnucash/engine/test
53: Environment variables:
53:  GNC_UNINSTALLED=YES
53:  GNC_BUILDDIR=/home/sk/gnucash/build-debug
53: Test timeout computed to be: 10000000
53: Running main() from /usr/src/googletest/googletest/src/gtest_main.cc
53: [==========] Running 2 tests from 1 test suite.
53: [----------] Global test environment set-up.
53: [----------] 2 tests from QofIDTest
53: [ RUN      ] QofIDTest.collection_new
53: [       OK ] QofIDTest.collection_new (0 ms)
53: [ RUN      ] QofIDTest.collection_add
53:
53: (process:179319): gnc.engine-CRITICAL **: 14:35:03.788: gboolean
qof_collection_add_entity(QofCollection*, QofInstance*): assertion
'coll->e_type == ent->e_type' failed
53: [       OK ] QofIDTest.collection_add (0 ms)
53: [----------] 2 tests from QofIDTest (0 ms total)
53:
53: [----------] Global test environment tear-down
53: [==========] 2 tests from 1 test suite ran. (0 ms total)
53: [  PASSED  ] 2 tests.
1/1 Test #53: test-qofid .......................   Passed    0.02 sec

This is due to the "g_return_val_if_fail (coll->e_type == ent->e_type,
FALSE);" inside the qof_collection_add_entity function.

The test still passes, but the output is messed up.   Is there a way
to setup the expectation for this assertion failure, and thus hide the
output?  Or should I not worry about this?
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to