// Copyright: All Rights Reserved // Author: egametang@gmail.com (tanghai) #include #include #include "Orm/DbHelper.h" #include "Orm/DbResult.h" #include "Orm/Select.h" #include "Orm/Person.pb.h" #include "Orm/Exception.h" namespace Egametang { class DbResultTest: public testing::Test { }; TEST_F(DbResultTest, One) { try { DbHelper dbHelper("tcp://127.0.0.1:3306", "root", "111111"); DbResultPtr result = dbHelper.Execute( Select(Column("*")). Where(Column("age") > 10) ); auto person = boost::make_shared(); result->One(person); ASSERT_EQ(26, person->age()); } catch (const Exception& e) { if (const std::string* str = boost::get_error_info(e)) { LOG(FATAL) << *str; } if (const std::string* str = boost::get_error_info(e)) { LOG(WARNING) << *str; } } } } // namespace Egametang int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }