-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from antoniovazquezblanco/dev/tests
Add a sample testing structure
- Loading branch information
Showing
8 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test | ||
description: 'Test a CMake project with CTest support' | ||
|
||
inputs: | ||
shell: | ||
required: false | ||
default: bash | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Test | ||
shell: ${{inputs.shell}} | ||
run: ctest --test-dir build -VV --rerun-failed --output-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ sigutils: | |
|
||
documentation: | ||
- doc/**/* | ||
|
||
tests: | ||
- tests/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
find_package(Catch2) | ||
|
||
if(Catch2_FOUND) | ||
# General options | ||
file(GLOB_RECURSE TEST_SRCS LIST_DIRECTORIES false *.cpp) | ||
add_executable(sigutils_test ${TEST_SRCS}) | ||
target_include_directories(sigutils_test PUBLIC $<TARGET_PROPERTY:sigutils,INCLUDE_DIRECTORIES>) | ||
target_compile_definitions(sigutils_test PUBLIC $<TARGET_PROPERTY:sigutils,COMPILE_DEFINITIONS>) | ||
target_link_libraries(sigutils_test $<TARGET_LINKER_FILE:sigutils>) | ||
include(Catch) | ||
catch_discover_tests(sigutils_test) | ||
|
||
if(Catch2_VERSION_MAJOR EQUAL 2) | ||
target_compile_definitions(sigutils_test PUBLIC CATCH2_V2) | ||
target_link_libraries(sigutils_test Catch2::Catch2) | ||
elseif(Catch2_VERSION_MAJOR EQUAL 3) | ||
target_compile_definitions(sigutils_test PUBLIC CATCH2_V3) | ||
target_link_libraries(sigutils_test Catch2::Catch2WithMain) | ||
else() | ||
message("Unsuported Catch2 version") | ||
endif() | ||
else() | ||
message("Catch2 needs to be installed to perform unit testing") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* Copyright (C) 2023 Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com> | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
#ifndef _CATCH_TEST_H | ||
#define _CATCH_TEST_H | ||
|
||
#ifdef CATCH2_V2 | ||
#define CATCH_CONFIG_MAIN | ||
#include <catch2/catch.hpp> | ||
#endif | ||
|
||
#ifdef CATCH2_V3 | ||
#include <catch2/catch_all.hpp> | ||
#endif | ||
|
||
#if !defined(CATCH2_V2) && !defined(CATCH2_V3) | ||
#error "No Catch2 version specified!" | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Copyright (C) 2023 Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com> | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
#include "catch.hpp" | ||
|
||
#include <sigutils/ncqo.h> | ||
|
||
TEST_CASE("Test normalized frecuency scale", "[NCQO]") | ||
{ | ||
su_ncqo_t ncqo; | ||
su_ncqo_init(&ncqo, 1.0); | ||
REQUIRE(SUFLOAT_EQUAL(su_ncqo_read_i(&ncqo), 1.0)); | ||
REQUIRE(SUFLOAT_EQUAL(su_ncqo_read_i(&ncqo), -1.0)); | ||
REQUIRE(SUFLOAT_EQUAL(su_ncqo_read_i(&ncqo), 1.0)); | ||
REQUIRE(SUFLOAT_EQUAL(su_ncqo_read_i(&ncqo), -1.0)); | ||
} |