Mercurial > hg > orthanc-postgresql
view UnitTestsSources/UnitTestsMain.cpp @ 126:ba9cb920e679
shared copyright with osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Jan 2017 16:21:15 +0100 |
parents | e6f78f4dd66d |
children | 11c4f0a4b647 |
line wrap: on
line source
/** * Orthanc - A Lightweight, RESTful DICOM Store * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * Copyright (C) 2017 Osimis, Belgium * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * This program 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 * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #include "../Core/PostgreSQLConnection.h" #include <gtest/gtest.h> #include <memory> #include <boost/lexical_cast.hpp> static int argc_; static char** argv_; OrthancPlugins::PostgreSQLConnection* CreateTestConnection(bool clearAll) { std::auto_ptr<OrthancPlugins::PostgreSQLConnection> pg(new OrthancPlugins::PostgreSQLConnection); pg->SetHost(argv_[1]); pg->SetPortNumber(boost::lexical_cast<uint16_t>(argv_[2])); pg->SetUsername(argv_[3]); pg->SetPassword(argv_[4]); pg->SetDatabase(argv_[5]); pg->Open(); if (clearAll) { pg->ClearAll(); } return pg.release(); } int main(int argc, char **argv) { if (argc < 6) { std::cerr << "Usage: " << argv[0] << " <host> <port> <username> <password> <database>" << std::endl << std::endl << "Example: " << argv[0] << " localhost 5432 postgres postgres orthanctest" << std::endl << std::endl; return -1; } argc_ = argc; argv_ = argv; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }