Skip to content

Unittesting a bool operator fails #119

Closed

Description

@grahamreeds

I detailed the issue I am having here:
http://stackoverflow.com/questions/38330348/continuous-error-21-library-routine-called-out-of-sequence
I have since narrowed it down to a piece of code. This passes:

    TEST_FIXTURE(DatabaseFixture, TryToCreateATable)
    {
        database db(test);
        CHECK(db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)"));
    }

But this fails (normally it is REQUIRE CHECK(db) but I removed it to make sure it isn't REQUIRE causing issues).

    TEST_FIXTURE(DatabaseFixture, TryToCreateATable)
    {
        database db(test);
        CHECK(db);
        CHECK(db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)"));
    }

The db boolean check is

operator bool() const { return connected_; }

If you replace the CHECK(db); line with the following:

if (!db) std::cout << "Not connected! " << db.error() << std::endl;

It passes. You can see the bool operator is called by placing a cout in there just to acknowledge the call.

While I initially thought it was Sqlite3 related it appears it is the boolean operator causing the issue.

Activity

  1. grahamreeds commented on Jul 13, 2016

    @grahamreeds
    ContributorAuthor

    One of the eagle eyed developers on SO points out it is related to #7

  2. added a commit that references this issue on Jul 16, 2016
    21589e5
  3. added this to the 2.0.0 milestone on Aug 17, 2016
  4. self-assigned this
    on Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions