Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::queue not changing size after push in test case #1378

Closed
syntactical opened this issue Sep 6, 2018 · 2 comments
Closed

std::queue not changing size after push in test case #1378

syntactical opened this issue Sep 6, 2018 · 2 comments

Comments

@syntactical
Copy link

syntactical commented Sep 6, 2018

Description

I'm writing a test that involves pushing items to a queue:

TEST_CASE( "strings are returned as-is", "[multi-file:2]" ){
    Parser parser;

    LettersGroupToken t("abcdef");

    std::queue<Token*> tokens;
    tokens.push(&t);

    std::vector<std::string> items = parser.parse(tokens);

    REQUIRE( items.size() == 1 );
    REQUIRE(items[0] == "abcdef" );
}

My issue is with tokens.push(&t);. It does not change the size of the queue tokens. After the push operation the size of tokens is zero. The same behavior happens when using emplace.

I've tried using a vector instead of a queue, and push_back works as intended, changing the size of the vector. I need to use a queue though...

Other things I've tried:

  • Defining CATCH_CONFIG_MAIN in the same file as this test case - still seeing this error
  • Defining CATCH_CONFIG_MAIN in another file - still seeing this error
  • Removing [multi-file:2] tag - still seeing this error
  • Changing to std::queue<int> - still seeing this error

BUT, moving this code to a main method of the program made the bug go away - the queue behaved as normal.

... really confused! :(

Extra information

This is the actual error I'm getting in the CLion test runner:

/fakepath/test/ParserTest.cpp:14: Failure:
fatal error
Process finished with exit code 132 (interrupted by signal 4: SIGILL)
  • Catch version: v2.3.0
  • Operating System: macOS High Sierra
  • IDE: CLion 2018.2.2
  • Compiler+version: Whatever default C++ compiler used by XCode 9.4.1
@syntactical
Copy link
Author

Never mind-- this looks like it's a bug in CLion that makes it impossible to inspect certain containers when running tests.

@horenmar
Copy link
Member

horenmar commented Sep 9, 2018

Ok, thanks for reporting back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants