]> sigrok.org Git - pulseview.git/blame - test/data/decoder.cpp
tests: Fix #include order.
[pulseview.git] / test / data / decoder.cpp
CommitLineData
3b3a445c
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
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 2 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
3b3a445c 21#include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
6ab78775 22#include <boost/test/unit_test.hpp>
3b3a445c
JH
23
24#include <libsigrok/libsigrok.h>
25
26#include "../../pv/devicemanager.h"
27#include "../../pv/sigsession.h"
28#include "../../pv/view/signal.h"
29
30using namespace boost;
31using namespace std;
32
33BOOST_AUTO_TEST_SUITE(DecoderTest)
34
35BOOST_AUTO_TEST_CASE(TwoDecoder)
36{
37 sr_context *ctx = NULL;
38
39 BOOST_REQUIRE(sr_init(&ctx) == SR_OK);
40 BOOST_REQUIRE(ctx);
41
42 BOOST_REQUIRE(srd_init(NULL) == SRD_OK);
43
44 srd_decoder_load_all();
45
46 {
47 pv::DeviceManager dm(ctx);
48 pv::SigSession ss(dm);
49
50 const GSList *l = srd_decoder_list();
51 BOOST_REQUIRE(l);
52 srd_decoder *const dec = (struct srd_decoder*)l->data;
53 BOOST_REQUIRE(dec);
54
55 map<const srd_probe*, shared_ptr<pv::view::Signal> > probes;
56 BOOST_CHECK (ss.add_decoder(dec, probes,
57 g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
58 (GDestroyNotify)g_variant_unref)));
59
60 BOOST_CHECK (ss.add_decoder(dec, probes,
61 g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
62 (GDestroyNotify)g_variant_unref)));
63 }
64
65
66 srd_exit();
67 sr_exit(ctx);
68}
69
70BOOST_AUTO_TEST_SUITE_END()