mirror of
https://github.com/ivabus/pantry
synced 2024-11-10 10:35:17 +03:00
55 lines
1.2 KiB
YAML
55 lines
1.2 KiB
YAML
distributable:
|
|
url: https://github.com/TartanLlama/expected/archive/refs/tags/v{{version}}.tar.gz
|
|
strip-components: 1
|
|
|
|
versions:
|
|
github: TartanLlama/expected
|
|
|
|
aka: tl-expected
|
|
|
|
build:
|
|
dependencies:
|
|
cmake.org: ^3
|
|
working-directory: build
|
|
script:
|
|
- cmake ..
|
|
-DCMAKE_INSTALL_PREFIX={{prefix}}
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
- make --jobs {{ hw.concurrency }} install
|
|
|
|
test:
|
|
fixture: |
|
|
#include <iostream>
|
|
#include <tl/expected.hpp>
|
|
|
|
tl::expected<int, std::string> divide(int a, int b) {
|
|
if (b == 0) {
|
|
return tl::make_unexpected("Division by zero");
|
|
}
|
|
return a / b;
|
|
}
|
|
|
|
int main() {
|
|
auto result = divide(10, 5);
|
|
if (result) {
|
|
std::cout << "Result: " << *result << std::endl;
|
|
} else {
|
|
std::cout << "Error: " << result.error() << std::endl;
|
|
}
|
|
|
|
result = divide(2, 0);
|
|
if (result) {
|
|
std::cout << "Result: " << *result << std::endl;
|
|
} else {
|
|
std::cout << "Error: " << result.error() << std::endl;
|
|
}
|
|
return 0;
|
|
}
|
|
script: |
|
|
mv $FIXTURE b.cpp
|
|
c++ b.cpp -std=c++17
|
|
out="$(./a.out)"
|
|
test "$out" = "Result: 2
|
|
Error: Division by zero"
|