Esempio n. 1
0
int
main (int argc, char **argv)
{
    int i;

    qof_init();
    g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING );

    xaccLogDisable ();

    /* Always start from the same random seed so we fail consistently */
    srand(0);
    if (!cashobjects_register())
    {
        failure("can't register cashbojects");
        goto cleanup;
    }

    /* Loop the test. */
    for (i = 0; i < 10; i++)
    {
        run_test ();
    }
    success("queries seem to work");

cleanup:
    qof_close();
    return get_rv();
}
Esempio n. 2
0
int
main (int argc, char ** argv)
{
    g_setenv ("GNC_UNINSTALLED", "1", TRUE);
    scm_boot_guile (argc, argv, guile_main, NULL);
    exit(get_rv());
}
Esempio n. 3
0
int
main (int argc, char **argv)
{
    g_setenv ("GNC_UNINSTALLED", "1", TRUE);
    //  scm_boot_guile (argc, argv, main_helper, NULL);
    return get_rv();
}
Esempio n. 4
0
int main (int argc, char ** argv)
{
    gchar* filename;
    QofSession* session_1;

    qof_init();
    cashobjects_register();
    qof_load_backend_library ("../.libs/", GNC_LIB_NAME);

    // Create a session with data
    session_1 = create_session();
    filename = tempnam( "/tmp", "test-sqlite3-" );
    printf( "Using filename: %s\n", filename );
    test_dbi_store_and_reload( "sqlite3", session_1, filename );
#if 0
    printf( "TEST_MYSQL_URL='%s'\n", TEST_MYSQL_URL );
    if ( strlen( TEST_MYSQL_URL ) > 0 )
    {
        session_1 = create_session();
        test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL );
    }
    printf( "TEST_PGSQL_URL='%s'\n", TEST_PGSQL_URL );
    if ( strlen( TEST_PGSQL_URL ) > 0 )
    {
        session_1 = create_session();
        test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL );
    }
