c++ - Why does google test ASSERT_FALSE not work in methods but EXPECT_FALSE does -
both assert_true
, assert_false
not compile in librarytest
class error.
error c2664: 'std::basic_string<_elem,_traits,_alloc>::basic_string(const std::basic_string<_elem,_traits,_alloc> &)' : cannot convert parameter 1 'void' 'const std::basic_string<_elem,_traits,_alloc> &'
it works since in test_f
use. expect_false
compiles fine in both librarytest
class , test_f
methods.
how can use assert
in method used test_f
?
class librarytest : public ::testing::test { public: string create_library(string libname) { string libpath = setup_library_file(libname); librarybrowser::reload_models(); assert_false(library_exists_at_path(libpath)); new_library(libname, libpath); assert_true(library_exists_at_path(libpath)); expect_false(library_exists_at_path(libpath)); return libpath; } }; test_f(librarytest, libraries_changed) { string libname = "1xevtestlibrary"; string libpath = create_library(libname); }
functions using of gtest assertions need return void
. in case, change function thus:
void create_library(const string &libname, string &libpath) { libpath = ... assert_false(...) }
and use this:
test_f(librarytest, libraries_changed) { string libname = "foo"; string libpath; create_library(libname, libpath); }
Comments
Post a Comment