SmartSpectra C++ SDK
Measure human vitals from video with SmartSpectra C++ SDK.
Loading...
Searching...
No Matches
test_main.hpp
1
2// Created by greg on 9/3/24.
3// Based on https://github.com/Algomorph/NeuralTracking/blob/main/cpp/tests/test_main.hpp,
4// which was created by Gregory Kramida, under Apache 2 License, (c) 2021 Gregory Kramida
5//
6// Copyright (C) 2024 Presage Security, Inc.
7//
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 3 of the License, or (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public License
19// along with this program; if not, write to the Free Software Foundation,
20// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23#pragma once
24
25#define CATCH_CONFIG_RUNNER
26
27#include <catch2/catch_session.hpp>
28#include <catch2/catch_test_macros.hpp>
29#include <catch2/benchmark/catch_benchmark.hpp>
30
31
32// Necessary to start running the test(s) as a python program
33int main(int argc, char* argv[]) {
34#ifdef SMARTSPECTRA_TEST_USE_PYTHON
35 wchar_t* program = Py_DecodeLocale(argv[0], nullptr);
36 if (program == nullptr) {
37 fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
38 exit(1);
39 }
40 Py_SetProgramName(program); /* optional but recommended */
41 Py_Initialize();
42#endif
43 int result = Catch::Session().run(argc, argv);
44#ifdef SMARTSPECTRA_TEST_USE_PYTHON
45 if (Py_FinalizeEx() < 0) {
46 exit(120);
47 }
48 PyMem_RawFree(program);
49#endif
50 return (result < 0xff ? result : 0xff);
51}