Add Catch2 testing into the Calyp library
This commit is contained in:
1 parent
33bf02ba0f
commit
70db70a7cf
4 files changed
+98
-1
No files matched your search
+20
-1
@@ -2,7 +2,7 @@
|
||||
# CMakeLists for calyp
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Project Definition
|
||||
@@ -48,6 +48,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)
|
||||
|
||||
@@ -124,6 +125,24 @@ IF(BUILD_TESTS)
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
INCLUDE(FetchContent)
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.1
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(Catch2)
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
Catch2 PROPERTIES
|
||||
URL "https://github.com/catchorg/Catch2"
|
||||
DESCRIPTION "Catch2 unit tests"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake)
|
||||
ENABLE_TESTING()
|
||||
ENDIF()
|
||||
|
||||
OPTION(USE_OPENCV "Add OpenCV support" ON)
|
||||
IF(USE_OPENCV)
|
||||
|
||||
|
||||
@@ -85,3 +85,7 @@ ENDIF()
|
||||
IF(BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
ADD_SUBDIRECTORY(catch2)
|
||||
ENDIF()
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# 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 ${PROJECT_LIBRARY} Catch2::Catch2)
|
||||
|
||||
INCLUDE(CTest)
|
||||
CATCH_DISCOVER_TESTS(CalypLibCatch2Tests)
|
||||
@@ -0,0 +1,61 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 8 bits 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 );
|
||||
REQUIRE( testFrame.getBitsPel() == 8 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 10 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 10 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 10 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 16 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 16 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 16 );
|
||||
}
|
||||
Reference in new issue
Block a user