mirror of
https://github.com/dvorka/hstr.git
synced 2024-09-20 06:46:13 +08:00
Fixing tests and adding GitHub Actions build which resolves #472
This commit is contained in:
parent
f945c7f209
commit
9913d7a0d6
31
.gitattributes
vendored
Normal file
31
.gitattributes
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
* text=auto
|
||||
|
||||
# These files are text and should be normalized (convert crlf to lf)
|
||||
*.rb text
|
||||
*.test text
|
||||
*.c text
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.txt text
|
||||
*.yml text
|
||||
*.s79 text
|
||||
*.bat text
|
||||
*.xcl text
|
||||
*.inc text
|
||||
*.info text
|
||||
*.md text
|
||||
makefile text
|
||||
rakefile text
|
||||
meson.build text
|
||||
|
||||
|
||||
#These files are binary and should not be normalized
|
||||
*.doc binary
|
||||
*.odt binary
|
||||
*.pdf binary
|
||||
*.ewd binary
|
||||
*.eww binary
|
||||
*.dni binary
|
||||
*.wsdt binary
|
||||
*.dbgdt binary
|
||||
*.mac binary
|
17
.github/workflows/build_ubuntu.yml
vendored
Normal file
17
.github/workflows/build_ubuntu.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: Ubuntu unit tests
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install packages
|
||||
run: sudo apt-get update && sudo apt install -y build-essential qttools5-dev-tools ccache libncursesw5-dev libreadline-dev
|
||||
|
||||
- name: Build lib and run unit tests using Unity test framework
|
||||
run: cd test && qmake hstr-unit-tests.pro && make clean all && ./hstr-unit-tests
|
|
@ -137,9 +137,11 @@ char* parse_history_line(char *l)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef HSTR_TESTS_UNIT
|
||||
if (isZsh) {
|
||||
l = zsh_unmetafy(l, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -35,19 +35,23 @@
|
|||
|
||||
/*
|
||||
* IMPORTANT: make sure to run TEST RUNNER GENERATOR script after any change to this file!
|
||||
*
|
||||
*/
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
// code to be run before this test suite
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
// code to be after this test suite
|
||||
}
|
||||
|
||||
void test_args(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
// GIVEN
|
||||
const unsigned LINELNG = 500;
|
||||
int argc = 3;
|
||||
char* argv[argc];
|
||||
|
@ -55,6 +59,7 @@ void test_args(void)
|
|||
argv[1] = "-o";
|
||||
argv[2] = "_args";
|
||||
|
||||
// WHEN
|
||||
if(argc>0) {
|
||||
int i;
|
||||
char line[LINELNG];
|
||||
|
@ -72,6 +77,7 @@ void test_args(void)
|
|||
strcat(line, " ");
|
||||
}
|
||||
|
||||
// THEN
|
||||
printf("#%s#\n", line);
|
||||
TEST_ASSERT_EQUAL_STRING("hstr -o _args ", line);
|
||||
} else {
|
||||
|
@ -81,6 +87,9 @@ void test_args(void)
|
|||
|
||||
void test_getopt(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
// GIVEN
|
||||
int argc = 3;
|
||||
char* argv[argc];
|
||||
argv[0] = "hstr";
|
||||
|
@ -164,6 +173,8 @@ void test_getopt(void)
|
|||
|
||||
void test_locate_char_in_string_overflow(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(0, strchr("a\nb",1));
|
||||
|
||||
printf("%s\n",strchr("a\nb",98));
|
||||
|
@ -175,6 +186,8 @@ void test_locate_char_in_string_overflow(void)
|
|||
|
||||
void test_favorites(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
FavoriteItems favoriteItems;
|
||||
|
||||
favorites_init(&favoriteItems);
|
||||
|
@ -199,6 +212,8 @@ void test_favorites(void)
|
|||
|
||||
void test_hashset_blacklist()
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
const char* commandBlacklist[] = { "a","b","c","d","e" };
|
||||
HashSet blacklist;
|
||||
int i;
|
||||
|
@ -214,6 +229,8 @@ void test_hashset_blacklist()
|
|||
|
||||
void test_hashset_get_keys()
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
const char* commandBlacklist[] = { "a","b","c","d","e" };
|
||||
HashSet blacklist;
|
||||
int i;
|
||||
|
@ -235,6 +252,8 @@ void test_hashset_get_keys()
|
|||
|
||||
void test_regexp(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
unsigned REGEXP_MATCH_BUFFER_SIZE = 10;
|
||||
|
||||
bool caseSensitive=false;
|
||||
|
@ -275,6 +294,8 @@ void test_regexp(void)
|
|||
|
||||
void test_help_long(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
TEST_IGNORE_MESSAGE("Tests exits the program");
|
||||
|
||||
char* ARG_HSTR = "hstr";
|
||||
|
@ -291,6 +312,8 @@ void test_help_long(void)
|
|||
|
||||
void test_help_short(void)
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
TEST_IGNORE_MESSAGE("Tests exits the program");
|
||||
|
||||
char* ARG_HSTR = "hstr";
|
||||
|
@ -307,6 +330,8 @@ void test_help_short(void)
|
|||
|
||||
void test_string_elide()
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
char buffer[1000];
|
||||
|
||||
// do nothing - string fits to screen
|
||||
|
@ -339,6 +364,8 @@ void test_string_elide()
|
|||
|
||||
void test_parse_history_line()
|
||||
{
|
||||
printf("\n= %s ========================================\n", __FUNCTION__);
|
||||
|
||||
TEST_ASSERT_EQUAL(NULL, parse_history_line(NULL));
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("ls", parse_history_line("ls"));
|
||||
|
|
Loading…
Reference in a new issue