From 72ef7deda63ae62bccc57e4ab5ef36545adc2594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Sun, 2 May 2021 23:55:07 +0100 Subject: [PATCH 1/3] Start adding cmake code to use catch2 --- CMakeLists.txt | 6 ++++++ lib/CMakeLists.txt | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07b2968..9338989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ OPTION(BUILD_TOOLS "Build Command Line Application" ON) OPTION(BUILD_EXAMPLES "Build Examples" OFF) OPTION(BUILD_DOC "Build Documentation" OFF) OPTION(BUILD_TESTS "Build Google Tests" OFF) +OPTION(BUILD_TESTS_CATCH2 "Build Catch2 Tests" OFF) OPTION(USE_FERVOR "Add Fervor support" OFF) @@ -119,6 +120,11 @@ IF(BUILD_TESTS) ) ENDIF() +IF(BUILD_TESTS_CATCH2) + FIND_PACKAGE(Catch2 REQUIRED) + ENABLE_TESTING() +ENDIF() + OPTION(USE_OPENCV "Add OpenCV support" ON) IF(USE_OPENCV) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 9dec7f3..2853ada 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -85,3 +85,7 @@ ENDIF() IF(BUILD_TESTS) ADD_SUBDIRECTORY(tests) ENDIF() + +IF(BUILD_TESTS_CATCH2) + ADD_SUBDIRECTORY(catch2) +ENDIF() \ No newline at end of file From 63eb742f648652abe89947c7d1674443695ad342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Sun, 2 May 2021 23:59:16 +0100 Subject: [PATCH 2/3] Add src files for catch2 tests --- lib/catch2/CMakeLists.txt | 12 ++++++++++++ lib/catch2/CalypFrameTests.cpp | 0 2 files changed, 12 insertions(+) create mode 100644 lib/catch2/CMakeLists.txt create mode 100644 lib/catch2/CalypFrameTests.cpp diff --git a/lib/catch2/CMakeLists.txt b/lib/catch2/CMakeLists.txt new file mode 100644 index 0000000..8a9a98e --- /dev/null +++ b/lib/catch2/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# CMakeLists for Calyp lis tests using catch2 +# + +#ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\") + +SET(Calyp_Lib_Catch2_Tests_SRCS + CalypFrameTests.cpp +) + +ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS}) +TARGET_LINK_LIBRARIES(CalypLibCatch2Tests PRIVATE Catch2::Catch2) \ No newline at end of file diff --git a/lib/catch2/CalypFrameTests.cpp b/lib/catch2/CalypFrameTests.cpp new file mode 100644 index 0000000..e69de29 From 32f803ada98586d4347bd41a1a7ed68da4df2cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Mon, 3 May 2021 00:24:02 +0100 Subject: [PATCH 3/3] Add first tests using catch2 --- CMakeLists.txt | 6 +++++ lib/catch2/CalypFrameTests.cpp | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9338989..37faa5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,12 @@ ENDIF() IF(BUILD_TESTS_CATCH2) FIND_PACKAGE(Catch2 REQUIRED) ENABLE_TESTING() + SET_PACKAGE_PROPERTIES( + Catch2 PROPERTIES + URL "https://github.com/catchorg/Catch2" + DESCRIPTION "Catch2 unit tests" + TYPE OPTIONAL +) ENDIF() OPTION(USE_OPENCV "Add OpenCV support" ON) diff --git a/lib/catch2/CalypFrameTests.cpp b/lib/catch2/CalypFrameTests.cpp index e69de29..6abe320 100644 --- a/lib/catch2/CalypFrameTests.cpp +++ b/lib/catch2/CalypFrameTests.cpp @@ -0,0 +1,42 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + + +/** + * \file CalypFrameTests.cpp + * \brief CalypFrame general tests + */ + +#include "CalypFrame.h" + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + + +TEST_CASE( "create a 256x128 frame in YUV420 format", "CalypFrame" ) { + + // Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 ); + CalypFrame testFrame( 256, 128, CLP_YUV420P, 8); + + REQUIRE( testFrame.getWidth() == 256 ); + REQUIRE( testFrame.getHeight() == 128 ); + REQUIRE( testFrame.getPelFormat() == CLP_YUV420P ); + +}