/
doctest.rb
39 lines (35 loc) 路 1.05 KB
/
doctest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Doctest < Formula
desc "Feature-rich C++11/14/17/20 single-header testing framework"
homepage "https://github.com/doctest/doctest"
url "https://github.com/doctest/doctest/archive/refs/tags/v2.4.11.tar.gz"
sha256 "632ed2c05a7f53fa961381497bf8069093f0d6628c5f26286161fbd32a560186"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "b8f867ef81a9944b88b63e945435086d822964acb39dd47b8a059057b76acec3"
end
depends_on "cmake" => :build
def install
mkdir "build" do
system "cmake", "..", *std_cmake_args
system "cmake", "--build", ".", "--target", "install"
end
end
test do
(testpath/"test.cpp").write <<~EOS
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
TEST_CASE("Basic") {
int x = 1;
SUBCASE("Test section 1") {
x = x + 1;
REQUIRE(x == 2);
}
SUBCASE("Test section 2") {
REQUIRE(x == 1);
}
}
EOS
system ENV.cxx, "test.cpp", "-std=c++11", "-o", "test"
system "./test"
end
end