sheredom / utest.h

🧪 single header unit testing framework for C and C++
The Unlicense
834 stars 57 forks source link

Support tests on C++ std::string #89

Closed tekknolagi closed 2 years ago

tekknolagi commented 2 years ago

This is helpful for C++ projects.

tekknolagi commented 2 years ago

I am not able to figure out what's going on with the tests -- when trying to build them, I get errors about trying to add std::string and int because for whatever reason, even in C++ mode, UTEST_AUTO is expanding to typeof(x + 1). I can try and come back to this later if you want this feature at all.

tekknolagi commented 2 years ago

In any case, thank you very much for this project :)

sheredom commented 2 years ago

The issue is that pre C++11 didn't have auto, and so the UTEST_AUTO macro is going back to the C version which uses typeof. I needed to do typeof(x + 0) to force type resolution (painful, horrific, but works!). I guess if you only added the test to https://github.com/sheredom/utest.h/blob/master/test/test11.cpp it'd work.

tekknolagi commented 2 years ago

Oh! This is... fascinating. I will take a look at doing that. Thank you.

tekknolagi commented 2 years ago

Huh. Not sure what is going on with Windows.