KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_scoped_temp_path.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
22#include <gestfich.h>
23
24#include <wx/ffile.h>
25#include <wx/filename.h>
26
27
28BOOST_AUTO_TEST_SUITE( ScopedTempPath )
29
30
31BOOST_AUTO_TEST_CASE( RemovesWhatItCreated )
32{
33 wxString directory;
34 wxString file;
35
36 {
37 SCOPED_TEMP_PATH tempDirectory;
38 SCOPED_TEMP_PATH tempFile;
39 BOOST_REQUIRE( tempDirectory.MakeDirectory( wxS( "kicad_qa_scoped" ) ) );
40 BOOST_REQUIRE( tempFile.MakeFile( wxS( "kicad_qa_scoped" ) ) );
41 directory = tempDirectory.Path();
42 file = tempFile.Path();
43 BOOST_CHECK( wxFileName::DirExists( directory ) );
44 BOOST_CHECK( wxFileName::FileExists( file ) );
45
46 wxFFile content( wxFileName( directory, wxS( "content" ) ).GetFullPath(), wxS( "w" ) );
47 BOOST_REQUIRE( content.IsOpened() );
48 }
49
50 BOOST_CHECK( !wxFileName::DirExists( directory ) );
51 BOOST_CHECK( !wxFileName::FileExists( file ) );
52}
53
54
A temporary file or directory that is removed when the object goes out of scope.
Definition gestfich.h:62
bool MakeFile(const wxString &aPrefix)
Create an empty file with a unique name after aPrefix.
Definition gestfich.cpp:939
bool MakeDirectory(const wxString &aPrefix)
Create an empty directory with a unique name after aPrefix.
Definition gestfich.cpp:946
const wxString & Path() const
Definition gestfich.h:75
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()