TsPlatform.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/unittest/core/utils/TsPlatform.cpp
22 
23  \brief A test suite for the TerraLib Core Utils Module.
24 
25  \author Carolina Galvão dos Santos
26  */
27 
28 // STL
29 #include <string>
30 
31 // TerraLib
33 
34 // Boost
35 #include <boost/test/unit_test.hpp>
36 #include <boost/algorithm/string/predicate.hpp>
37 
38 BOOST_AUTO_TEST_SUITE( platform_tests )
39 
40 BOOST_AUTO_TEST_CASE( findpath_correct_tests )
41 {
42 
43  /* Empty path */
44  BOOST_CHECK(te::core::FindInTerraLibPath("") != "");
45 
46  /* Search in the same path */
47  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/terralib_unittest_core"),"/terralib_unittest_core"));
48 
49  /* Search in the previous path */
50  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/share"),"/share"));
51 
52  /* Search in codebase path */
53  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/src"),"/src"));
54 
55  /* Search without / */
56  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("bin"),"/bin"));
57 
58  /* Search a file path */
59  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("src/terralib/core/utils/Platform.cpp"),"src/terralib/core/utils/Platform.cpp"));
60 
61  return;
62 }
63 
64 BOOST_AUTO_TEST_CASE( findpath_wrong_tests )
65 {
66 
67  /* Search path that doesn't exist */
68  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/abacate"),"/abacate") == false);
69 
70  /* Search an incorrect path*/
71  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/src/core/utils"),"/src/core/utils") == false);
72 
73  /* First directory is not in the search directories */
74  BOOST_CHECK(boost::algorithm::ends_with(te::core::FindInTerraLibPath("/core/encoding"),"/core/encoding") == false);
75 
76  return;
77 }
78 
79 BOOST_AUTO_TEST_CASE( system_directories_tests )
80 {
81  BOOST_CHECK_NO_THROW(te::core::GetUserDirectory());
82 
83  BOOST_CHECK_NO_THROW(te::core::GetAppDataLocation());
84 
85  BOOST_CHECK_NO_THROW(te::core::GetAppLocalDataLocation());
86 
87  return;
88 }
89 
90 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(platform_tests) BOOST_AUTO_TEST_CASE(findpath_correct_tests)
Definition: TsPlatform.cpp:38
TECOREEXPORT std::string GetAppDataLocation()
It returns the writable folder location to store application data applied to all users.
This file is a wrapper around platform specific include files.
BOOST_AUTO_TEST_CASE(findpath_wrong_tests)
Definition: TsPlatform.cpp:64
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
TECOREEXPORT std::string GetAppLocalDataLocation()
It returns the writable folder location to store per user data.
TECOREEXPORT std::string GetUserDirectory()
Returns the system user home dir path.