summaryrefslogtreecommitdiffhomepage
path: root/mixlib/testsuite/mix_device_t.c
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2006-03-20 22:46:46 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2006-03-20 22:46:46 +0000
commit300160e73da486946ae513f1d039dcd7b85ff17c (patch)
treef26691ff724b57dac450ab47e4eea91e63cdadc1 /mixlib/testsuite/mix_device_t.c
parent50375f34b611281a3b05a37221e2baa143f5f5ca (diff)
downloadmdk-300160e73da486946ae513f1d039dcd7b85ff17c.tar.gz
mdk-300160e73da486946ae513f1d039dcd7b85ff17c.tar.bz2
Version 1.2.1 imported1.2.1
git-archimport-id: mdk@sv.gnu.org/mdk--devel--1--patch-1
Diffstat (limited to 'mixlib/testsuite/mix_device_t.c')
-rw-r--r--mixlib/testsuite/mix_device_t.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/mixlib/testsuite/mix_device_t.c b/mixlib/testsuite/mix_device_t.c
new file mode 100644
index 0000000..8638d2f
--- /dev/null
+++ b/mixlib/testsuite/mix_device_t.c
@@ -0,0 +1,76 @@
+/* -*-c-*- -------------- mix_device_t.c :
+ * Implementation of the functions declared in mix_device_t.h
+ * ------------------------------------------------------------------
+ * Copyright (C) 2000 Free Software Foundation, Inc.
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <mix_device.h>
+
+/* Define VERBOSE_TEST if you want to get prints of the test */
+/* #define VERBOSE_TEST */
+#include "test.h"
+
+static int S_ = MIX_CHAR_MAX +1;
+
+int
+main (int argc, char **argv)
+{
+ mix_device_t *console;
+ size_t s;
+ mix_word_t **block;
+ mix_char_t mchars[S_];
+ gchar chars[S_];
+ int i, j;
+ int bno;
+
+
+ INIT_TEST;
+
+ console = mix_device_new (mix_dev_CONSOLE);
+ s = mix_device_block_size (console);
+ bno = S_/(s*5);
+ if (bno == 0) bno = 1;
+
+ block = g_new (mix_word_t *, bno);
+ for (i = 0; i < bno; ++i)
+ block[i] = g_new (mix_word_t, s);
+
+ for (i = 0; i < S_; ++i) {
+ chars[i] = mix_char_to_ascii (i);
+ mchars[i] = mix_ascii_to_char (chars[i]);
+ g_assert (mchars[i] == i);
+ }
+
+ for (i = 0; i < bno; ++i) {
+ for (j = 0; j < s; ++j) {
+ int n = i*s + 5*j;
+ if (n < S_)
+ block[i][j] = mix_bytes_to_word (mchars + n, 5);
+ else
+ block[i][j] = 0;
+ }
+ }
+
+ for (i = 0; i < bno; ++i) {
+ mix_device_write (console, block[i]);
+ }
+
+
+ return EXIT_SUCCESS;
+}