MCPcopy Create free account
hub / github.com/MrKepzie/Natron / TEST

Function TEST

Tests/KnobFile_Test.cpp:40–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38using namespace SequenceParsing;
39
40TEST(SequenceParsing, TestHashCharacter) {
41 ////////
42 ////////
43 /////// WARNING: If this test fails it *may* left some files on disk
44 ////// which can cause this test to fail on next run. For safety, if the test fails,
45 ////// please delete the files indicated by the location that should've been printed on stdout.
46
47 QStringList fileNames;
48 int sequenceItemsCount = 10;
49 ///create temporary files as a sequence and try to read that sequence.
50 QString tempPath = StandardPaths::writableLocation(StandardPaths::eStandardLocationTemp);
51 QDir dir(tempPath);
52 QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( qrand() );
53
54 dir.mkpath( QString::fromUtf8(".") );
55 dir.mkdir(dirName);
56 dir.cd(dirName);
57 for (int i = 0; i < sequenceItemsCount; ++i) {
58 QFile file( dir.absoluteFilePath( QString::fromUtf8("test_") + QString::number(i) + QString::fromUtf8(".unittest") ) );
59 fileNames << file.fileName();
60 std::cout << "Creating file: " << file.fileName().toStdString() << std::endl;
61 file.open(QIODevice::WriteOnly | QIODevice::Text);
62 file.close();
63 }
64 SequenceFromPattern sequence;
65 FileSystemModel::filesListFromPattern(dir.absoluteFilePath( QString::fromUtf8("test_#.unittest") ).toStdString(), &sequence);
66 EXPECT_EQ( sequenceItemsCount, (int)sequence.size() );
67
68 sequence.clear();
69 FileSystemModel::filesListFromPattern(dir.absoluteFilePath( QString::fromUtf8("test_##.unittest") ).toStdString(), &sequence);
70 EXPECT_EQ( 0, (int)sequence.size() );
71
72 ///test that a single file matching pattern would match a single file only.
73 sequence.clear();
74 FileSystemModel::filesListFromPattern(dir.absoluteFilePath( QString::fromUtf8("test_0.unittest") ).toStdString(), &sequence);
75 EXPECT_EQ( 1, (int)sequence.size() );
76
77 ///delete files
78 for (int i = 0; i < fileNames.size(); ++i) {
79 QFile::remove(fileNames[i]);
80 }
81
82 fileNames.clear();
83 ///re-create all 11 files withtout padding
84 sequenceItemsCount = 11;
85 for (int i = 0; i < sequenceItemsCount; ++i) {
86 QFile file( dir.absoluteFilePath( QString::fromUtf8("test_") + QString::number(i) + QString::fromUtf8(".unittest") ) );
87 fileNames << file.fileName();
88 std::cout << "Creating file: " << file.fileName().toStdString() << std::endl;
89 file.open(QIODevice::WriteOnly | QIODevice::Text);
90 file.close();
91 }
92
93 sequence.clear();
94 FileSystemModel::filesListFromPattern(dir.absoluteFilePath( QString::fromUtf8("test_##.unittest") ).toStdString(), &sequence);
95 EXPECT_EQ( 1, (int)sequence.size() );
96
97 ///delete files

Callers

nothing calls this directly

Calls 13

QStringClass · 0.85
mkdirMethod · 0.80
toStdStringMethod · 0.80
removeMethod · 0.80
atMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected