Create tests/mctest.h with useful inline macros
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
bbf84a02e4
Коммит
0e3550594f
@ -1 +1,3 @@
|
||||
SUBDIRS = lib src
|
||||
|
||||
EXTRA_DIST = mctest.h
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
libmc - check if library is independ to $(topsrc)/src directory
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "lib/library_independ"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - mc_build_filename() function testing
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,13 +25,10 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
libmc - check mcconfig submodule. read and write config files
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "lib/mcconfig"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/strescape.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
libmc - check mcconfig submodule. Get full paths to user's config files.
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -24,10 +24,8 @@
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/mcconfig"
|
||||
#include <config.h>
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/strescape.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - Quote file names
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,20 +25,19 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/util"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @Before */
|
||||
static void
|
||||
setup (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* @After */
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
@ -46,8 +45,9 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @DataSource("data_source1") */
|
||||
/* *INDENT-OFF* */
|
||||
static const struct data_source1_struct
|
||||
static const struct data_source1
|
||||
{
|
||||
gboolean input_quote_percent;
|
||||
const char *input_string;
|
||||
@ -60,30 +60,31 @@ static const struct data_source1_struct
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* @Test(dataSource = "data_source1") */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (quote_percent_test)
|
||||
START_PARAMETRIZED_TEST (quote_percent_test, data_source1)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
char *actual_string;
|
||||
const struct data_source1_struct test_data = data_source1[_i];
|
||||
|
||||
/* when */
|
||||
actual_string = name_quote (test_data.input_string, test_data.input_quote_percent);
|
||||
actual_string = name_quote (data->input_string, data->input_quote_percent);
|
||||
|
||||
/* then */
|
||||
g_assert_cmpstr (actual_string, ==, test_data.expected_string);
|
||||
mctest_assert_str_eq (actual_string, data->expected_string);
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
END_PARAMETRIZED_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @DataSource("data_source2") */
|
||||
/* *INDENT-OFF* */
|
||||
static const struct data_source2_struct
|
||||
static const struct data_source2
|
||||
{
|
||||
const char *input_string;
|
||||
|
||||
@ -102,24 +103,24 @@ static const struct data_source2_struct
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* @Test(dataSource = "data_source2") */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (name_quote_test)
|
||||
START_PARAMETRIZED_TEST (name_quote_test, data_source2)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
char *actual_string;
|
||||
const struct data_source2_struct test_data = data_source2[_i];
|
||||
|
||||
/* when */
|
||||
actual_string = name_quote (test_data.input_string, FALSE);
|
||||
actual_string = name_quote (data->input_string, FALSE);
|
||||
|
||||
/* then */
|
||||
g_assert_cmpstr (actual_string, ==, test_data.expected_string);
|
||||
mctest_assert_str_eq (actual_string, data->expected_string);
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
END_PARAMETRIZED_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -136,11 +137,8 @@ main (void)
|
||||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_loop_test (tc_core, quote_percent_test, 0,
|
||||
sizeof (data_source1) / sizeof (data_source1[0]));
|
||||
|
||||
tcase_add_loop_test (tc_core, name_quote_test, 0,
|
||||
sizeof (data_source2) / sizeof (data_source2[0]));
|
||||
mctest_add_parameterized_test (tc_core, quote_percent_test, data_source1);
|
||||
mctest_add_parameterized_test (tc_core, name_quote_test, data_source2);
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
libmc - checks for processing esc sequences in replace string
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,9 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "lib/search/regex"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "regex.c" /* for testing static functions */
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
libmc - checks for processing esc sequences in replace string
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,9 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "lib/search/regex"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "regex.c" /* for testing static functions */
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - common serialize/deserialize functions
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/serialize.h"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib - canonicalize path
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - manipulate with current directory
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,9 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* lib/vfs - vfs_path_t compare functions
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -22,9 +23,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* lib/vfs - vfs_path_t compare functions
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -22,9 +23,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* lib/vfs - test vfs_path_t manipulation functions
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -22,9 +23,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - vfs_path_t charset recode functions
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - vfs_path_t serialize/deserialize functions
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* lib/vfs - test vfs_path_t manipulation functions
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -22,9 +23,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - manipulations with temp files and dirs
|
||||
|
||||
Copyright (C) 2012
|
||||
Copyright (C) 2012, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2012, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - test vfs_parse_ls_lga() functionality
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,12 +25,10 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/utilvfs.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/strutil.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - get vfs_path_t from string
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,7 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.c"
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - test vfs_prefix_to_class() functionality
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/vfs.c" /* for testing static methods */
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - test vfs_s_get_path() function
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/direntry.c" /* for testing static methods */
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - test vfs_split() functionality
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/path.c" /* for testing static methods */
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
lib/vfs - x_basename() function testing
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,57 +25,86 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @Before */
|
||||
static void
|
||||
setup (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @After */
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define check_x_basename( input, etalon ) \
|
||||
{ \
|
||||
result = x_basename ( input ); \
|
||||
fail_unless(strcmp(result, etalon) == 0, \
|
||||
"\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result, etalon); \
|
||||
}
|
||||
|
||||
/* @DataSource("test_x_basename_ds") */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_x_basename)
|
||||
static const struct test_x_basename_ds
|
||||
{
|
||||
const char *input_value;
|
||||
const char *expected_result;
|
||||
} test_x_basename_ds[] =
|
||||
{
|
||||
{
|
||||
"/test/path/test2/path2",
|
||||
"path2"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2#vfsprefix",
|
||||
"path2#vfsprefix"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2/vfsprefix://",
|
||||
"path2/vfsprefix://"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2/vfsprefix://subdir",
|
||||
"subdir"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2/vfsprefix://subdir/",
|
||||
"subdir/"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2/vfsprefix://subdir/subdir2",
|
||||
"subdir2"
|
||||
},
|
||||
{
|
||||
"/test/path/test2/path2/vfsprefix:///",
|
||||
"/"
|
||||
},
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* @Test(dataSource = "test_x_basename_ds") */
|
||||
/* *INDENT-OFF* */
|
||||
START_PARAMETRIZED_TEST (test_x_basename, test_x_basename_ds)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
const char *result;
|
||||
check_x_basename ("/test/path/test2/path2", "path2");
|
||||
/* given */
|
||||
const char *actual_result;
|
||||
|
||||
check_x_basename ("/test/path/test2/path2#vfsprefix", "path2#vfsprefix");
|
||||
/* when */
|
||||
actual_result = x_basename (data->input_value);
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix://", "path2/vfsprefix://");
|
||||
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix://subdir", "subdir");
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix://subdir/", "subdir/");
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix://subdir/subdir2", "subdir2");
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix:///", "/");
|
||||
/* then */
|
||||
mctest_assert_str_eq (actual_result, data->expected_result);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
END_PARAMETRIZED_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -92,7 +121,7 @@ main (void)
|
||||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_test (tc_core, test_x_basename);
|
||||
mctest_add_parameterized_test (tc_core, test_x_basename, test_x_basename_ds);
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
|
77
tests/mctest.h
Обычный файл
77
tests/mctest.h
Обычный файл
@ -0,0 +1,77 @@
|
||||
#ifndef MC__TEST
|
||||
#define MC__TEST
|
||||
|
||||
#include <config.h>
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
|
||||
tcase_add_loop_test (tc_core, test_func, 0, \
|
||||
sizeof (test_data_source) / sizeof (test_data_source[0])); \
|
||||
}
|
||||
|
||||
#define mctest_assert_str_eq(actual_result, etalon_result) { \
|
||||
g_assert_cmpstr (actual_result, ==, etalon_result); \
|
||||
}
|
||||
|
||||
#define mctest_assert_int_eq(actual_result, etalon_result) { \
|
||||
ck_assert_int_eq (actual_result, etalon_result); \
|
||||
}
|
||||
|
||||
#define mctest_assert_int_ne(actual_result, etalon_result) { \
|
||||
ck_assert_int_ne (actual_result, etalon_result); \
|
||||
}
|
||||
|
||||
#define mctest_assert_ptr_eq(actual_pointer, etalon_pointer) { \
|
||||
fail_unless ( actual_pointer == etalon_pointer, \
|
||||
"%s(%p) pointer should be equal to %s(%p)\n", \
|
||||
#actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
|
||||
);\
|
||||
}
|
||||
|
||||
#define mctest_assert_ptr_ne(actual_pointer, etalon_pointer) { \
|
||||
fail_unless ( actual_pointer != etalon_pointer, \
|
||||
"%s(%p) pointer should not be equal to %s(%p)\n", \
|
||||
#actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
|
||||
);\
|
||||
}
|
||||
|
||||
#define mctest_assert_null(actual_pointer) { \
|
||||
fail_unless( \
|
||||
(void *) actual_pointer == NULL, \
|
||||
"%s(%p) variable should be NULL", #actual_pointer, actual_pointer \
|
||||
); \
|
||||
}
|
||||
|
||||
#define mctest_assert_not_null(actual_pointer) { \
|
||||
fail_if( \
|
||||
(void *) actual_pointer == NULL, \
|
||||
"%s(nil) variable should not be NULL", #actual_pointer \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Define header for a parameterized test.
|
||||
* Declare 'data' variable for access to the parameters in current iteration
|
||||
*/
|
||||
#define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
|
||||
|
||||
/**
|
||||
* Define footer for a parameterized test.
|
||||
*/
|
||||
#define END_PARAMETRIZED_TEST } END_TEST
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__TEST */
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
src/filemanager - tests for do_cd_command() function
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/src/filemanager"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
#include "src/filemanager/command.c"
|
||||
@ -128,11 +125,10 @@ static const struct test_empty_mean_home_ds
|
||||
|
||||
/* @Test(dataSource = "test_empty_mean_home_ds") */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_empty_mean_home)
|
||||
START_PARAMETRIZED_TEST (test_empty_mean_home, test_empty_mean_home_ds)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
|
||||
get_current_type__return_value = view_listing;
|
||||
do_cd__return_value = TRUE;
|
||||
mc_config_get_home_dir__return_value = "/home/test";
|
||||
@ -141,7 +137,7 @@ START_TEST (test_empty_mean_home)
|
||||
{
|
||||
char *input_command;
|
||||
|
||||
input_command = g_strdup (test_empty_mean_home_ds[_i].command);
|
||||
input_command = g_strdup (data->command);
|
||||
do_cd_command (input_command);
|
||||
g_free (input_command);
|
||||
}
|
||||
@ -150,13 +146,13 @@ START_TEST (test_empty_mean_home)
|
||||
char *actual_path;
|
||||
|
||||
actual_path = vfs_path_to_str (do_cd__new_dir_vpath__captured);
|
||||
g_assert_cmpstr (mc_config_get_home_dir__return_value, ==, actual_path);
|
||||
mctest_assert_str_eq (mc_config_get_home_dir__return_value, actual_path);
|
||||
g_free (actual_path);
|
||||
}
|
||||
ck_assert_int_eq (do_cd__cd_type__captured, cd_parse_command);
|
||||
mctest_assert_int_eq (do_cd__cd_type__captured, cd_parse_command);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
END_PARAMETRIZED_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -173,8 +169,7 @@ main (void)
|
||||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_loop_test (tc_core, test_empty_mean_home, 0,
|
||||
sizeof (test_empty_mean_home_ds) / sizeof (test_empty_mean_home_ds[0]));
|
||||
mctest_add_parameterized_test (tc_core, test_empty_mean_home, test_empty_mean_home_ds);
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
src/filemanager - examine_cd() function testing
|
||||
|
||||
Copyright (C) 2012
|
||||
Copyright (C) 2012, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,13 +26,10 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/src/filemanager"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <check.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/path.h"
|
||||
#include "src/filemanager/layout.h"
|
||||
#include "src/filemanager/midnight.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
src/filemanager - filemanager functions
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -25,11 +25,8 @@
|
||||
|
||||
#define TEST_SUITE_NAME "/src/filemanager"
|
||||
|
||||
#include <config.h>
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
#include "src/filemanager/midnight.c"
|
||||
@ -102,7 +99,7 @@ export MC_EXT_SELECTED\n\
|
||||
MC_EXT_ONLYTAGGED=\"tagged\\ file1.txt tagged\\ file2.txt \"\n\
|
||||
export MC_EXT_ONLYTAGGED\n";
|
||||
|
||||
g_assert_cmpstr (actual_string, ==, expected_string);
|
||||
mctest_assert_str_eq (actual_string, expected_string);
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user