#endif
    print_test_results();
    qof_close();
    exit(get_rv());
}
Esempio n. 5
0
int
main(int argc, char **argv)
{
    parse_file("test-dom-parser1-1.xml", get_parser1_1_parser1());
    parse_file("test-dom-parser1-1.xml", get_parser1_1_parser2());
    exit(get_rv());
}
int
main (int argc, char** argv)
{
    qof_init ();
    cashobjects_register ();
    xaccLogDisable ();

    gnc_transaction_xml_v2_testing = TRUE;

    book = qof_book_new ();

    if (argc > 1)
    {
        test_files_in_dir (argc, argv, test_real_transaction,
                           gnc_transaction_sixtp_parser_create (),
                           "gnc:transaction", book);
    }
    else
    {
        test_transaction ();
    }

    print_test_results ();
    qof_close ();
    exit (get_rv ());
}
Esempio n. 7
0
int
main (int argc, char **argv)
{
    gint i;

    qof_init();
    if (!cashobjects_register())
        exit(1);

    /* Any tests that cause an error or warning to be printed
     * automatically fail! */
    g_log_set_always_fatal((GLogLevelFlags)(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING));
    /* Set up a reproducible test-case */
    srand(0);
    /* Iterate the test a number of times */
    for (i = 0; i < max_iterate; i++)
    {
        fprintf(stdout, " Lots: %d of %d paired tests . . . \r",
                (i + 1) * 2, max_iterate * 2);
        fflush(stdout);
        run_test ();
    }
    /* 'erase' the recurring tag line with dummy spaces. */
    fprintf(stdout, "Lots: Test series complete.         \n");
    fflush(stdout);
    print_test_results();

    qof_close();
    return get_rv();
}
int
main (int argc, char **argv)
{
    run_tests ();
    print_test_results ();
    exit (get_rv ());
}
Esempio n. 9
0
static void
main_helper (void *closure, int argc, char **argv)
{
    gnc_module_system_init ();
    gnc_module_load("gnucash/engine", 0);
    gnc_module_load("gnucash/app-utils", 0);

    xaccLogDisable ();

    /* scm conversion doesn't handle binary atm */
    kvp_exclude_type (KVP_TYPE_BINARY);

    /* double->string->double is not idempotent */
    kvp_exclude_type (KVP_TYPE_DOUBLE);

    /* Initialize to a known RNG position */
    guid_init();
    srand(1);

    run_tests ();

    print_test_results ();

    exit (get_rv ());
}
Esempio n. 10
0
static void
main_helper (void *closure, int argc, char **argv)
{
    int count = 50;

    gnc_module_load("gnucash/engine", 0);
    gnc_module_load("gnucash/app-utils", 0);

    if (argc > 1)
        count = atoi (argv[1]);

    if (count < 0)
        count = 0;

    xaccLogDisable ();

    /* scm conversion doesn't handle binary atm */
    kvp_exclude_type (KVP_TYPE_BINARY);

    run_tests (count);

    print_test_results ();

    exit (get_rv ());
}
int
main (int argc, char** argv)
{
    QofSession* session;

    qof_init ();
    cashobjects_register ();
    session = qof_session_new ();
    sixbook = qof_session_get_book (session);
    if (argc > 1)
    {
        test_files_in_dir (argc, argv, test_real_account,
                           gnc_account_sixtp_parser_create (),
                           "gnc:account", sixbook);
    }
    else
    {
        test_generation ();
    }

    qof_session_destroy (session);
    print_test_results ();
    qof_close ();
    exit (get_rv ());
}
Esempio n. 12
0
static void
main_helper (void *closure, int argc, char **argv)
{
    gnc_module_load("gnucash/business-core", 0);
    test_business();
    print_test_results();
    exit(get_rv());
}
Esempio n. 13
0
int
main (int argc, char** argv)
{
    int i;

    for (i = 0; i < 20; i++)
    {
        Timespec* spec1;
        Timespec spec2;
        gchar* sec_str;
        gchar* nsec_str;

        spec1 = get_random_timespec ();

        sec_str = timespec_sec_to_string (spec1);
        nsec_str = timespec_nsec_to_string (spec1);

        if (!string_to_timespec_secs (sec_str, &spec2))
        {
            failure_args ("string_to_timespec_secs", __FILE__, __LINE__,
                          "string is %s", sec_str);
        }

        else if (!string_to_timespec_nsecs (nsec_str, &spec2))
        {
            failure_args ("string_to_timespec_nsecs", __FILE__, __LINE__,
                          "string is %s", nsec_str);
        }

        else if (spec1->tv_sec != spec2.tv_sec)
        {
            failure_args ("timespec_secs", __FILE__, __LINE__,
                          "not equal ints are %" G_GINT64_FORMAT
                          " and %" G_GINT64_FORMAT "\n",
                          spec1->tv_sec, spec2.tv_sec);
        }

        else if (spec1->tv_nsec != spec2.tv_nsec)
        {
            failure_args ("timespec_nsecs", __FILE__, __LINE__,
                          "not equal ints are %ld and %ld\n",
                          spec1->tv_nsec, spec2.tv_nsec);
        }

        else
        {
            success ("timespec");
        }

        g_free (spec1);
        g_free (sec_str);
        g_free (nsec_str);
    }
    print_test_results ();
    exit (get_rv ());
}
Esempio n. 14
0
int
main (int argc, char **argv)
{
    run_test ();

    success ("dates seem to work");

    print_test_results();
    exit(get_rv());
}
Esempio n. 15
0
int
main (int argc, char** argv)
{
    qof_log_init ();
    fflush (stdout);
    test_string_converters ();
    test_bad_string ();
    fflush (stdout);
    print_test_results ();
    exit (get_rv ());
}
Esempio n. 16
0
int
main (int argc, char ** argv)
{
    const char *location = g_getenv("GNC_TEST_FILES");
    int files_tested = 0;
    GDir *xml2_dir;

    qof_init();
    cashobjects_register();
    do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME),
            " loading gnc-backend-xml GModule failed");

    if (!location)
    {
        location = "test-files/xml2";
    }

    xaccLogDisable();

    if ((xml2_dir = g_dir_open(location, 0, NULL)) == NULL)
    {
        failure("unable to open xml2 directory");
    }
    else
    {
        const gchar *entry;

        while ((entry = g_dir_read_name(xml2_dir)) != NULL)
        {
            if (g_str_has_suffix(entry, ".gml2"))
            {
                gchar *to_open = g_build_filename(location, entry, (gchar*)NULL);
                if (!g_file_test(to_open, G_FILE_TEST_IS_DIR))
                {
                    test_load_file(to_open);
                    files_tested++;
                }
                g_free(to_open);
            }
        }
    }

    g_dir_close(xml2_dir);

    if (files_tested == 0)
    {
        failure("handled 0 files in test-load-xml2");
    }

    print_test_results();
    qof_close();
    exit(get_rv());
}
Esempio n. 17
0
int
main (int argc, char **argv)
{
    qof_init();
    if (cashobjects_register())
    {
        test_address();
        print_test_results();
    }
    qof_close();
    return get_rv();
}
int
main (int argc, char ** argv)
{
    const char *location = g_getenv("GNC_ACCOUNT_PATH");
    GSList *list = NULL;
    GDir *ea_dir;

    g_setenv ("GNC_UNINSTALLED", "1", TRUE);

    if (!location)
    {
        location = "../../../../accounts/C";
    }

    gnc_module_system_init();
    gnc_module_load("gnucash/engine", 0);

    if ((ea_dir = g_dir_open(location, 0, NULL)) == NULL)
    {
        failure("unable to open ea directory");
    }
    else
    {
        const gchar *entry;

        while ((entry = g_dir_read_name(ea_dir)) != NULL)
        {
            if (g_str_has_suffix(entry, da_ending))
            {
                gchar *to_open = g_build_filename(location, entry, (gchar*)NULL);
                if (!g_file_test(to_open, G_FILE_TEST_IS_DIR))
                {
                    test_load_file(to_open);
                }
                g_free(to_open);
            }
        }
    }
    g_dir_close(ea_dir);

    {
        list = gnc_load_example_account_list(location);

        do_test(list != NULL, "gnc_load_example_account_list");

        gnc_free_example_account_list(list);
    }


    print_test_results();
    exit(get_rv());
}
Esempio n. 19
0
int
main (int argc, char **argv)
{
    qof_init();
    if (cashobjects_register())
    {
        xaccLogDisable ();
        run_test ();
        print_test_results();
    }
    qof_close();
    return get_rv();
}
Esempio n. 20
0
int
main (int argc, char **argv)
{
    qof_init();
    do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
    do_test (gncJobRegister (),  "Cannot register GncJob");
    do_test (gncCustomerRegister(), "Cannot register GncCustomer");
    do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
    test_employee();
    print_test_results();
    qof_close();
    return get_rv();
}
Esempio n. 21
0
static void
main_helper (void *closure, int argc, char **argv)
{
    gnc_module_system_init ();
    gnc_module_load("gnucash/engine", 0);

    xaccLogDisable ();

    run_tests ();

    print_test_results ();

    exit (get_rv ());
}
int
main (int argc, char** argv)
{
    qof_init ();
    cashobjects_register ();
    //qof_log_init_filename("/tmp/gnctest.trace");
    //qof_log_set_default(QOF_LOG_DETAIL);
    //qof_log_set_level(GNC_MOD_PRICE, QOF_LOG_DETAIL);
    session = qof_session_new ();
    test_generation ();
    print_test_results ();
    qof_close ();
    exit (get_rv ());
}
Esempio n. 23
0
int
main (int argc, char **argv)
{
    qof_init();

    g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING );

