#define snprintf _snprintf
#endif // _WIN32
+DatabaseConnection* connect_to_customer_database(void);
+unsigned int get_customer_id_by_name(
+ DatabaseConnection * const connection,
+ const char * const customer_name);
+
// Connect to the database containing customer information.
-DatabaseConnection* connect_to_customer_database() {
+DatabaseConnection* connect_to_customer_database(void) {
return connect_to_database("customers.abcd.org", 321);
}
DatabaseConnection * const connection, const char * const customer_name);
// Mock query database function.
-unsigned int mock_query_database(
+static unsigned int mock_query_database(
DatabaseConnection* const connection, const char * const query_string,
void *** const results) {
*results = (void**)((unsigned)mock());
return (DatabaseConnection*)((unsigned)mock());
}
-void test_connect_to_customer_database(void **state) {
+static void test_connect_to_customer_database(void **state) {
will_return(connect_to_database, 0x0DA7ABA53);
assert_int_equal((int)connect_to_customer_database(), 0x0DA7ABA53);
}
/* This test fails as the mock function connect_to_database() will have no
* value to return. */
-void fail_connect_to_customer_database(void **state) {
+static void fail_connect_to_customer_database(void **state) {
assert_true(connect_to_customer_database() ==
(DatabaseConnection*)0x0DA7ABA53);
}
-void test_get_customer_id_by_name(void **state) {
+static void test_get_customer_id_by_name(void **state) {
DatabaseConnection connection = {
"somedatabase.somewhere.com", 12345678, mock_query_database
};
assert_int_equal(get_customer_id_by_name(&connection, "john doe"), 543);
}
-int main(int argc, char* argv[]) {
+int main(void) {
const UnitTest tests[] = {
unit_test(test_connect_to_customer_database),
unit_test(test_get_customer_id_by_name),