* [gentoo-commits] proj/libbash:master commit in: /, src/builtins/tests/, test/
@ 2011-05-13 11:06 Petteri Räty
0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-05-13 11:06 UTC (permalink / raw
To: gentoo-commits
commit: 89b7d86f8319dd3b26e8486c5ff6c736e52f769c
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri May 13 09:05:54 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri May 13 11:08:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=89b7d86f
Tests: fix cppunittests
NULL is not allowed to initialize a string object. A common
helper function is created to solve the problem.
---
Makefile.am | 3 +++
src/builtins/tests/source_tests.cpp | 14 ++++----------
test/test.cpp | 35 +++++++++++++++++++++++++++++++++++
test/test.h | 31 +++++++++++++++++++++++++++++++
4 files changed, 73 insertions(+), 10 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 33387ff..3d26460 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -103,6 +103,8 @@ cppunittests_SOURCES = test/run_tests.cpp \
src/builtins/tests/boolean_tests.cpp \
src/builtins/tests/source_tests.cpp \
src/builtins/tests/return_tests.cpp \
+ test/test.h \
+ test/test.cpp \
test/post_check.cpp \
test/api_test.cpp \
test/walker_test.cpp
@@ -111,6 +113,7 @@ cppunittests_LDADD = libcppbash.la \
$(BOOST_SYSTEM_LIB) \
$(BOOST_FILESYSTEM_LIB)
cppunittests_LDFLAGS = -static
+cppunittests_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/test/
endif
diff --git a/src/builtins/tests/source_tests.cpp b/src/builtins/tests/source_tests.cpp
index ae603ae..aa9aa27 100644
--- a/src/builtins/tests/source_tests.cpp
+++ b/src/builtins/tests/source_tests.cpp
@@ -21,8 +21,6 @@
/// \brief series of unit tests for source built in
///
-#include <cstdlib>
-
#include <iostream>
#include <string>
@@ -31,16 +29,14 @@
#include "builtins/builtin_exceptions.h"
#include "core/interpreter.h"
#include "cppbash_builtin.h"
-
-using namespace std;
+#include "test.h"
TEST(source_builtin_test, source_true)
{
- std::string srcdir(getenv("srcdir"));
interpreter walker;
int status = cppbash_builtin::exec("source",
- {srcdir + "/scripts/source_true.sh"},
+ {get_src_dir() + "/scripts/source_true.sh"},
std::cout,
std::cerr,
std::cin,
@@ -52,10 +48,9 @@ TEST(source_builtin_test, source_true)
TEST(source_builtin_test, source_false)
{
- std::string srcdir(getenv("srcdir"));
interpreter walker;
int status = cppbash_builtin::exec("source",
- {srcdir + "/scripts/source_false.sh"},
+ {get_src_dir() + "/scripts/source_false.sh"},
std::cout,
std::cerr,
std::cin,
@@ -65,10 +60,9 @@ TEST(source_builtin_test, source_false)
TEST(source_builtin_test, source_return)
{
- std::string srcdir(getenv("srcdir"));
interpreter walker;
int status = cppbash_builtin::exec("source",
- {srcdir + "/scripts/source_return.sh"},
+ {get_src_dir() + "/scripts/source_return.sh"},
std::cout,
std::cerr,
std::cin,
diff --git a/test/test.cpp b/test/test.cpp
new file mode 100644
index 0000000..da4bc9e
--- /dev/null
+++ b/test/test.cpp
@@ -0,0 +1,35 @@
+/*
+ Please use git log for copyright holder and year information
+
+ This file is part of libbash.
+
+ libbash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ libbash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libbash. If not, see <http://www.gnu.org/licenses/>.
+ */
+///
+/// \file test.cpp
+/// \author Mu Qiao
+/// \brief helper functions for tests
+///
+#include <cstdlib>
+
+#include "test.h"
+
+std::string get_src_dir()
+{
+ std::string srcdir(".");
+ if(getenv("srcdir"))
+ srcdir = getenv("srcdir");
+
+ return srcdir;
+}
diff --git a/test/test.h b/test/test.h
new file mode 100644
index 0000000..18a1a31
--- /dev/null
+++ b/test/test.h
@@ -0,0 +1,31 @@
+/*
+ Please use git log for copyright holder and year information
+
+ This file is part of libbash.
+
+ libbash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ libbash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libbash. If not, see <http://www.gnu.org/licenses/>.
+ */
+///
+/// \file test.h
+/// \author Mu Qiao
+/// \brief helper functions for tests
+///
+#ifndef LIBBASH_TEST_H_
+#define LIBBASH_TEST_H_
+
+#include <string>
+
+std::string get_src_dir();
+
+#endif
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-13 11:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13 11:06 [gentoo-commits] proj/libbash:master commit in: /, src/builtins/tests/, test/ Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox