Browse Source

Add a basic test for bcl

This test is not going to test the code that is in bc(1), just the fact
that the library glue works without asserts firing or things like that.
library
Gavin Howard 3 months ago
parent
commit
26eaa7c52d
Signed by: gavin GPG Key ID: C08038BDF280D33E
4 changed files with 67 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +10
    -1
      Makefile.in
  3. +4
    -0
      configure.sh
  4. +52
    -0
      tests/bcl.c

+ 1
- 0
.gitignore View File

@ -9,6 +9,7 @@ bin/*bc
bin/*bc.exe
bin/*dc
bin/*dc.exe
bin/bcl
bc.old
*.o
*.a


+ 10
- 1
Makefile.in View File

@ -85,6 +85,9 @@ DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
LIB = libbcl
LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME)
BCL = bcl
BCL_TEST = $(BIN)/$(BCL)
BCL_TEST_C = tests/$(BCL).c
MANUALS = manuals
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
@ -221,7 +224,7 @@ help:
check: test
test: test_bc timeconst test_dc
test: %%TESTS%%
test_bc:
%%BC_TEST%%
@ -240,6 +243,12 @@ time_test_dc:
timeconst:
%%TIMECONST%%
library_test: library
$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
test_library: library_test
$(BCL_TEST)
valgrind: valgrind_bc valgrind_dc
valgrind_bc:


+ 4
- 0
configure.sh View File

@ -578,6 +578,8 @@ link="@printf 'No link necessary\\\\n'"
main_exec="BC"
executable="BC_EXEC"
tests="test_bc timeconst test_dc"
bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 \$(BC_EXEC)"
bc_time_test="@tests/all.sh bc $extra_math 1 $generate_tests 1 \$(BC_EXEC)"
@ -667,6 +669,7 @@ else
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
fi
@ -1057,6 +1060,7 @@ contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ")
contents=$(replace "$contents" "EXECUTABLES" "$executables")
contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
contents=$(replace "$contents" "EXEC" "$executable")
contents=$(replace "$contents" "TESTS" "$tests")
contents=$(replace "$contents" "BC_TEST" "$bc_test")
contents=$(replace "$contents" "BC_TIME_TEST" "$bc_time_test")


+ 52
- 0
tests/bcl.c View File

@ -0,0 +1,52 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* Tests for bcl(3).
*
*/
#include <stdlib.h>
#include <bcl.h>
void err(BclError e) {
if (e != BCL_ERROR_SUCCESS) exit((int) e);
}
int main(void) {
BclError e;
e = bcl_init();
err(e);
return 0;
}

Loading…
Cancel
Save