diff options
Diffstat (limited to 'basics/main.c')
| -rw-r--r-- | basics/main.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/basics/main.c b/basics/main.c index 89d4401..4b5f289 100644 --- a/basics/main.c +++ b/basics/main.c @@ -11,7 +11,7 @@ */ int factorial(uint64_t n); -void test_factorial() +void test_factorial(void) { assert(factorial(0) == 0); assert(factorial(1) == 1); @@ -19,7 +19,7 @@ void test_factorial() assert(factorial(3) == 6); assert(factorial(4) == 24); - printf("factorial:\tOK\n"); + printf("factorial:\t\tOK\n"); } /* @@ -30,7 +30,7 @@ void test_factorial() */ char * reverse_string(char *str); -void test_reverse_string() +void test_reverse_string(void) { assert(reverse_string(NULL) == NULL); assert(reverse_string("") == ""); @@ -41,7 +41,7 @@ void test_reverse_string() char s2[] = "."; assert(strcmp(reverse_string(s2), ".") == 0); - printf("reverse_string:\tOK\n"); + printf("reverse_string:\t\tOK\n"); } /* @@ -51,7 +51,7 @@ void test_reverse_string() */ bool is_palindrome(char *str); -void test_is_palindrome() +void test_is_palindrome(void) { assert(is_palindrome(NULL) == 0); assert(is_palindrome("") == 0); @@ -59,7 +59,25 @@ void test_is_palindrome() assert(is_palindrome("aaa") == 1); assert(is_palindrome("This is a a si sihT") == 1); - printf("is_palindrome:\tOK\n"); + printf("is_palindrome:\t\tOK\n"); +} + +/* + * This function computes the following: ((a + b) * b) + b. Don't try to make + * sense of it, that's the computation I ended up while messing with RISC-V + * floating point instructions. Anyways, with this in mind, it will return if + * the computed value is greater than 10. + * + * Implemented in float.S + */ +bool greater_than_ten(double a, uint64_t b); + +void test_greater_than_ten(void) +{ + assert(!greater_than_ten(2.3, 1)); // 4.3 + assert(greater_than_ten(2.3, 2)); // 10.6 + + printf("greater_than_ten:\tOK\n"); } int main() @@ -67,4 +85,5 @@ int main() test_factorial(); test_reverse_string(); test_is_palindrome(); + test_greater_than_ten(); } |