#if 0
    set_success_print(TRUE);
#endif

    test_main();

    print_test_results();
    return get_rv();
}
Esempio n. 24
0
int
main (int argc, char **argv)
{
    qof_init();
    do_test (cashobjects_register(), "Cannot register cash objects");
    /* These three registrations are done during cashobjects_register,
       so trying to register them again naturally fails. */
#if 0
    do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
    do_test (gncJobRegister (),  "Cannot register GncJob");
    do_test (gncCustomerRegister(), "Cannot register GncCustomer");
#endif
    test_customer();
    print_test_results();
    qof_close ();
    return get_rv();
}
Esempio n. 25
0
int
main (int argc, char** argv)
{
    const char* directory = g_getenv ("GNC_TEST_FILES");

    if (!directory)
    {
        directory = "test-files/xml2";
    }

    char* filename = static_cast<decltype (filename)> (malloc (strlen (
            directory) + 1 + strlen (FILENAME) + 1));
    sprintf (filename, "%s/%s", directory, FILENAME);
    do_test (gnc_is_xml_data_file_v2 (filename, NULL), "gnc_is_xml_data_file_v2");

    print_test_results ();
    exit (get_rv ());
}
int
main(int argc, char **argv)
{
    int i;

    qof_init();

    for (i = 0; strs[i].input != NULL; i++)
    {
        char *daout;
        char *dain;
        char *wantout;

        if (strs[i].prefix_home == 1)
        {
            dain = g_build_filename(g_get_home_dir(), strs[i].input,
                                    (gchar *)NULL);
            wantout = g_build_filename(g_get_home_dir(), strs[i].output,
                                       (gchar *)NULL);
        }
        else if (strs[i].prefix_home == 2)
        {
            dain = g_strdup(strs[i].input);
            wantout = g_build_filename(g_get_home_dir(), strs[i].output,
                                       (gchar *)NULL);
        }
        else
        {
            dain = g_strdup(strs[i].input);
            wantout = g_strdup(strs[i].output);
        }

        daout = gnc_resolve_file_path(dain);
        do_test_args(g_strcmp0(daout, wantout) == 0,
                     "gnc_resolve_file_path",
                     __FILE__, __LINE__,
                     "%s (%s) vs %s", daout, dain, wantout);
        g_free(dain);
        g_free(wantout);
        g_free(daout);
    }
    print_test_results();
    return get_rv();
}
Esempio n. 27
0
int
main(int argc, char **argv)
{
    qof_init();
    cashobjects_register();
    test_dom_tree_to_guid();
    fflush(stdout);
    test_dom_tree_to_commodity_ref();
    fflush(stdout);
    test_dom_tree_to_text();
    fflush(stdout);
    test_dom_tree_to_timespec();
    fflush(stdout);
    test_dom_tree_to_gnc_numeric();
    fflush(stdout);
    print_test_results();
    qof_close();
    exit(get_rv());
}
Esempio n. 28
0
int
main (int argc, char** argv)
{
    g_setenv ("GNC_UNINSTALLED", "1", TRUE);
    gnc_engine_init (argc, argv);

    book = qof_book_new ();

    if (argc > 1)
    {
        test_files_in_dir (argc, argv, test_real_commodity,
                           gnc_commodity_sixtp_parser_create (),
                           "gnc:commodity", book);
    }
    else
    {
        test_generation ();
    }

    print_test_results ();
    exit (get_rv ());
}
Esempio n. 29
0
static void
main_helper (void *closure, int argc, char **argv)
{
    int count = 50;

    gnc_module_load("gnucash/engine", 0);
    gnc_module_load("gnucash/app-utils", 0);

    if (argc > 1)
        count = atoi (argv[1]);

    if (count < 0)
        count = 0;

    xaccLogDisable ();

    run_tests (count);

    print_test_results ();

    exit (get_rv ());
}
Esempio n. 30
0
int
main(int argc, char **argv)
{
    int i;

    qof_init();

    /* TEST: gnc_uri_get_components */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gchar *tprotocol = NULL;
        gchar *thostname = NULL;
        gchar *tusername = NULL;
        gchar *tpassword = NULL;
        gchar *tpath     = NULL;
        gint32 tport     = 0;
        gboolean testresult;

        gnc_uri_get_components( strs[i].uri, &tprotocol, &thostname,
                                &tport, &tusername, &tpassword, &tpath );
        testresult = ( safe_strcmp ( tprotocol, strs[i].protocol ) == 0 ) &
                     ( safe_strcmp ( thostname, strs[i].hostname ) == 0 ) &
                     ( safe_strcmp ( tusername, strs[i].username ) == 0 ) &
                     ( safe_strcmp ( tpassword, strs[i].password ) == 0 ) &
                     ( safe_strcmp ( tpath, strs[i].path ) == 0 ) &
                     ( tport == strs[i].port );
        do_test_args(testresult,
                     "gnc_uri_get_components",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s, %s, %s, %s, %s, %d\n"
                     "    Got     : %s, %s, %s, %s, %s, %d\n",
                     strs[i].uri, strs[i].protocol, strs[i].hostname,
                     strs[i].username, strs[i].password, strs[i].path, strs[i].port,
                     tprotocol, thostname, tusername, tpassword, tpath, tport);
        g_free(tprotocol);
        g_free(thostname);
        g_free(tusername);
        g_free(tpassword);
        g_free(tpath);
    }

    /* TEST: gnc_uri_get_protocol */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gchar *tprotocol = NULL;
        gboolean testresult;

        tprotocol = gnc_uri_get_protocol( strs[i].uri );
        testresult = ( safe_strcmp ( tprotocol, strs[i].protocol ) == 0 );
        do_test_args(testresult,
                     "gnc_uri_get_protocol",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].uri, strs[i].protocol, tprotocol );
        g_free(tprotocol);
    }

    /* TEST: gnc_uri_get_path */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gchar *tpath = NULL;
        gboolean testresult;

        tpath = gnc_uri_get_path( strs[i].uri );
        testresult = ( safe_strcmp ( tpath, strs[i].path ) == 0 );
        do_test_args(testresult,
                     "gnc_uri_get_path",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].uri, strs[i].path, tpath );
        g_free(tpath);
    }

    /* TEST: gnc_uri_create_uri */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gchar *turi = NULL;
        gboolean testresult;

        turi = gnc_uri_create_uri( strs[i].protocol, strs[i].hostname, strs[i].port,
                                   strs[i].username, strs[i].password, strs[i].path );
        testresult = ( safe_strcmp ( turi, strs[i].created_uri ) == 0 );
        do_test_args(testresult,
                     "gnc_uri_create_uri",
                     __FILE__, __LINE__,
                     "\n  %s, %s, %s, %s, %s, %d:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].protocol, strs[i].hostname,
                     strs[i].username, strs[i].password, strs[i].path, strs[i].port,
                     strs[i].created_uri, turi);
        g_free(turi);
    }

    /* TEST: gnc_uri_normalize_uri */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gchar *turi = NULL;
        gboolean testresult;

        turi = gnc_uri_normalize_uri( strs[i].uri, strs[i].want_password );
        testresult = ( safe_strcmp ( turi, strs[i].normalized_uri ) == 0 );
        do_test_args(testresult,
                     "gnc_uri_normalize_uri",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].uri, strs[i].normalized_uri, turi );
        g_free(turi);
    }

    /* TEST: gnc_uri_is_file_protocol */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gboolean tis_file_protocol;
        gboolean testresult;

        tis_file_protocol = gnc_uri_is_file_protocol( strs[i].protocol );
        testresult = ( tis_file_protocol == strs[i].is_file_protocol );
        do_test_args(testresult,
                     "gnc_uri_is_file_protocol",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].uri, strs[i].is_file_protocol, tis_file_protocol );
    }

    /* TEST: gnc_uri_is_file_uri */
    for (i = 0; strs[i].uri != NULL; i++)
    {
        gboolean tis_file_uri;
        gboolean testresult;

        tis_file_uri = gnc_uri_is_file_uri( strs[i].uri );
        testresult = ( tis_file_uri == strs[i].is_file_protocol );
        do_test_args(testresult,
                     "gnc_uri_is_file_uri",
                     __FILE__, __LINE__,
                     "\n  %s:\n"
                     "    Expected: %s\n"
                     "    Got     : %s\n",
                     strs[i].uri, strs[i].is_file_protocol, tis_file_uri );
    }

    print_test_results();
    return get_rv();
}