Skip to content

Commit 9b3d599

Browse files
committed
TestPath: improved existence tests and generate files for tests
1 parent 39192b8 commit 9b3d599

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ test/testoptions.o: test/testoptions.cpp lib/check.h lib/color.h lib/config.h li
779779
test/testother.o: test/testother.cpp externals/simplecpp/simplecpp.h lib/check.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h
780780
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testother.cpp
781781

782-
test/testpath.o: test/testpath.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h
782+
test/testpath.o: test/testpath.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
783783
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpath.cpp
784784

785785
test/testpathmatch.o: test/testpathmatch.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h

test/testpath.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "path.h"
2020
#include "fixture.h"
21+
#include "helpers.h"
2122

2223
#include <string>
2324
#include <vector>
@@ -159,13 +160,21 @@ class TestPath : public TestFixture {
159160
}
160161

161162
void isDirectory() const {
162-
ASSERT_EQUALS(false, Path::isDirectory("readme.txt"));
163-
ASSERT_EQUALS(true, Path::isDirectory("lib"));
163+
ScopedFile file("testpath.txt", "", "testpath");
164+
ScopedFile file2("testpath2.txt", "");
165+
ASSERT_EQUALS(false, Path::isDirectory("testpath.txt"));
166+
ASSERT_EQUALS(true, Path::isDirectory("testpath"));
167+
ASSERT_EQUALS(false, Path::isDirectory("testpath/testpath.txt"));
168+
ASSERT_EQUALS(false, Path::isDirectory("testpath2.txt"));
164169
}
165170

166171
void isFile() const {
167-
ASSERT_EQUALS(false, Path::isFile("lib"));
168-
ASSERT_EQUALS(true, Path::isFile("readme.txt"));
172+
ScopedFile file("testpath.txt", "", "testpath");
173+
ScopedFile file2("testpath2.txt", "");
174+
ASSERT_EQUALS(false, Path::isFile("testpath"));
175+
ASSERT_EQUALS(false, Path::isFile("testpath.txt"));
176+
ASSERT_EQUALS(true, Path::isFile("testpath/testpath.txt"));
177+
ASSERT_EQUALS(true, Path::isFile("testpath2.txt"));
169178
}
170179
};
171180

0 commit comments

Comments
 (0)