Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
c514e409
Commit
c514e409
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rm TestProjectUtils: it's more about itself than about any GUI functionality
parent
ce86234e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Unit/GUI/TestProjectUtils.cpp
+0
-76
0 additions, 76 deletions
Tests/Unit/GUI/TestProjectUtils.cpp
with
0 additions
and
76 deletions
Tests/Unit/GUI/TestProjectUtils.cpp
deleted
100644 → 0
+
0
−
76
View file @
ce86234e
#include
"GUI/Model/Project/ProjectUtil.h"
#include
"GUI/Support/Util/ItemFileNameUtil.h"
#include
"Tests/GTestWrapper/google_test.h"
#include
"Utils.h"
#include
<QDir>
#include
<QFile>
#include
<QTextStream>
#include
<iostream>
namespace
{
QStringList
dataInDir
(
const
QString
&
dirname
)
{
QDir
dir
(
dirname
);
if
(
!
dir
.
exists
())
throw
std
::
runtime_error
(
"Error. Non existing directory '"
+
dirname
.
toLatin1
()
+
"'."
);
return
dir
.
entryList
({
"*.int"
,
"*.int.gz"
});
}
}
// namespace
class
TestProjectUtils
:
public
::
testing
::
Test
{};
TEST_F
(
TestProjectUtils
,
dataInDir
)
{
const
QString
projectDir
=
"test_ProjectUtils"
;
QDir
dir
(
projectDir
);
if
(
dir
.
exists
())
{
EXPECT_TRUE
(
QDir
(
projectDir
).
removeRecursively
());
EXPECT_FALSE
(
dir
.
exists
());
}
UTest
::
GUI
::
create_dir
(
projectDir
);
EXPECT_TRUE
(
QFile
::
exists
(
projectDir
));
EXPECT_EQ
(
1
,
1
);
QStringList
test_data_files
{
"jobdata_job2_0.int"
,
"refdata_job2_0.int"
,
"realdata_box_nanodots_0.int"
,
"realdata_untitled_0.int"
};
const
QString
ext
=
QString
(
GUI
::
Project
::
Util
::
projectFileExtension
);
QStringList
test_some_other_files
{
"b.txt"
,
"untitled"
+
ext
};
std
::
cout
<<
"create files ..."
<<
std
::
endl
;
for
(
const
auto
&
fn
:
test_data_files
+
test_some_other_files
)
{
QString
filename
=
projectDir
.
isEmpty
()
?
fn
:
projectDir
+
"/"
+
fn
;
std
::
cout
<<
"..."
<<
filename
.
toStdString
()
<<
std
::
endl
;
QFile
file
(
filename
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
throw
std
::
runtime_error
(
"Error. Cannot create file"
);
QTextStream
out
(
&
file
);
out
<<
"Test file "
<<
42
<<
"
\n
"
;
file
.
close
();
EXPECT_TRUE
(
QFile
::
exists
(
filename
));
}
std
::
cout
<<
"check dataInDir ..."
<<
std
::
endl
;
// Check dataInDir method, should contain only files from test_data_files.
QStringList
datfiles
=
dataInDir
(
projectDir
);
std
::
cout
<<
"sort files ..."
<<
std
::
endl
;
datfiles
.
sort
();
test_data_files
.
sort
();
EXPECT_EQ
(
datfiles
.
size
(),
4
);
EXPECT_EQ
(
test_data_files
,
datfiles
);
std
::
cout
<<
"remove data files ..."
<<
std
::
endl
;
for
(
auto
&
name
:
datfiles
)
QFile
::
remove
(
projectDir
+
"/"
+
name
);
std
::
cout
<<
"check that no files left ..."
<<
std
::
endl
;
datfiles
=
dataInDir
(
projectDir
);
EXPECT_EQ
(
datfiles
.
size
(),
0
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment