Skip to content

Commit

Permalink
Merge pull request #30 from lxylxy123456/fib
Browse files Browse the repository at this point in the history
Add Fib to valgrind
  • Loading branch information
lxylxy123456 committed Dec 18, 2020
2 parents dd03f04 + d440bef commit 0ace10e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ VALGRIND := $(filter-out valgrind/RaceExampleTest,$(VALGRIND))

# VALGRIND_ALL has currently unavailable tests filtered out
VALGRIND_ALL := $(VALGRIND)
VALGRIND_ALL := $(filter-out valgrind/FibTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/IntervalTreeTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/MatVecTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/PSquareMatrixMultiplyTest,$(VALGRIND_ALL))
Expand All @@ -57,7 +56,7 @@ $(TESTS): test/%: bin/%

$(VALGRIND): valgrind/%: bin/%
# https://stackoverflow.com/a/55130152
valgrind $(VALGRINDFLAGS) ./$^ > /dev/null
valgrind $(VALGRINDFLAGS) ./$^ valgrind > /dev/null
echo valgrind ./$^ Completed

clean:
Expand Down
6 changes: 5 additions & 1 deletion src/FibTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ int test(size_t n, size_t expected) {
}

int main(int argc, char *argv[]) {
int N = 21;
if (argc >= 2)
// Valgrind: reduce test size
N = 13;
size_t prev = 0, cur = 1;
for (int n = 0; n < 21; n++) {
for (int n = 0; n < N; n++) {
test(n, prev);
prev += cur;
cur ^= prev ^= cur ^= prev;
Expand Down
4 changes: 2 additions & 2 deletions src/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void graph_weighted_test(const size_t v, const size_t e) {
}

int main(int argc, char *argv[]) {
const size_t v = get_argv(argc, argv, 1, 5);
const size_t e = get_argv(argc, argv, 2, 10);
const size_t v = 5;
const size_t e = 10;
std::cout << "GraphAdjList" << std::endl;
graph_test<GraphAdjList<size_t>>(v, e);
std::cout << "GraphAdjMatrix" << std::endl;
Expand Down
3 changes: 3 additions & 0 deletions src/RaceExampleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ int test(size_t n) {
}

int main(int argc, char *argv[]) {
if (argc >= 2)
// Valgrind: do not test at all
return 0;
for (int n = 0; n < 2147483647; n++)
if (test(n))
return 0;
Expand Down

0 comments on commit 0ace10e

Please sign in to comment.