X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fdata%2Fdecoder.cpp;fp=test%2Fdata%2Fdecoder.cpp;h=8ea5d181b73eb4f3d97ff3eab5f10500136db68e;hb=3b3a445c072df27ae4e1831f6078467d84baa425;hp=0000000000000000000000000000000000000000;hpb=e92cd4e4cddac2639c1a5e278124b5bb22ace10f;p=pulseview.git diff --git a/test/data/decoder.cpp b/test/data/decoder.cpp new file mode 100644 index 00000000..8ea5d181 --- /dev/null +++ b/test/data/decoder.cpp @@ -0,0 +1,71 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include /* First, so we avoid a _POSIX_C_SOURCE warning. */ + +#include + +#include "../../pv/devicemanager.h" +#include "../../pv/sigsession.h" +#include "../../pv/view/signal.h" + +using namespace boost; +using namespace std; + +BOOST_AUTO_TEST_SUITE(DecoderTest) + +BOOST_AUTO_TEST_CASE(TwoDecoder) +{ + sr_context *ctx = NULL; + + BOOST_REQUIRE(sr_init(&ctx) == SR_OK); + BOOST_REQUIRE(ctx); + + BOOST_REQUIRE(srd_init(NULL) == SRD_OK); + + srd_decoder_load_all(); + + { + pv::DeviceManager dm(ctx); + pv::SigSession ss(dm); + + const GSList *l = srd_decoder_list(); + BOOST_REQUIRE(l); + srd_decoder *const dec = (struct srd_decoder*)l->data; + BOOST_REQUIRE(dec); + + map > probes; + BOOST_CHECK (ss.add_decoder(dec, probes, + g_hash_table_new_full(g_str_hash, g_str_equal, g_free, + (GDestroyNotify)g_variant_unref))); + + BOOST_CHECK (ss.add_decoder(dec, probes, + g_hash_table_new_full(g_str_hash, g_str_equal, g_free, + (GDestroyNotify)g_variant_unref))); + } + + + srd_exit(); + sr_exit(ctx); +} + +BOOST_AUTO_TEST_SUITE_END()