Aktywne Wpisy

JakDorobic_com +142
Jesteśmy w niezłym konkursowym gazie, więc organizujemy jeszcze jedno weekendowe #rozdajo! ( ͡° ͜ʖ ͡° )つ──☆*:・゚
Do zdobycia jest karta podarunkowa Allegro o wartości
Do zdobycia jest karta podarunkowa Allegro o wartości
źródło: rozdajo wykop jakdorobic
Pobierz
Mufasaaa +108
źródło: Zdjęcie z biblioteki
Pobierz




Chce sprawdzić jak działa Catch2 dla C++ w Debian
przykład:
#include <catch2/catch_test_macros.hpp>
static int Factorial( int number ) {
return number <= 1 ? number : Factorial( number - 1 ) * number; // fail
// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass
}
TEST_CASE( "Factorial of 0 is 1 (fail)", "[single-file]" ) {
REQUIRE( Factorial(0) == 1 );
}
TEST_CASE( "Factorials of 1 and higher are computed (pass)", "[single-file]" ) {
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}
catch2 jest w /usr/include zainstalowane z pakietu deb
Kompiluje:
g++ -std=c++14 -Wall -I /usr/include/catch2 -o 010-TestCase 010-TestCase.cpp && 010-TestCase --successi poszło...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in functionstart':(.text+0x20): undefined reference to
main'CATCH2INTERNALTEST0()':/usr/bin/ld: /tmp/ccFU1LF2.o: in function
010-TestCase.cpp:(.text+0x9a): undefined reference to
Catch::AssertionHandler::AssertionHandler(Catch::StringRef, Catch::SourceLineInfo const&, Catch::StringRef, Catch::ResultDisposition::Flags)'itd.
Co ja źle robię? Co źle rozumiem?
-I /usr/include/catch2tym zakomunikowałeś gdzie są same headery, ale nigdzie nie dałeś informacji skąd ma sobie dolinkować "mięso" do finalnej binarki. takie coś by wystarczyło jakbyś miał bibliotekę header-only. imo ten-I /usr/include/catch2/jest niepotrzebny w ogóle, powinien tam z automatu zerkaćv2pozwalała na taki kod,v3już nie jest header only i musisz zalinkować libkę https://github.com/catchorg/Catch2/blob/devel/docs/migrate-v2-to-v3.md#top .@horus666: przykład z repozytorium ¯\(ツ)/¯
Komentarz usunięty przez autora