diff options
author | 2011-05-13 17:05:54 +0800 | |
---|---|---|
committer | 2011-05-13 19:08:05 +0800 | |
commit | 89b7d86f8319dd3b26e8486c5ff6c736e52f769c (patch) | |
tree | 15f13475f212d0e4e26854da701f999e9f0e3bd5 /test | |
parent | Build: silence javac warnings (diff) | |
download | libbash-89b7d86f8319dd3b26e8486c5ff6c736e52f769c.tar.gz libbash-89b7d86f8319dd3b26e8486c5ff6c736e52f769c.tar.bz2 libbash-89b7d86f8319dd3b26e8486c5ff6c736e52f769c.zip |
Tests: fix cppunittests
NULL is not allowed to initialize a string object. A common
helper function is created to solve the problem.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.cpp | 35 | ||||
-rw-r--r-- | test/test.h | 31 |
2 files changed, 66 insertions, 0 deletions
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 |