Unit testing non-exported classes in a DLL

Expanding on Tom Quarendon’s answer to this question, I have used a slight variant of Simon Steele’s response: Create a test project (using whatever test framework you like, I use CppUnit). In your test_case.cpp, #include <header/in/source/project.h>. In the test project properties: In Linker->General, add the source project’s $(IntDir) to the Additional Library Directories. In Linker->Input, … Read more

CMake: Project structure with unit tests

For questions 1 & 2, I would recommend making a library from your non-test files excluding main.cpp (in this case just src/sqr.cpp and src/sqr.h), and then you can avoid listing (and more importantly re-compiling) all the sources twice. For question 3, these commands add a test called “MyTest” which invokes your executable “test” without any … Read more

Comparison of C++ unit test frameworks [duplicate]

A new player is Google Test (also known as Google C++ Testing Framework) which is pretty nice though. #include <gtest/gtest.h> TEST(MyTestSuitName, MyTestCaseName) { int actual = 1; EXPECT_GT(actual, 0); EXPECT_EQ(1, actual) << “Should be equal to one”; } Main features: Portable Fatal and non-fatal assertions Easy assertions informative messages: ASSERT_EQ(5, Foo(i)) << ” where i … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)