diff --git a/tests/string_memcpy.c b/tests/string_memcpy.c new file mode 100644 index 0000000..bae1d15 --- /dev/null +++ b/tests/string_memcpy.c @@ -0,0 +1,16 @@ +#include "string.h" + +int main(void) +{ + char testblock[8] = {1, 2, 3, 4, 5, 6, 7, 8}; + char testblock2[6] = {50, 60, 70, 80, 90, 100}; + int i = 0; + + memcpy((void *)&testblock, (void *)&testblock2, (sizeof(char)*6)); + for ( i = 0; i < 6; i++) { + if ( testblock[i] != testblock2[i] ) return (i + 1); + } + if ( testblock[6] != 7 ) return 7; + if ( testblock[7] != 8 ) return 8; + return 0; +} diff --git a/tests/string_memcpy.deps b/tests/string_memcpy.deps new file mode 100644 index 0000000..ee8a39c --- /dev/null +++ b/tests/string_memcpy.deps @@ -0,0 +1 @@ +string diff --git a/tests/string_memset.c b/tests/string_memset.c new file mode 100644 index 0000000..88681a0 --- /dev/null +++ b/tests/string_memset.c @@ -0,0 +1,17 @@ +#include "string.h" + +int main(void) +{ + char testblock[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + int i = 0; + + memset((void *)&testblock, 0x00, (sizeof(char) * 8)); + for ( i = 0; i < 8; i++) { + if ( testblock[i] != 0x00 ) return (i + 1); + } + if ( testblock[8] != 9 ) return 8; + if ( testblock[9] != 10 ) return 9; + if ( testblock[10] != 11 ) return 10; + if ( testblock[11] != 12 ) return 11; + return 0; +} diff --git a/tests/string_memset.deps b/tests/string_memset.deps new file mode 100644 index 0000000..ee8a39c --- /dev/null +++ b/tests/string_memset.deps @@ -0,0 +1 @@ +string diff --git a/tests/string_strlen.c b/tests/string_strlen.c new file mode 100644 index 0000000..39aed22 --- /dev/null +++ b/tests/string_strlen.c @@ -0,0 +1,9 @@ +#include "string.h" + +int main(void) +{ + if ( strlen("Test") != 4 ) return 1; + if ( strlen("Th\0ing") != 2 ) return 2; + if ( strlen(NULL) != 0 ) return 3; + return 0; +} diff --git a/tests/string_strlen.deps b/tests/string_strlen.deps new file mode 100644 index 0000000..ee8a39c --- /dev/null +++ b/tests/string_strlen.deps @@ -0,0 +1 @@ +string diff --git a/tests/string_strncat.c b/tests/string_strncat.c new file mode 100644 index 0000000..94a4cd9 --- /dev/null +++ b/tests/string_strncat.c @@ -0,0 +1,20 @@ +#include "string.h" + +int main(void) +{ + char buffer[32]; + char *src = "Test String"; + int i = 0 ; + if ( strncat((char *)&buffer, NULL, 0) != 0 ) return 1; + if ( strncat(NULL, NULL, 0) != 0 ) return 2; + if ( strncat(NULL, src, 0) != 0 ) return 3; + + if ( strncat((char *)&buffer, src, 11) == 0 ) return 4; + + for ( i = 0; i < 11 ; i++ ) { + if ( buffer[i] != *(src + (sizeof(char) * i)) ) return i + 5; + } + if ( buffer[11] != '\0' ) return 12 + 5; + + return 0; +} diff --git a/tests/string_strncat.deps b/tests/string_strncat.deps new file mode 100644 index 0000000..ee8a39c --- /dev/null +++ b/tests/string_strncat.deps @@ -0,0 +1 @@ +string