-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add catch2 version 2.9.2 #51
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
2.9.2: | ||
url: https://github.com/catchorg/Catch2/archive/v2.9.2.tar.gz | ||
sha256: 54BEA6D80A388A80F895CD0E2343FCA72B0D9093A776AF40904AEFCE49C13BDA |
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,55 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class ConanRecipe(ConanFile): | ||
name = "catch2" | ||
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD" | ||
topics = ("conan", "catch2", "header-only", "unit-test", "tdd", "bdd") | ||
homepage = "https://github.com/catchorg/Catch2" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
license = "BSL-1.0" | ||
|
||
settings = "os", "compiler", "build_type", "arch" | ||
|
||
generators = "cmake" | ||
|
||
_source_subfolder = "source_subfolder" | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = "Catch2-" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
|
||
_build_subfolder = "build_subfolder" | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.definitions["BUILD_TESTING"] = "OFF" | ||
cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" | ||
cmake.definitions["CATCH_INSTALL_HELPERS"] = "ON" | ||
cmake.configure( | ||
source_folder=self._source_subfolder, | ||
build_folder=self._build_subfolder | ||
) | ||
return cmake | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
Minimonium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def package(self): | ||
self.copy(pattern="LICENSE.txt", dst="licenses", | ||
src=self._source_subfolder) | ||
|
||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
Minimonium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def package_id(self): | ||
self.info.header_only() |
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,15 @@ | ||
// 000-CatchMain.cpp | ||
|
||
// In a Catch project with multiple files, dedicate one file to compile the | ||
// source code of Catch itself and reuse the resulting object file for linking. | ||
|
||
// Let Catch provide main(): | ||
#define CATCH_CONFIG_MAIN | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
// That's it | ||
|
||
// Compile implementation of Catch for use with files that do contain tests: | ||
// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 000-CatchMain.cpp | ||
// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 000-CatchMain.cpp |
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,69 @@ | ||
// 100-Fix-Section.cpp | ||
|
||
// Catch has two ways to express fixtures: | ||
// - Sections (this file) | ||
// - Traditional class-based fixtures | ||
|
||
// main() provided in 000-CatchMain.cpp | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
TEST_CASE( "vectors can be sized and resized", "[vector]" ) { | ||
|
||
// For each section, vector v is anew: | ||
|
||
std::vector<int> v( 5 ); | ||
|
||
REQUIRE( v.size() == 5 ); | ||
REQUIRE( v.capacity() >= 5 ); | ||
|
||
SECTION( "resizing bigger changes size and capacity" ) { | ||
v.resize( 10 ); | ||
|
||
REQUIRE( v.size() == 10 ); | ||
REQUIRE( v.capacity() >= 10 ); | ||
} | ||
SECTION( "resizing smaller changes size but not capacity" ) { | ||
v.resize( 0 ); | ||
|
||
REQUIRE( v.size() == 0 ); | ||
REQUIRE( v.capacity() >= 5 ); | ||
} | ||
SECTION( "reserving bigger changes capacity but not size" ) { | ||
v.reserve( 10 ); | ||
|
||
REQUIRE( v.size() == 5 ); | ||
REQUIRE( v.capacity() >= 10 ); | ||
} | ||
SECTION( "reserving smaller does not change size or capacity" ) { | ||
v.reserve( 0 ); | ||
|
||
REQUIRE( v.size() == 5 ); | ||
REQUIRE( v.capacity() >= 5 ); | ||
} | ||
} | ||
|
||
// Compile & run: | ||
// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 100-Fix-Section 100-Fix-Section.cpp 000-CatchMain.o && 100-Fix-Section --success | ||
// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 100-Fix-Section.cpp 000-CatchMain.obj && 100-Fix-Section --success | ||
|
||
// Expected compact output (all assertions): | ||
// | ||
// prompt> 100-Fix-Section.exe --reporter compact --success | ||
// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// 100-Fix-Section.cpp:23: passed: v.size() == 10 for: 10 == 10 | ||
// 100-Fix-Section.cpp:24: passed: v.capacity() >= 10 for: 10 >= 10 | ||
// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// 100-Fix-Section.cpp:29: passed: v.size() == 0 for: 0 == 0 | ||
// 100-Fix-Section.cpp:30: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// 100-Fix-Section.cpp:35: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:36: passed: v.capacity() >= 10 for: 10 >= 10 | ||
// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// 100-Fix-Section.cpp:41: passed: v.size() == 5 for: 5 == 5 | ||
// 100-Fix-Section.cpp:42: passed: v.capacity() >= 5 for: 5 >= 5 | ||
// Passed 1 test case with 16 assertions. |
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,13 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(test_package) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
set(CMAKE_VERBOSE_MAKEFILE TRUE) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} 000-CatchMain.cpp 100-Fix-Section.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
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 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
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,3 @@ | ||
versions: | ||
2.9.2: | ||
folder: 2.x.x |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add your name as author 😺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After Cppcon, Martin, the Catch2's maintainer, could be willing to pick up the authorship.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you there at cppcon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly no. 🙂