-3

I have created a project:

// func.h :
#ifndef FUNCS_H_
#define FUNCS_H_

int addInts(int i, int j);

#endif /* FUNCS_H_ */

// func.cpp
#include "func.h"

int addInts(int i, int j) {
    return i + j;
}

// main.cpp
#include "func.h"

#include <iostream>

int main() {
    std::cout << addInts(5, 7) << std::endl;
    return 0;
}

//makefile
OBJS := \
    main.o \
    func.o

CXX := g++

CXX_FLAGS := -Wall -Werror -Wextra -std=c++11

all: main_prj

main_prj: $(OBJS)
    $(CXX) $(OBJS) -lm -o main

-include $(OBJS:.o=.d)

%.o: %.cpp
    $(CXX) -c $(CXX_FLAGS) $*.cpp -o $*.o

clean:
    rm -f main $(OBJS)

And I created also a test (boost test) for that function:

// test/main_test.cpp
#define BOOST_TEST_MODULE main_test
#include <boost/test/included/unit_test.hpp>

//____________________________________________________________________________//


// FIXTURES ...

//____________________________________________________________________________//

// test/addInts/addInts_test.cpp
#include <boost/test/unit_test.hpp>

#include "../../func.h"

BOOST_AUTO_TEST_CASE(addInts_5_7) {
    int addInts_5_7 = 5 + 7;
    BOOST_CHECK_EQUAL(addInts_5_7, addInts(5, 7));
}

// test/makefile
OBJS_TEST := \
    main_test.o \
    addInts/addInts_test.o \
    ../func.o

CXX_TEST := g++

CXX_FLAGS_TEST := -Wall -Werror -Wextra -std=c++11

all_test: main_test_prj

main_test_prj: $(OBJS_TEST)
    $(CXX_TEST) $(OBJS_TEST) -lm -o main_test

-include $(OBJS_TEST:.o=.d)

%.o: %.cpp
    $(CXX_TEST) -c $(CXX_FLAGS_TEST) $*.cpp -o $*.o

clean_test:
    rm -f main_test $(OBJS_TEST)

Now, the make commands work, so they clean all the created files, or create the o files and the executables. When I run the main file, the output is correct: 12 ; but when I run the main_test file, the output is a little strange:

Running 1 test case...

*** No errors detected

I would expect the output with running tests and OK/KO, or pass/not pass... I cannot figure what am I doing wrong. Can anyone help me, please?

sop
  • 3,445
  • 8
  • 41
  • 84

1 Answers1

1

You have one test.

The output says that one test was run, and that no errors were found.

This output appears to be as documented.

There is no problem here.

Though, sadly, the documentation on how to change this output is rather lacking…

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • You are right. did not pay attention, but I added more tests and it seems to output the same thing, except the number of tests and if one fails, then the error is printed, where and what; but is there a way to see the "beautiful" output with each test name and ok/ko ? – sop Jun 28 '16 at 06:20
  • ...nevermind, it is not important to have the OKs... :) – sop Jun 28 '16 at 06:31
  • @sop If you want some specific kind of output, you're going to have to tell us what it is. Though, as pointed out at the bottom of my answer, I don't think I could help you with that anyway. :) The Boost mailing lists may be of more help. – Lightness Races in Orbit Jun 28 '16 at 09:09
  • Yes, you did :) I was thinking about something like the output of googletest (see [this](http://stackoverflow.com/questions/7923903/printing-additional-output-in-google-test) for seeing an example), but the logging to xml is ok too – sop Jun 28 '16 at 11:17