drleq / cppunittestframework Goto Github PK
View Code? Open in Web Editor NEWA simple single header C++17 unit test framework
License: MIT License
A simple single header C++17 unit test framework
License: MIT License
Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreNotEqual( expected_value, actual_value, because );
Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail( because );
CHAMOIS_UNITTEST_FRAMEWORK
-> Copyright 2014 Oli Wilkinson
I am running Linux (Fedora 36 to be exact) here, and when I try to compile some unit tests using this framework, they fail to build with this error message:
CppUnitTestFramework.hpp:561:47: error: ‘numeric_limits’ is not a member of ‘std’
561 | if ((b < 1.0f) && (a > b*std::numeric_limits::max())) {
Looking at this 'c++ reference' site: https://en.cppreference.com/w/cpp/types/numeric_limits it seems that using 'std::numeric_limits' would require '#include <limits>', and indeed if I add that include between lines 7 and 8 of 'CppUnitTestFramework.hpp', I am then able to build my unit tests successfully.
Thanks,
Franco
Please see the equivalents in #24
I would like to create a Visual Studio 2022 project for existing UnitTests implemented for the CppUnit test framework. The tests should be visualized in the test explorer. The tests are additionally built in the Linux build environment.
In Visual Studio the plugin 'Test Adapter for CppUnitTestFramework' is installed. However, the plugin requires that the tests are implemented as follows:
#include "CppUnitTest.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest3
{
TEST_CLASS(UnitTest3)
{
public:
TEST_METHOD(TestMethod1)
{
}
};
}
But my existing CppUnit tests have the following structure:
class TestCases : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestCases);
CPPUNIT_TEST(TestMethod1);
CPPUNIT_TEST(TestMethod2);
CPPUNIT_TEST_SUITE_END();
};
Do I need to implement my own C++ macros that convert the format to the appropriate format for Visual Studio and gcc? Or is there already something existing?
e.g. BOOST_AUTO_TEST_CASE( A010_CreateDocClass, *utf::timeout( 1 ) )
I have used CHECK_EQUAL to verify a std::optional variable is std::nullopt and get the following compiler error:
CppUnitTestFramework.hpp:439:63: error: no matching function for
call to 'ToString'
auto msg = "[" + Ext::ToString(left) + "] == [" + Ext::ToString(right) + "]";
I had a look to the 'ToString' function and have seen that none of the constexpression checks catch a std::nullopt, so the function ends up with the last else block, which assumes std::to_string(value) can be used. This is where the compiler throws the above error.
I don't have have a good solution to this problem and therefore cannot offer a pull request. For now, I was able to mitigate it by inserting the following code before the last else:
} else if constexpr (std::is_literal_type<T>::value) {
// std::nullopt
return "literal_type";
Hope this helps and someone can improve it.
Hello,
Thanks for sharing this. Can you please share detailed steps on how to get this framework working with my Visual Studio Code workspace? I have extension installed. Should I copy this repo to my workspace? My test.cpp has trouble finding .hpp file. Also some more information on Configuration properties or example usage would really help. Apologise for inconvenience. I am new with Visual Studio Code.
Thanks in advance.
Regards,
Rishit
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.