Add tests for stdlib
This commit is contained in:
19
tests/stdlib_isalnum.c
Normal file
19
tests/stdlib_isalnum.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#define NULL 0x00
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const char *postest = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
const char *negtest = "~!@#$%^&*()_+{}|[]\\:\";'<>?,./`/*-.";
|
||||||
|
char *ptr = NULL;
|
||||||
|
|
||||||
|
for ( ptr = (char *)postest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( isalnum((int)*ptr) != 1 ) return (int)(ptr - postest);
|
||||||
|
}
|
||||||
|
for ( ptr = (char *)negtest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( islower((int)*ptr) != 0 ) return (int)(100 + (ptr - negtest));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
tests/stdlib_isalnum.deps
Normal file
1
tests/stdlib_isalnum.deps
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stdlib
|
||||||
19
tests/stdlib_isdigit.c
Normal file
19
tests/stdlib_isdigit.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#define NULL 0x00
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
if ( isdigit((int)'0') != 1 ) return 1;
|
||||||
|
if ( isdigit((int)'1') != 1 ) return 2;
|
||||||
|
if ( isdigit((int)'2') != 1 ) return 3;
|
||||||
|
if ( isdigit((int)'3') != 1 ) return 4;
|
||||||
|
if ( isdigit((int)'4') != 1 ) return 5;
|
||||||
|
if ( isdigit((int)'5') != 1 ) return 6;
|
||||||
|
if ( isdigit((int)'6') != 1 ) return 7;
|
||||||
|
if ( isdigit((int)'7') != 1 ) return 8;
|
||||||
|
if ( isdigit((int)'8') != 1 ) return 9;
|
||||||
|
if ( isdigit((int)'9') != 1 ) return 10;
|
||||||
|
if ( isdigit((int)'a') != 0 ) return 11;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
tests/stdlib_isdigit.deps
Normal file
1
tests/stdlib_isdigit.deps
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stdlib
|
||||||
1
tests/stdlib_isupper.deps
Normal file
1
tests/stdlib_isupper.deps
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stdlib
|
||||||
27
tests/stdlib_isupper_islower.c
Normal file
27
tests/stdlib_isupper_islower.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#define NULL 0x00
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const char *uptest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
const char *lowtest = "abcdefghijklmnopqrstuvwcyz";
|
||||||
|
char *ptr = NULL;
|
||||||
|
|
||||||
|
for ( ptr = (char *)uptest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( isupper((int)*ptr) != 1 ) return (int)(ptr - uptest);
|
||||||
|
}
|
||||||
|
for ( ptr = (char *)lowtest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( isupper((int)*ptr) != 0 ) return (int)(26 + (ptr - lowtest));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for ( ptr = (char *)lowtest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( islower((int)*ptr) != 1 ) return (int)(52 + (ptr - uptest));
|
||||||
|
}
|
||||||
|
for ( ptr = (char *)uptest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( islower((int)*ptr) != 0 ) return (int)(78 + (ptr - lowtest));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
tests/stdlib_isupper_islower.deps
Normal file
1
tests/stdlib_isupper_islower.deps
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stdlib
|
||||||
19
tests/stdlib_isxdigit.c
Normal file
19
tests/stdlib_isxdigit.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#define NULL 0x00
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const char *postest = "ABCDEFabcdef0123456789";
|
||||||
|
const char *negtest = "GHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz~!@#$%^&*()_+{}|[]\\:\";'<>?,./`/*-.";
|
||||||
|
char *ptr = NULL;
|
||||||
|
|
||||||
|
for ( ptr = (char *)postest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( isxdigit((int)*ptr) != 1 ) return (int)(ptr - postest);
|
||||||
|
}
|
||||||
|
for ( ptr = (char *)negtest; *ptr != '\0' ; ptr++ ) {
|
||||||
|
if ( isxdigit((int)*ptr) != 0 ) return (int)(100 + (ptr - negtest));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
tests/stdlib_isxdigit.deps
Normal file
1
tests/stdlib_isxdigit.deps
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stdlib
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
for file in *.c
|
for testfile in *.c
|
||||||
do
|
do
|
||||||
filebase=$(basename $file | sed 's/\.c$//')
|
filebase=$(basename $testfile | sed 's/\.c$//')
|
||||||
compile_def=$(cat <<EOF
|
compile_def=$(cat <<EOF
|
||||||
function shunittest_compile_${filebase} {
|
function shunittest_compile_${filebase} {
|
||||||
set -e ; make ${filebase}.elf >&2 ; test -e ${filebase}.elf ; set +e
|
set -e ; make ${filebase}.elf >&2 ; test -e ${filebase}.elf ; set +e
|
||||||
|
|||||||
Reference in New Issue
Block a user