forked from AllenDowney/ExercisesInC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c08a47
commit bcb2f58
Showing
5 changed files
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Example code for Software Systems at Olin College. | ||
Copyright 2017 Allen Downey | ||
License: Creative Commons Attribution-ShareAlike 3.0 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
#include "endswith.h" | ||
#include "minunit.h" | ||
|
||
int tests_run = 0; | ||
|
||
static char *test1() { | ||
int res = endswith("endswith", "swith"); | ||
char *message = "test1 failed: endswith(\"endswith\", \"swith\") should return 1"; | ||
mu_assert(message, res == 1); | ||
return NULL; | ||
} | ||
|
||
static char *test2() { | ||
int res = endswith("endswith", "ends"); | ||
char *message = "test2 failed: endswith(\"endswith\", \"ends\") should return 0"; | ||
mu_assert(message, res == 0); | ||
return NULL; | ||
} | ||
|
||
static char *test3() { | ||
int res = endswith("endswith", "offendswith"); | ||
char *message = "test3 failed: endswith(\"offendswith\", \"swith\") should return 0"; | ||
mu_assert(message, res == 0); | ||
return NULL; | ||
} | ||
|
||
static char * all_tests() { | ||
mu_run_test(test1); | ||
mu_run_test(test2); | ||
mu_run_test(test3); | ||
return NULL; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
char *result = all_tests(); | ||
if (result != NULL) { | ||
printf("%s\n", result); | ||
} else { | ||
printf("ALL TESTS PASSED\n"); | ||
} | ||
printf("Tests run: %d\n", tests_run); | ||
|
||
return result != 0; | ||
} |