3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
26 #include <qa_gr_circular_file.h>
27 #include <gr_circular_file.h>
28 #include <cppunit/TestAssert.h>
33 static const char *test_file = "qa_gr_circular_file.data";
34 static const int BUFFER_SIZE = 8192;
35 static const int NWRITE = 8192 * 9 / 8;
38 qa_gr_circular_file::t1 ()
41 gr_circular_file *cf_writer;
42 gr_circular_file *cf_reader;
46 cf_writer = new gr_circular_file (test_file, true, BUFFER_SIZE * sizeof (short));
49 for (int i = 0; i < NWRITE; i++){
51 cf_writer->write (&sd, sizeof (sd));
56 // now read it back...
58 cf_reader = new gr_circular_file (test_file);
59 for (int i = 0; i < BUFFER_SIZE; i++){
60 int n = cf_reader->read (&sd, sizeof (sd));
61 CPPUNIT_ASSERT_EQUAL ((int) sizeof (sd), n);
62 CPPUNIT_ASSERT_EQUAL (NWRITE - BUFFER_SIZE + i, (int) sd);
65 int n = cf_reader->read (&sd, sizeof (sd));
66 CPPUNIT_ASSERT_EQUAL (0, n);