int test_addchar( newstr *s ) { int failed = 0; int numshort = 5, numchars = 1000, i; /* ...appending '\0' characters won't increase length */ newstr_empty( s ); for ( i=0; i<numshort; ++i ) newstr_addchar( s, '\0' ); if ( test_consistency( s, 0, __FUNCTION__ ) || test_identity( s, "" ) ) failed++; /* ...build "11111" with newstr_addchar */ newstr_empty( s ); for ( i=0; i<numshort; ++i ) newstr_addchar( s, '1' ); if ( test_consistency( s, 5, __FUNCTION__ ) || test_identity( s, "11111" ) ) failed++; newstr_empty( s ); for ( i=0; i<numchars; ++i ) { newstr_addchar( s, ( i % 64 ) + 64); } if ( test_consistency( s, numchars, __FUNCTION__ ) ) failed++; return failed; }
int test_strcpy( newstr *s ) { int failed = 0; int numstrings = 1000, i; /* Copying null string should reset string */ newstr_empty( s ); for ( i=0; i<numstrings; ++i ) { newstr_strcpy( s, "1" ); newstr_strcpy( s, "" ); if ( test_consistency( s, 0, __FUNCTION__ ) || test_identity( s, "" ) ) failed++; } newstr_empty( s ); for ( i=0; i<numstrings; ++i ) { newstr_strcpy( s, "1" ); if ( test_consistency( s, 1, __FUNCTION__ ) || test_identity( s, "1" ) ) failed++; } newstr_empty( s ); for ( i=0; i<numstrings; ++i ) { newstr_strcpy( s, "XXOO" ); if ( test_consistency( s, 4, __FUNCTION__ ) || test_identity( s, "XXOO" ) ) failed++; } return failed; }
int main(int argc, char *argv[]) { if (argc != 2) printf("usage: testelf file.elf"); FILE *input; input = fopen(argv[1], "rb"); fseek(input, 0, SEEK_END); int elf_length = ftell(input); fseek(input, 0, SEEK_SET); elf = (u_int8_t*)malloc(elf_length); fread(elf, 1, elf_length, input); fclose(input); test_identity(); if(arch == 32) { test_header32(); if(Elf_Header32.e_phoff != 0) test_program_headers(); if(Elf_Header32.e_shoff != 0) test_section_headers(); } else { test_header64(); if(Elf_Header64.e_phoff != 0) test_program_headers(); if(Elf_Header64.e_shoff != 0) test_section_headers(); } }
int main (int argc, char **argv) { MPI_Comm mpicomm; int mpiret; int N; mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = MPI_COMM_WORLD; sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); N = 43; test_identity (N); test_shell (N); test_sphere (N); /* clean up and exit */ sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int test_strcat( newstr *s ) { int failed = 0; int numshort = 5, numstrings = 1000, i; /* ...adding empty strings to an empty string shouldn't change length */ newstr_empty( s ); for ( i=0; i<numstrings; ++i ) newstr_strcat( s, "" ); if ( test_consistency( s, 0, __FUNCTION__ ) || test_identity( s, "" ) ) failed++; /* ...adding empty strings to a defined string shouldn't change string */ newstr_strcpy( s, "1" ); for ( i=0; i<numstrings; ++i ) newstr_strcat( s, "" ); if ( test_consistency( s, 1, __FUNCTION__ ) || test_identity( s, "1" ) ) failed++; /* ...build "1111" with newstr_strcat */ newstr_empty( s ); for ( i=0; i<numshort; ++i ) newstr_strcat( s, "1" ); if ( test_consistency( s, numshort, __FUNCTION__ ) || test_identity( s, "11111" ) ) failed++; /* ...build "xoxoxoxoxo" with newstr_strcat */ newstr_empty( s ); for ( i=0; i<numshort; ++i ) newstr_strcat( s, "xo" ); if ( test_consistency( s, numshort*2, __FUNCTION__ ) || test_identity( s, "xoxoxoxoxo" ) ) failed++; newstr_empty( s ); for ( i=0; i<numstrings; ++i ) newstr_strcat( s, "1" ); if ( test_consistency( s, numstrings, __FUNCTION__ ) ) failed++; newstr_empty( s ); for ( i=0; i<numstrings; ++i ) { newstr_strcat( s, "XXOO" ); } failed += test_consistency( s, numstrings*4, __FUNCTION__ ); return failed; }
int main() { if(test_unary() && test_131() && test_313() && test_identity()) { printf("All tests pass.\n"); } else { printf("At least one test didn't pass.\n"); } }
main() { int matrix[SIZE][SIZE]; set_identity(matrix); print_identity(matrix); if(test_identity(matrix)) { printf("is identity matrix\n"); } else { printf("is NOT identity matrix\n"); } matrix[0][3] = 1; print_identity(matrix); if(test_identity(matrix)) { printf("is identity matrix\n"); } else { printf("is NOT identity matrix\n"); } }
int main (void) { setup_test_environment(); test_bind_before_connect (); test_connect_before_bind (); test_connect_before_bind_pub_sub (); test_multiple_connects (); test_multiple_threads (); test_identity (); test_connect_only (); return 0; }
int test_empty( newstr *s ) { int failed = 0; int numchars = 1000, i, j; newstr_empty( s ); for ( i=0; i<numchars; ++i ) { for ( j=0; j<i; ++j ) newstr_addchar( s, 'x' ); newstr_empty( s ); if ( test_consistency( s, 0, __FUNCTION__ ) || test_identity( s, "" ) ) failed++; } return failed; }
int test_segcpy( newstr *s ) { int failed = 0; int numstrings = 1000, i; char segment[]="0123456789"; char *start=&(segment[2]), *end=&(segment[5]); newstr_empty( s ); for ( i=0; i<numstrings; ++i ) { newstr_segcpy( s, start, end ); if ( test_consistency( s, 3, __FUNCTION__ ) || test_identity( s, "234" ) ) failed++; } return failed; }
int main (void) { setup_test_environment (); test_bind_before_connect (); test_connect_before_bind (); test_connect_before_bind_pub_sub (); test_multiple_connects (); test_multiple_threads (); test_simultaneous_connect_bind_threads (); test_identity (); test_connect_only (); test_unbind (); test_shutdown_during_pend (); return 0; }
static int run_test (int /*unused*/, char* /*unused*/ []) { test_identity (); #if !defined _RWSTD_NO_RVALUE_REFERENCES test_forward (); test_move (); #else // no rvalue references rw_warn (0, 0, __LINE__, "No compiler support for rvalue references; tests disabled."); #endif // !defined _RWSTD_NO_RVALUE_REFERENCES return 0; }