All Questions
194 questions
0
votes
1
answer
69
views
How to call a template function to test in another file to test it with CppUnit [duplicate]
I am creating a simple MergeSort algorithm with array type(array<int,N>).
The function mergeSortByMyself is written with templates.
I want to test it with CppUnit, but when I run the code, it ...
0
votes
2
answers
674
views
GCC linking CppUnit gives undefined references (Ubuntu 20.04)
I'm failing to link CppUnit (libcppunit.so) with GCC on Ubuntu/Linux. What am I doing wrong?
For reproducibility, I used Docker as follows:
docker run -it -w /opt/myproject --name cxx ubuntu:20.04 /...
0
votes
0
answers
85
views
Expected unqualified-id :4. How to fix it?
#define SUM(__FIRST_NUM, __SECOND_NUM) __SUM_
template <class __TYPE_>
__TYPE_ __SUM_(__TYPE_ &__FIRST_NUM, __TYPE_ &__SECOND_NUM)
return __FIRST_NUM + __SECOND_NUM; //<- ...
0
votes
0
answers
20
views
How do i use overloading with friend function [duplicate]
I am new to coding with c++ and I am confused about how to fix the error message popping out with the code below.
The error message reads:
/tmp/cc3Qc0nv.0: In function 'main':
main.cpp:(.text+0x73a): ...
1
vote
1
answer
2k
views
How to include third party tools with cmake?
I have been working on a CPP project but was using configuration on visual studio IDE. Now, I wanted to use a build system generator CMake. It is a little difficult to getting started with this.
I am ...
0
votes
1
answer
151
views
Segfault coredump occurs when I use CPPUNIT_ASSERT
I recently updated to fedora 30. When running a test now, my code will coredump on the CPPUNIT_ASSERT in the destrctor of the Message,
gcc version:
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright ...
1
vote
1
answer
10k
views
error: use of undeclared identifier 'Solution' vector<int> ret = Solution().plusOne(param_1); return ret;
trying to add +1 to the nth term****and showing the error at the leetcode window which is mentioned above
#include<iostream>
using namespace std;
int main()
{
int n;
...
1
vote
1
answer
526
views
Does std C++17 does not support CPPUNIT?
The code is compiling fine in VS2015 but in VS2019 code is throwing errors for CPPUNIT. Is it not supported in C++17 std? if not how to resolve these error:
Code:
class CAbcTestCase : public ...
1
vote
0
answers
101
views
Cannot link against brew-installde cppunit in OSX travis image
I have a cmake-based C++ project on github that builds with Travis CI. The .travis.yml file has the following for building on OSX with clang:
language: cpp
jobs:
include:
- os: osx
...
0
votes
1
answer
43
views
Two abstract classes, deriving from the same base class. How can I access a pointer from one abstract class to the other
I'm writing a helper class for my cppUnit test harness to among other things print test descriptions with spaces. Since various elements are concatenated by the test harness to name the test class, ...
1
vote
1
answer
2k
views
Test an aborting assertion failure in CppUnit
I want to unit test a C++ function which throws aborting assertion error on invalid input.
The function is as follows:
uint64_t FooBar::ReadTimeStamp(std::string& name) {
auto iter = ...
0
votes
1
answer
234
views
CppUnit: How to print failure details immediately
I use the following code to run CppUnit tests:
CppUnit::TextTestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry....
0
votes
1
answer
136
views
Created a friend in class, gives 'no input files' error
I am an absolute beginner in C++ and trying to learn how to create a friend inside a class. I did everything exactly as the teacher did, but the compiler gives me two errors:
[Error] hj²k.cpp: No ...
2
votes
0
answers
89
views
Matching certain function declarations from existing context in clang-tidy
I would like to write a custom clang-tidy check to port code from cppunit to googletest.
class SomeTest: public CPPUNIT_NS::TestFixture {
CPPUNIT_TEST_SUITE(SomeTest);
CPPUNIT_TEST(...
0
votes
0
answers
38
views
Trouble removing tests from default registry
I have a trouble in finding a way to un-register tests that were added using the CPPUNIT_TEST_SUITE_REGISTRATION macro in CppUnit. I am attempting to optimize my main test runner by un-registering all ...
1
vote
1
answer
233
views
Inheritance with CppUnitTestFramework
I want to make global classes because I want to do the same initialize across my tests. I tried like that, I've mutiples errors like ambiguous access. Someone have an idea ?
#include <CppUnitTest....
0
votes
1
answer
824
views
Including CPPUnit test in visualcode
I'm working on this tutorial from:
http://www.evocomp.de/tutorials/tutorium_cppunit/howto_tutorial_cppunit.html
and I am not able to include headers from the CPPUnit directory in Visual Code on mac. ...
0
votes
1
answer
310
views
mechanism to take code coverage using cppunit
I need to take the code coverage of my product code.
We use cppunit for unit testing. The complete code is in cpp.
Compilation of code takes place using make files.
Is there any way to take the ...
2
votes
1
answer
4k
views
How to initialize test variables using Visual Studio CppUnitTestFramework
I'm writing a roboter controller class Controller in which I'm using a struct Axis for each of the 4 controllable motors.
For each test I want to reset everything, so I created a pointer in the ...
0
votes
1
answer
295
views
CppUnit test core dumped despite successful test. Why?
So I wanted to try TDD and set up CppUnit as test environment. I read the cookbook as I want to start small. I simply want to test a public factorial function of a class Factor. My test runs ...
0
votes
0
answers
294
views
CPPUnit ASSERT for C function which returns multiple parameters
I have to use CPPUnit in my project which includes both C++ and C codes. How do I CPPUNIT_ASSERT the following function for unit testing:
void readData(char* locationOfData,int* sizeT, int* sizeW,...
0
votes
1
answer
1k
views
How to resolve "undefined reference" error while statically linking cppunit?
I am not sure why this question is marked as a duplicate of Why does the order in which libraries are linked sometimes cause errors in GCC?. That question and this question are two totally different ...
-1
votes
2
answers
272
views
CppUnit: Why does a static local variable keep its value?
I'm trying to use CppUnit to test a method that should execute some code only the first time it is called.
class CElementParseInputTests: public CppUnit::TestFixture {
private:
CElement* element;
...
-1
votes
1
answer
60
views
cppunit export local variable
for (int i = 0; i < 50; ++i)
{
CPPUNIT_ASSERT(RtcTime_GetDayOfWeek(TimeC[i])==RtcTime_GetDayOfWeek(TimeC[i+1]));
}
This test fall down. How i can export 'i' on which this test fall ...
0
votes
1
answer
341
views
CppUnit - how use unique_ptr in setUp()
The code is taken from http://cppunit.sourceforge.net/doc/cvs/cppunit_cookbook.html
here they are creating pointers on the heap and deleted them in tearDown()
private:
Complex *m_10_1, *m_1_1, *...
0
votes
1
answer
252
views
CppUnit test hangs with Qt 5.9
While porting our source code from Qt 5.6 to Qt 5.9.1 an issue has come up when testing with CppUnit 1.13.2: DllPluginTester.exe hangs when having successfully performed all unit tests on finishing. ...
0
votes
1
answer
885
views
cppUnit: setUp function executed once for multiple testmethods
I've got an object Obj doing some (elaborate) computation and want to check weather the result (let's call it aComputed and bComputed) is correct or not. Therefore I want to split this task up into ...
3
votes
2
answers
369
views
Run a repeated test reporting as different tests
I'd like to unit test a function with a set of different inputs and expected outputs.
My function is irrelevant thus I'll instead use an example function which counts english words with the following ...
0
votes
1
answer
694
views
C++ library header not found
I am OS X user and I've recently installed "cppunit" library using brew. When I try to compile "test.cpp" file using TestCase.h header the error occurs:
> test.cpp:3:10: fatal error: 'TestCase.h' ...
0
votes
0
answers
148
views
cppUnitTests for performance testing
We are evaluating CPPUnitTest framework to do some performance evaluation of a particular production by consuming its API. The test is expected to login into the application and then perform some ...
2
votes
2
answers
815
views
CPPUNIT_ASSERT_EQUAL on std collections
I know I can specialize assertion_traits on std::vector<>:
namespace CPPUNIT_NS
{
template <class T> struct assertion_traits<std::vector<T>>
{
inline static ...
0
votes
0
answers
114
views
CPPUNIT_ASSERTs cause system to freeze or hang
Without providing too much context (as I have seen this issue in many different unit tests) can anyone explain to me why a failing CPPUNIT_ASSERT call will sometimes cause the program to freeze/hang?
...
0
votes
1
answer
2k
views
Where do I find the version of cppunit?
We use cppunit as our testing framework. How do I find its version over the command line (ubuntu)?
Is it listed somewhere or do I need to query the version via code?
4
votes
3
answers
2k
views
Parametrized Test method in Microsoft::VisualStudio::CppUnitTestFramework
I'm writing some test cases for my C++ project using Microsoft::VisualStudio::CppUnitTestFramework. Here I have a case where I have to run a same test case with different parameters.
In Nunit ...
0
votes
1
answer
2k
views
How can I do C++ Unit Tests in Netbeans?
I attempted to follow the tutorial here to get Netbeans unit testing setup for C++. It talks about a "Select Elements" portion of the test setup wizard in which one selects the parts of the actual ...
7
votes
1
answer
482
views
What are examples of test suite property uses in CPPUnit? (CPPUNIT_TEST_SUITE_PROPERTY)
I joined a project where CPPUnit is used for unit testing and will be adding some tests that probably share setup and teardown code. In researching this more I came across
...
0
votes
3
answers
270
views
Why this macro accepts a template with 1 parameter and refuses a template with 2 parameters?
I'm working with CPPUNIT 1.12.1.
It has those macro defined:
#define CPPUNIT_TEST_SUITE_ADD_TEST( test ) \
context.addTest( test )
#define CPPUNIT_TEST( testMethod ) \
...
1
vote
1
answer
2k
views
CppUnit - Registry multiple suites to be runned in a single main function
I am starting with C++ unit tests using CppUnit. The goal I am trying to achieve is to run all my test suites on a single main file (and function). Let me explain:
Let's say we have two classes with ...
0
votes
1
answer
603
views
cppunit throws std::bad_alloc after upgrading gcc to 5.4.0
I've recently updated my Gentoo Linux PC with GCC 5.4.0.
I also recompiled all packages depending on gcc (it was mentioned in gcc upgrade guide for gentoo).
Most of programs works well, however my ...
4
votes
1
answer
401
views
CPPUNIT: do we really need one function per test?
Consider this CPPUNIT test class meant to do the same test (doTest) but with different arguments:
class MyTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( MyTest );
CPPUNIT_TEST( test1 ...
1
vote
2
answers
3k
views
C++ CPPUNIT_ASSERT with two parameters
In some code i found the following line:
CPPUNIT_ASSERT(1, val.getBytefield().size());
Does this really compare the two parameters for equality? Normally, i would expect this comparison with ...
1
vote
1
answer
267
views
Netbeans Cpp compiles and runs project, but not test with cppunit
I have a C++ project using libraries such as wiringPi and MySQL Connector. My regular project compiles normally when I run it. When I try to Test one of my tests, it fails building the project.
Here'...
1
vote
1
answer
1k
views
Sonar unable to read my CPPUnit report
I try to integrate a CPPUnit Test cases in my Sonar, but when I put the report, there is a problem with the parsing.
# must be unique in a given SonarQube instance
sonar.projectKey=test
# this is ...
5
votes
1
answer
2k
views
How to make CppUnit logging more verbose?
I'm using CppUnit to write unit tests for a C++ library. By default it prints a single "." character to the console for each test. I'd like to log the name of each test on a separate line, before the ...
0
votes
1
answer
56
views
When to link and when to include?
I was writing a test case for a simple c++ program using CppUnit API.
my program is four files:
Calc.h : Defines the class with the methods to test
TestCalc.h/cpp : Defines/impelents the class which ...
0
votes
0
answers
173
views
Rotating LNK2005 / LNK2019 Errors in CPPUnitTest in C++ Visual Studio
I've been trying to set up a CPPUnitTest to test a C++ project. I've came across an error where I've got two rotating errors depending on how I try to solve my problem.
I've got two projects in a ...
3
votes
1
answer
971
views
Can't build with scons my unit tests alongside with the program
I am trying to build test suite for my code with scons. There is all my files in their current state. After trying scons test and scons I get this bunch of linker errors:
scons: Reading SConscript ...
0
votes
1
answer
282
views
'Assert Failed' message incomplete using CppUnit and TFS2015
Using: MSTest / CppUnit / TFS2015 / VS2013 / C++
I'm debugging a test that runs fine locally and fails on the build machine (which I don't have access to). This morning I sat down and was presented ...
2
votes
0
answers
493
views
Testing with CppUnit, compiled with gcc, produce stack trace
I have a lot of C++ test-cases that are all implemented using the CppUnit unit testing framework.
In our project we have tons of statements in various test-classes and various helper classes - short ...