]> granicus.if.org Git - check/commitdiff
* Added revision 3 of money example.
authorcpickett <cpickett@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Fri, 13 Oct 2006 03:52:28 +0000 (03:52 +0000)
committercpickett <cpickett@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Fri, 13 Oct 2006 03:52:28 +0000 (03:52 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@317 64e312b2-a51f-0410-8e61-82d0ca0eb02a

doc/example/src/money.3.c [new file with mode: 0644]
doc/example/tests/check_money.3.c [new file with mode: 0644]

diff --git a/doc/example/src/money.3.c b/doc/example/src/money.3.c
new file mode 100644 (file)
index 0000000..52ac9ea
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include "money.h"
+
+Money *
+money_create (int amount, char *currency)
+{
+  return NULL;
+}
+
+int
+money_amount (Money * m)
+{
+  return 0;
+}
+
+char *
+money_currency (Money * m)
+{
+  return NULL;
+}
+
+void
+money_free (Money * m)
+{
+  return;
+}
diff --git a/doc/example/tests/check_money.3.c b/doc/example/tests/check_money.3.c
new file mode 100644 (file)
index 0000000..52e448d
--- /dev/null
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <check.h>
+#include "../src/money.h"
+
+START_TEST (test_money_create)
+{
+  Money *m;
+  m = money_create (5, "USD");
+  fail_unless (money_amount (m) == 5,
+               "Amount not set correctly on creation");
+  fail_unless (strcmp (money_currency (m), "USD") == 0,
+               "Currency not set correctly on creation");
+  money_free(m);
+}
+END_TEST
+
+Suite * money_suite (void)
+{
+  Suite *s = suite_create ("Money");
+
+  /* Core test case */
+  TCase *tc_core = tcase_create ("Core");
+  tcase_add_test (tc_core, test_money_create);
+  suite_add_tcase (s, tc_core);
+
+  return s;
+}
+
+int
+main (void)
+{
+  int number_failed;
+  Suite *s = money_suite ();
+  SRunner *sr = srunner_create (s);
+  srunner_run_all (sr, CK_NORMAL);
+  number_failed = srunner_ntests_failed (sr);
+  srunner_free (sr);
+  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}