Giter VIP home page Giter VIP logo

cppunittestframework's People

Contributors

acondie avatar drleq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nicolaze

cppunittestframework's Issues

Missing <limits> include in 'CppUnitTestFramework.hpp'

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

Different CppUnit macros

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?

CHECK_EQUAL and std::nullopt

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.

How to get this working with my Visual Studio Code after installing Extension?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.