Add tests

Related: rhbz#1980993
This commit is contained in:
Zoltan Fridrich 2021-07-16 10:46:24 +02:00
parent 2841154465
commit 5264cf0066
6 changed files with 57 additions and 2 deletions

View File

@ -2,7 +2,7 @@
Name: catch1
Version: 1.12.2
Release: 9%{?dist}
Release: 10%{?dist}
Summary: A modern, C++-native, header-only, framework for unit-tests, TDD and BDD
License: Boost
@ -57,7 +57,8 @@ cp -pr include %{buildroot}%{_includedir}/catch
%changelog
* Thu Jul 15 2021 Zoltan Fridrich <zfridric@redhat.com> - 1.12.2-9
* Thu Jul 15 2021 Zoltan Fridrich <zfridric@redhat.com> - 1.12.2-10
- Add tests
- Fix compilation error due to dynamic stack sizes
Resolves: rhbz#1980993

1
tests/.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,14 @@
#define CATCH_CONFIG_MAIN
#include <catch/catch.hpp>
unsigned int Factorial(unsigned int number) {
return number <= 1 ? number : Factorial(number - 1) * number;
}
TEST_CASE("Factorials are computed", "[factorial]") {
REQUIRE(Factorial(1) == 1);
REQUIRE(Factorial(2) == 2);
REQUIRE(Factorial(3) == 6);
REQUIRE(Factorial(10) == 3628800);
}

View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
set -x
TEST_SOURCE=factorial.cpp
TEST_TARGET="${TEST_SOURCE/\.cpp/}"
CXXFLAGS="$(rpm --eval '%{build_cxxflags}')"
LDFLAGS="$(rpm --eval '%{build_ldflags}')"
LIBFLAGS=""
# build target using distribution-specific flags
g++ -std=c++11 $CXXFLAGS $LDFLAGS $LIBFLAGS -o $TEST_TARGET $TEST_SOURCE
# test that target exists
test -f ./$TEST_TARGET
# test that target is executable
test -x ./$TEST_TARGET
# test that target runs successfully
./$TEST_TARGET

4
tests/provision.fmf Normal file
View File

@ -0,0 +1,4 @@
---
standard-inventory-qcow2:
qemu:
m: 4G

13
tests/tests.yml Normal file
View File

@ -0,0 +1,13 @@
---
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-basic
tests:
- devel-usability
required_packages:
- gcc-c++
- rpm
- redhat-rpm-config
- catch1-devel