Skip to content
Snippets Groups Projects
Commit 609d0ae9 authored by armatusmiles's avatar armatusmiles
Browse files

Add simple test dap_config

parent d2494ceb
No related branches found
No related tags found
No related merge requests found
*.user
#ifndef _DAP_CONFIG_H_
#define _DAP_CONFIG_H_
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct dap_config{
void * _internal;
} dap_config_t;
......@@ -20,5 +25,9 @@ const char * dap_config_get_item_str_default(dap_config_t * a_config, const char
bool dap_config_get_item_bool(dap_config_t * a_config, const char * a_section_path, const char * a_item_name);
double dap_config_get_item_double(dap_config_t * a_config, const char * a_section_path, const char * a_item_name);
#ifdef __cplusplus
}
#endif
#endif
cmake_minimum_required(VERSION 2.8)
project(libdap-test)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Test REQUIRED)
# dependencies for testing
set(HEADERS
../core/dap_config.h
../core/dap_common.h
)
set(SRC
../core/dap_config.c
../core/dap_common.c
)
set(TEST_FILES
main.cpp
TestHeaders.hpp
core/DapConfig_test.hpp
)
add_executable(${PROJECT_NAME} ${TEST_FILES} ${SRC} ${HEADERS}) # ${SRC} ${HEADERS}
target_include_directories(${PROJECT_NAME} PUBLIC ../core)
target_link_libraries(${PROJECT_NAME} Qt5::Test)
#pragma once
#include "core/DapConfig_test.hpp"
#pragma once
#include <QTest>
#include "dap_config.h"
class DapConfigTest : public QObject {
Q_OBJECT
private:
// helper functions
private slots:
void dapConfigOpenFail() {
QVERIFY(dap_config_open("RandomNeverExistName") == NULL);
}
};
#include <QTest>
#include <QDebug>
#define RUN_TESTS(TestObject) { \
TestObject tc; \
if(QTest::qExec(&tc)) \
exit(1); }
/* comment this and add RUN_TESTS in main function
* for run and debugging one testing class */
#define RUN_ALL_TESTS
#ifdef RUN_ALL_TESTS
#include "TestHeaders.hpp"
void run_all_tests() {
RUN_TESTS(DapConfigTest)
}
#endif
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setAttribute(Qt::AA_Use96Dpi, true);
QTEST_SET_MAIN_SOURCE_PATH
#ifdef RUN_ALL_TESTS
run_all_tests();
#endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment