summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mixlib/testsuite/mix_types_t.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/mixlib/testsuite/mix_types_t.c b/mixlib/testsuite/mix_types_t.c
index be9fb46..bd4a2bc 100644
--- a/mixlib/testsuite/mix_types_t.c
+++ b/mixlib/testsuite/mix_types_t.c
@@ -2,22 +2,22 @@
* Tests for mix_types.h
* ------------------------------------------------------------------
*
-** Copyright (C) 1999 Free Software Foundation, Inc.
-**
+** Copyright (C) 1999, 2004 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
+**
*/
@@ -38,17 +38,17 @@ word_compare_(mix_word_t w1, mix_word_t w2)
return ( w1 == w2 );
}
-
+
/* create a word from an array of bytes and check the result */
static void
-test_word_from_bytes_(mix_word_t *word,
- mix_byte_t *bytes,
+test_word_from_bytes_(mix_word_t *word,
+ mix_byte_t *bytes,
unsigned byteno,
const char *message)
{
mix_byte_t r;
unsigned int k;
-
+
*word = mix_bytes_to_word(bytes,byteno);
mix_word_print(*word,message);
g_print("\n");
@@ -62,12 +62,12 @@ test_word_from_bytes_(mix_word_t *word,
/* test field access */
static void
-test_field_access_(mix_fspec_t l, mix_fspec_t r,
+test_field_access_(mix_fspec_t l, mix_fspec_t r,
mix_word_t from, mix_word_t to)
{
mix_fspec_t f = mix_fspec_new(l,r);
mix_word_t result;
-
+
PRINT_BYTE(l); g_print(", ");
PRINT_BYTE(r); g_print(", ");
PRINT_BYTE(f); g_print("\n ");
@@ -86,7 +86,7 @@ static void
test_word_add_(mix_word_t w1, mix_word_t w2)
{
mix_word_t r;
-
+
r = mix_word_add(w1,w2);
mix_word_print(w1,"\n");
mix_word_print(w2,NULL);
@@ -125,18 +125,18 @@ test_word_mul_(mix_word_t w1, mix_word_t w2)
} else {
g_assert( mix_word_magnitude(l) == 0 && mix_word_magnitude(h) == 0 );
}
-
+
}
/* test word division */
static void
-test_word_div_(mix_word_t h, mix_word_t l, mix_word_t by)
+test_word_div_(mix_word_t h, mix_word_t l, mix_word_t by)
{
mix_word_t q,r;
gboolean overflow;
overflow = mix_word_div(h,l,by,&q,&r);
-
+
mix_word_print(h,"\n\n");
mix_word_print(l,NULL);
mix_word_print(by,"\n div by ");
@@ -153,7 +153,7 @@ test_word_div_(mix_word_t h, mix_word_t l, mix_word_t by)
g_assert( mix_word_magnitude(l1) == mix_word_magnitude(l) );
} else
g_print("\n\t = overflow");
-
+
}
static void
@@ -163,11 +163,11 @@ test_mix_char_(void)
guchar achar;
guint k;
g_print("\nTesting mix_char_t. Table of mix_chars:\n");
-
+
for (k = 0; k < MIX_CHAR_MAX + 1; ++k) {
mchar = k;
achar = mix_char_to_ascii(mchar);
- g_print("%02d: %c, ",k,achar);
+ g_print("%02d: %c, ", k, achar);
if ( (k+1)%5 == 0 ) g_print("\n");
g_assert( mchar == mix_ascii_to_char(achar) );
}
@@ -184,9 +184,9 @@ int main(int argc, char **argv)
mix_byte_t r;
mix_short_t ss[6];
mix_word_t words[6];
-
+
INIT_TEST;
-
+
g_print("Testing mix_byte_t arithmetics...\n");
PRINT_BYTE(bytes[0]); g_print(", ");
PRINT_BYTE(bytes[1]); g_print(", ");
@@ -212,14 +212,14 @@ int main(int argc, char **argv)
PRINT_BYTE(r = mix_byte_mul(bytes[4],bytes[1]));
g_print("\n"); g_assert(r == 56);
PRINT_BYTE(r = mix_byte_div(bytes[4],bytes[2]));
- g_print("\n"); g_assert(r == 2);
+ g_print("\n"); g_assert(r == 2);
PRINT_BYTE(r = mix_byte_div(bytes[3],bytes[2]));
g_print("\n"); g_assert(r == 1);
test_mix_char_();
g_print("\nTesting word<->short conversions...");
- words[0] = mix_bytes_to_word(bytes+1,5);
+ words[0] = mix_bytes_to_word(bytes+1,5);
words[1] = mix_word_negative(words[0]);
ss[0] = mix_word_to_short(words[0]);
ss[1] = mix_word_to_short(words[1]);
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
mix_word_reverse_sign(words[5]);
g_assert(words[4] == words[2]);
g_assert(words[5] == words[3]);
-
+
g_print("Testing mix_word_t creation and byte access...\n");
test_word_from_bytes_(words,bytes,5,"word[0] created from bytes[0-4]");
test_word_from_bytes_(words+1,bytes,4,"\nword[1] created from bytes[0-3]");
@@ -279,7 +279,7 @@ int main(int argc, char **argv)
mix_word_set_byte(words+3,k,21 + 3*k);
}
words[5] = 0;
-
+
g_print("\n***addition***");
for ( k = 0; k < 6; ++k )
for ( j = 0; j <= k; ++j ) {
@@ -302,15 +302,15 @@ int main(int argc, char **argv)
}
g_print("\nTesting shift operations...\n");
- for ( k = 0; k < 10; ++k )
+ for ( k = 0; k < 10; ++k )
mix_word_set_byte(words+(k/5),1+(k%5),k+1);
-
+
mix_word_print(words[0],"A = ");
mix_word_print(words[1],"X = ");
for ( k = 0; k < 11; ++k ) {
mix_word_t A, X;
unsigned int m;
-
+
mix_word_shift_left(words[0],words[1],k,&A,&X);
g_print("\nShift left %d:\n",k);
mix_word_print(A,"A ");
@@ -320,7 +320,7 @@ int main(int argc, char **argv)
mix_word_get_byte(words[(m+k)/5], ((m+k)%5)+1) );
for ( ; m < 10; ++m )
g_assert( mix_word_get_byte( m < 5 ? A:X, (m%5)+1 ) == 0 );
-
+
mix_word_shift_right(words[0],words[1],k,&A,&X);
g_print("\nShift right %d:\n",k);
mix_word_print(A,"A ");
@@ -330,7 +330,7 @@ int main(int argc, char **argv)
for ( ; m < 10; ++m )
g_assert( mix_word_get_byte( m < 5 ? A:X, (m%5)+1 ) ==
mix_word_get_byte(words[(m-k)/5], ((m-k)%5)+1) );
-
+
mix_word_shift_left_circular(words[0],words[1],k,&A,&X);
g_print("\nShift left circular %d:\n",k);
mix_word_print(A,"A ");
@@ -339,7 +339,7 @@ int main(int argc, char **argv)
g_assert( mix_word_get_byte( m < 5 ? A:X, (m%5)+1 ) ==
mix_word_get_byte(words[(m+k)/5], ((m+k)%5)+1) );
for ( ; m < 10; ++m )
- g_assert( mix_word_get_byte( m < 5 ? A:X, (m%5)+1 ) ==
+ g_assert( mix_word_get_byte( m < 5 ? A:X, (m%5)+1 ) ==
mix_word_get_byte(words[(m-10+k)/5], 1+((m-10+k)%5)) );
mix_word_shift_right_circular(A, X, k, &A, &X);
g_print("\nRe-shiftting right...\n");
@@ -348,13 +348,13 @@ int main(int argc, char **argv)
g_assert(A == words[0]);
g_assert(X == words[1]);
}
-
-
+
+
g_print("\n");
return EXIT_SUCCESS;
}
-
+