/*** * * A set of unit tests for GTE * * These tests exercise the non-graphical portions of the code */#pragma keep "../obj/unittest"#include <stdio.h>#include <string.h>#include "../include/gte.h"#define LEFT_TO_RIGHT 0#define RIGHT_TO_LEFT 1/*   if ( mask != NULL )     ReadUnaligned( maskbuff, mask, s_x, s_width, direction );   else      CreateMask( databuff, maskbuff, s_width );*/void test_mask( void ){  static char buff[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };  static char data[8];  static char mask[8];  static char ans1[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };  static char ans2[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F };  static char ans3[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF };  static char ans4[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF };  static char ans5[8] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F };  static char ans6[8] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF };                                                                    ReadUnaligned( data, buff, 0, 16, LEFT_TO_RIGHT );  CreateMask( data, mask, 16 );  printf( "Test  1: %s\n", memcmp( mask, ans1, 8 ) ? "Failed" : "Passed" );  CreateMask( data, mask, 15 );  printf( "Test  2: %s\n", memcmp( mask, ans2, 8 ) ? "Failed" : "Passed" );  CreateMask( data, mask, 14 );  printf( "Test  3: %s\n", memcmp( mask, ans3, 8 ) ? "Failed" : "Passed" );  CreateMask( data, mask, 13 );  printf( "Test  4: %s\n", memcmp( mask, ans4, 8 ) ? "Failed" : "Passed" );}void test_read( void ){  static char buff[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };  static char data[8];  static char ans1[8] = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 };  static char ans2[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xE0 };  static char ans3[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0x00 };  static char ans4[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xC0, 0x00 };  static char ans5[2] = { 0x40, 0x00 };  static char ans6[2] = { 0x50, 0x00 };  static char ans7[2] = { 0x60, 0x00 };  static char ans8[2] = { 0x70, 0x00 };  static char ans9[4] = { 0xED, 0xCB, 0xA9, 0x87 };  ReadUnaligned( data, buff, 0, 16, LEFT_TO_RIGHT );  printf( "Test  1: %s\n", memcmp( data, buff, 8 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 0, 16, RIGHT_TO_LEFT );  printf( "Test  2: %s\n", memcmp( data, ans1, 8 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 0, 15, LEFT_TO_RIGHT );  printf( "Test  3: %s\n", memcmp( data, ans2, 8 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 0, 14, LEFT_TO_RIGHT );  printf( "Test  4: %s\n", memcmp( data, ans3, 8 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 0, 13, LEFT_TO_RIGHT );  printf( "Test  5: %s\n", memcmp( data, ans4, 8 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 4, 1, LEFT_TO_RIGHT );  printf( "Test  6: %s\n", memcmp( data, ans5, 2 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 5, 1, LEFT_TO_RIGHT );  printf( "Test  7: %s\n", memcmp( data, ans6, 2 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 6, 1, LEFT_TO_RIGHT );  printf( "Test  8: %s\n", memcmp( data, ans7, 2 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 7, 1, LEFT_TO_RIGHT );  printf( "Test  9: %s\n", memcmp( data, ans8, 2 ) ? "Failed" : "Passed" );  ReadUnaligned( data, buff, 7, 8, RIGHT_TO_LEFT );  printf( "Test 10: %s\n", memcmp( data, ans9, 2 ) ? "Failed" : "Passed" );}int main( int argc, char *argv[] ){  printf( "ReadUnaligned Tests\n" );  test_read();  printf( "\nCreateMask Tests\n" );  test_mask();  return 0;}