]> sigrok.org Git - libsigrokflow.git/blob - tests/init.cpp
Add tests/legacy_decoder.cpp and a simple unit test.
[libsigrokflow.git] / tests / init.cpp
1 /*
2  * This file is part of the libsigrokflow project.
3  *
4  * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <catch2/catch.hpp>
21 #include <libsigrokflow/libsigrokflow.hpp>
22
23 TEST_CASE("init/deinit", "[init]")
24 {
25         SECTION("Srf::init() before successful Gst::init() should throw") {
26                 CHECK_THROWS(Srf::init());
27         }
28
29         REQUIRE_NOTHROW(Gst::init());
30
31         SECTION("Srf::init() after successful Gst::init() should not throw") {
32                 CHECK_NOTHROW(Srf::init());
33                 SECTION("Multiple Srf::init() calls should throw") {
34                         for (int i = 0; i < 10; ++i)
35                                 CHECK_THROWS(Srf::init());
36                         CHECK_NOTHROW(Srf::deinit());
37                 }
38                 SECTION("Srf::deinit() should not throw") {
39                         CHECK_NOTHROW(Srf::deinit());
40                 }
41                 SECTION("Multiple Srf::deinit() calls should throw") {
42                         CHECK_NOTHROW(Srf::deinit());
43                         for (int i = 0; i < 10; ++i)
44                                 CHECK_THROWS(Srf::deinit());
45                 }
46         }
47
48         REQUIRE_NOTHROW(Gst::deinit());
49 }