"Fossies" - the Fresh Open Source Software Archive

Member "check-0.13.0/doc/example/tests/check_money.3.c" (22 Oct 2019, 1645 Bytes) of package /linux/privat/check-0.13.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "check_money.3.c": 0.10.0_vs_0.11.0.

    1 /*
    2  * Check: a unit test framework for C
    3  * Copyright (C) 2001, 2002 Arien Malec
    4  *
    5  * This library is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Lesser General Public
    7  * License as published by the Free Software Foundation; either
    8  * version 2.1 of the License, or (at your option) any later version.
    9  *
   10  * This library is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13  * Lesser General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU Lesser General Public
   16  * License along with this library; if not, write to the
   17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
   18  * MA 02110-1301, USA.
   19  */
   20 
   21 #include <stdlib.h>
   22 #include <check.h>
   23 #include "../src/money.h"
   24 
   25 START_TEST(test_money_create)
   26 {
   27     Money *m;
   28 
   29     m = money_create(5, "USD");
   30     ck_assert_int_eq(money_amount(m), 5);
   31     ck_assert_str_eq(money_currency(m), "USD");
   32     money_free(m);
   33 }
   34 END_TEST
   35 
   36 Suite * money_suite(void)
   37 {
   38     Suite *s;
   39     TCase *tc_core;
   40 
   41     s = suite_create("Money");
   42 
   43     /* Core test case */
   44     tc_core = tcase_create("Core");
   45 
   46     tcase_add_test(tc_core, test_money_create);
   47     suite_add_tcase(s, tc_core);
   48 
   49     return s;
   50 }
   51 
   52 int main(void)
   53 {
   54     int number_failed;
   55     Suite *s;
   56     SRunner *sr;
   57 
   58     s = money_suite();
   59     sr = srunner_create(s);
   60 
   61     srunner_run_all(sr, CK_NORMAL);
   62     number_failed = srunner_ntests_failed(sr);
   63     srunner_free(sr);
   64     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
   65 }