pull/32/head
Geoffrey Merck 4 years ago
parent 249af92976
commit cf6116fd7a

2
.gitignore vendored

@ -44,4 +44,4 @@ Sandbox/*
*.out
*.app
dstargateway
Tests/dstargateway_tests

@ -27,6 +27,30 @@
"ignoreFailures": true
}
]
},
{
"name": "Tests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Tests/dstargateway_tests",
"args": [ ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Activer l'impression en mode Pretty pour gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Définir la version désassemblage sur Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

@ -30,5 +30,9 @@
}
}
]
}
},
"gtest-adapter.debugConfig": [
"Tests"
],
"gtest-adapter.supportLocation": true
}

10
.vscode/tasks.json vendored

@ -10,10 +10,7 @@
"args": [
"-j3"
],
"group": {
"kind": "build",
"isDefault": true
},
"group": "build",
"problemMatcher": []
},
{
@ -24,7 +21,10 @@
"-j3",
"tests"
],
"group": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]

@ -22,15 +22,15 @@ export DATA_DIR=/usr/local/share/dstargateway.d/
export LOG_DIR=/var/log/dstargateway/
# choose this if you want debugging help
CPPFLAGS=-g -ggdb -W -Wall -Werror -std=c++17
export CPPFLAGS=-g -ggdb -W -Wall -Werror -std=c++17
# or, you can choose this for a much smaller executable without debugging help
#CPPFLAGS=-W -Wall -Werror -std=c++17
LDFLAGS:=-lcurl -pthread
export CC=g++
export LDFLAGS:=-lcurl -pthread
ifeq ($(USE_GPSD), 1)
CPPFLAGS+= -DUSE_GPSD
LDFLAGS+= -lgps
export CPPFLAGS+= -DUSE_GPSD
export LDFLAGS+= -lgps
endif
SRCS = $(wildcard *.cpp)
@ -38,13 +38,13 @@ OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
.PHONY: all
all: dstargateway
all: dstargateway tests
dstargateway : GitVersion.h $(OBJS)
g++ $(CPPFLAGS) -o dstargateway $(OBJS) $(LDFLAGS)
$(CC) $(CPPFLAGS) -o dstargateway $(OBJS) $(LDFLAGS)
%.o : %.cpp
g++ $(CPPFLAGS) -MMD -MD -c $< -o $@
$(CC) $(CPPFLAGS) -MMD -MD -c $< -o $@
GitVersion.h : FORCE
ifneq ("$(wildcard .git/index)","")
@ -66,7 +66,8 @@ endif
.PHONY: clean
clean:
$(RM) GitVersion.h $(OBJS) $(DEPS) dstargateway
@$(RM) GitVersion.h $(OBJS) $(DEPS) dstargateway
@$(MAKE) -C Tests clean
-include $(DEPS)
@ -129,6 +130,8 @@ removehostfiles :
@rm -f $(DATA_DIR)/DCS_Hosts.txt
@rm -f $(DATA_DIR)/DPlus_Hosts.txt
.PHONY tests:
tests : GitVersion.h $(OBJS)
$(MAKE) -C Tests tests
FORCE:

@ -0,0 +1,25 @@
SRCS = $(wildcard *.cpp) $(wildcard ../*.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
.PHONY tests:
tests: rmdstargatewayapp $(OBJS)
$(CC) $(CPPFLAGS) -o dstargateway_tests $(OBJS) $(LDFLAGS) -lgtest -lgtest_main
%.o : %.cpp
$(CC) $(CPPFLAGS) -DUNIT_TESTS -I../ -MMD -MD -c $< -o $@
-include $(DEPS)
.PHONY clean :
clean :
@$(RM) $(OBJS) $(DEPS) dstargateway_tests
.PHONY rmdstargatewayapp :
rmdstargatewayapp: FORCE
@$(RM) ../DStarGatewayApp.o
@$(RM) ../DStarGatewayApp.d
FORCE:

@ -0,0 +1,54 @@
#include <gtest/gtest.h>
#include <APRSParser.h>
// The fixture for testing class Foo.
class FooTest : public ::testing::Test {
protected:
// You can remove any or all of the following functions if their bodies would
// be empty.
FooTest() {
// You can do set-up work for each test here.
}
~FooTest() override {
// You can do clean-up work that doesn't throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
void SetUp() override {
// Code here will be called immediately after the constructor (right
// before each test).
}
void TearDown() override {
// Code here will be called immediately after each test (right
// before the destructor).
}
// Class members declared here can be used by all tests in the test suite
// for Foo.
};
// Tests that the Foo::Bar() method does Abc.
TEST_F(FooTest, MethodBarDoesAbc) {
const std::string input_filepath = "this/package/testdata/myinputfile.dat";
const std::string output_filepath = "this/package/testdata/myoutputfile.dat";
TAPRSFrame frame;
CAPRSParser::parseFrame("bla", frame);
EXPECT_EQ(frame.m_type, APFT_MESSAGE);
}
// Tests that Foo does Xyz.
TEST_F(FooTest, DoesXyz) {
// Exercises the Xyz feature of Foo.
}
Loading…
Cancel
Save

Powered by TurnKey Linux.