mirror of
https://github.com/dvorka/hstr.git
synced 2024-09-20 06:46:13 +08:00
Introducing new main() to enable creation of UNIT tests.
This commit is contained in:
parent
05b667e0e3
commit
742c51c756
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,6 +15,7 @@ Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
*.o
|
*.o
|
||||||
*.snap
|
*.snap
|
||||||
hstr.pro.user
|
|
||||||
*.*~
|
*.*~
|
||||||
hstr
|
hstr
|
||||||
|
*.pro.user
|
||||||
|
test/hstr-unit-tests
|
||||||
|
|
2
PKGBUILD
2
PKGBUILD
|
@ -1,4 +1,4 @@
|
||||||
# Maintainer: Christian Wieden <wiedenchr at gmail dot com
|
# Maintainer: Christian Wieden <wiedenchr at gmail dot com>
|
||||||
# Contributor: Ricardo Band <me at xengi dot de>
|
# Contributor: Ricardo Band <me at xengi dot de>
|
||||||
# Contributor: Filip Szymański <fszymanski at, fedoraproject.org>
|
# Contributor: Filip Szymański <fszymanski at, fedoraproject.org>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# configure.ac Autoconf configuration file
|
# configure.ac Autoconf configuration file
|
||||||
# process this file with autoconf to produce a configure script
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
# Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
#
|
#
|
||||||
|
@ -15,12 +14,16 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
#
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
|
|
||||||
AC_INIT(hh, 1.27.0, martin.dvorak@mindforger.com)
|
AC_INIT(hh, 1.27.0, martin.dvorak@mindforger.com)
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
|
||||||
|
|
||||||
# Checks for src dir existence.
|
# Check src dir existence.
|
||||||
AC_CONFIG_SRCDIR([src/hstr.c])
|
AC_CONFIG_SRCDIR([src/hstr.c])
|
||||||
|
|
||||||
# Init (no longer takes parameters).
|
# Init (no longer takes parameters).
|
||||||
|
|
8
hstr.pro
8
hstr.pro
|
@ -1,4 +1,4 @@
|
||||||
# hstr.pro Qt project file for HSTR
|
# hstr.pro Qt project file for HSTR shell history compleation utility
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
# Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
#
|
#
|
||||||
|
@ -31,7 +31,8 @@ SOURCES += \
|
||||||
src/hstr_regexp.c \
|
src/hstr_regexp.c \
|
||||||
src/hstr_utils.c \
|
src/hstr_utils.c \
|
||||||
src/hstr.c \
|
src/hstr.c \
|
||||||
src/radixsort.c
|
src/radixsort.c \
|
||||||
|
src/main.c
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/include/hashset.h \
|
src/include/hashset.h \
|
||||||
|
@ -41,7 +42,8 @@ HEADERS += \
|
||||||
src/include/hstr_history.h \
|
src/include/hstr_history.h \
|
||||||
src/include/hstr_regexp.h \
|
src/include/hstr_regexp.h \
|
||||||
src/include/hstr_utils.h \
|
src/include/hstr_utils.h \
|
||||||
src/include/radixsort.h
|
src/include/radixsort.h \
|
||||||
|
src/include/hstr.h
|
||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
QMAKE_CC = ccache gcc
|
QMAKE_CC = ccache gcc
|
||||||
|
|
|
@ -30,7 +30,8 @@ hh_SOURCES = \
|
||||||
hstr_blacklist.c include/hstr_blacklist.h \
|
hstr_blacklist.c include/hstr_blacklist.h \
|
||||||
hstr_regexp.c include/hstr_regexp.h \
|
hstr_regexp.c include/hstr_regexp.h \
|
||||||
radixsort.c include/radixsort.h \
|
radixsort.c include/radixsort.h \
|
||||||
hstr.c
|
hstr.c include/hstr.h \
|
||||||
|
main.c
|
||||||
|
|
||||||
# create hh > hstr hard link on installation
|
# create hh > hstr hard link on installation
|
||||||
install-exec-hook:
|
install-exec-hook:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
hstr.c BASH history completion utility
|
hstr.c HSTR shell history completion utility
|
||||||
|
|
||||||
Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@
|
||||||
#include "include/hstr_regexp.h"
|
#include "include/hstr_regexp.h"
|
||||||
#include "include/hstr_utils.h"
|
#include "include/hstr_utils.h"
|
||||||
|
|
||||||
|
#include "include/hstr.h"
|
||||||
|
|
||||||
#define SELECTION_CURSOR_IN_PROMPT -1
|
#define SELECTION_CURSOR_IN_PROMPT -1
|
||||||
#define SELECTION_PREFIX_MAX_LNG 512
|
#define SELECTION_PREFIX_MAX_LNG 512
|
||||||
#define CMDLINE_LNG 2048
|
#define CMDLINE_LNG 2048
|
||||||
|
@ -1490,7 +1492,7 @@ void hstr_getopt(int argc, char **argv, Hstr *hstr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int hstrMain(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
|
|
24
src/include/hstr.h
Normal file
24
src/include/hstr.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
hstr.h header file for HSTR shell history completion utility
|
||||||
|
|
||||||
|
Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HSTR_H_
|
||||||
|
#define HSTR_H_
|
||||||
|
|
||||||
|
int hstrMain(int argc, char *argv[]);
|
||||||
|
|
||||||
|
#endif
|
24
src/main.c
Normal file
24
src/main.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
main.c HSTR shell history completion utility main
|
||||||
|
|
||||||
|
Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "include/hstr.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return hstrMain(argc, argv);
|
||||||
|
}
|
50
test/hstr-unit-tests.pro
Normal file
50
test/hstr-unit-tests.pro
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# hstr-unit-tests.pro Qt project file of UNIT tests for HSTR
|
||||||
|
#
|
||||||
|
# Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG -= qt
|
||||||
|
|
||||||
|
# -L for where to look for library, -l for linking the library
|
||||||
|
LIBS += -lm -lreadline -lncursesw
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../src/hashset.c \
|
||||||
|
../src/hstr_blacklist.c \
|
||||||
|
../src/hstr_curses.c \
|
||||||
|
../src/hstr_favorites.c \
|
||||||
|
../src/hstr_history.c \
|
||||||
|
../src/hstr_regexp.c \
|
||||||
|
../src/hstr_utils.c \
|
||||||
|
../src/hstr.c \
|
||||||
|
../src/radixsort.c \
|
||||||
|
../test/src/test.c
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../src/include/hashset.h \
|
||||||
|
../src/include/hstr_blacklist.h \
|
||||||
|
../src/include/hstr_curses.h \
|
||||||
|
../src/include/hstr_favorites.h \
|
||||||
|
../src/include/hstr_history.h \
|
||||||
|
../src/include/hstr_regexp.h \
|
||||||
|
../src/include/hstr_utils.h \
|
||||||
|
../src/include/radixsort.h \
|
||||||
|
../src/include/hstr.h
|
||||||
|
|
||||||
|
# compiler and linker
|
||||||
|
QMAKE_CC = ccache gcc
|
||||||
|
QMAKE_LINK = gcc
|
24
test/src/test.c
Normal file
24
test/src/test.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
main.c UNIT tests main for HSTR shell history completion utility
|
||||||
|
|
||||||
|
Copyright (C) 2014-2018 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../src/include/hstr.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return hstrMain(argc, argv);
|
||||||
|
}
|
Loading…
Reference in a new issue