mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Add a basic unit test for FileSystemPath
Just to make sure that things are on the up-and-up.
This commit is contained in:
parent
1f9b8f0e7c
commit
43ec733b61
Notes:
sideshowbarker
2024-07-19 12:50:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/43ec733b61a
2 changed files with 35 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
PROGRAMS = TestString TestQueue TestVector TestHashMap TestJSON TestWeakPtr TestNonnullRefPtr TestRefPtr TestFixedArray
|
||||
PROGRAMS = TestString TestQueue TestVector TestHashMap TestJSON TestWeakPtr TestNonnullRefPtr TestRefPtr TestFixedArray TestFileSystemPath
|
||||
|
||||
CXXFLAGS = -std=c++17 -Wall -Wextra -ggdb3 -O2 -I../ -I../../
|
||||
|
||||
|
@ -12,6 +12,7 @@ SHARED_TEST_OBJS = \
|
|||
../JsonObject.o \
|
||||
../JsonValue.o \
|
||||
../JsonParser.o \
|
||||
../FileSystemPath.o \
|
||||
|
||||
.cpp.o:
|
||||
@echo "HOST_CXX $<"; $(PRE_CXX) $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
@ -54,6 +55,10 @@ TestRefPtr: TestRefPtr.o $(SHARED_TEST_OBJS)
|
|||
TestOptional: TestOptional.o $(SHARED_TEST_OBJS)
|
||||
$(PRE_CXX) $(CXX) $(CXXFLAGS) -o $@ TestOptional.o $(SHARED_TEST_OBJS)
|
||||
|
||||
TestFileSystemPath: TestFileSystemPath.o $(SHARED_TEST_OBJS)
|
||||
$(PRE_CXX) $(CXX) $(CXXFLAGS) -o $@ TestFileSystemPath.o $(SHARED_TEST_OBJS)
|
||||
|
||||
|
||||
clean:
|
||||
rm -f $(SHARED_TEST_OBJS)
|
||||
rm -f $(PROGRAMS)
|
||||
|
|
29
AK/Tests/TestFileSystemPath.cpp
Normal file
29
AK/Tests/TestFileSystemPath.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath().is_valid(), false);
|
||||
}
|
||||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
FileSystemPath path("/abc/def/ghi.txt");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.basename(), "ghi.txt");
|
||||
EXPECT_EQ(path.title(), "ghi");
|
||||
EXPECT_EQ(path.extension(), "txt");
|
||||
EXPECT_EQ(path.parts().size(), 3);
|
||||
EXPECT_EQ(path.parts(), Vector<String>({ "abc", "def", "ghi.txt" }));
|
||||
EXPECT_EQ(path.string(), "/abc/def/ghi.txt");
|
||||
}
|
||||
|
||||
TEST_CASE(dotdot_coalescing)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath("/home/user/../../not/home").string(), "/not/home");
|
||||
EXPECT_EQ(FileSystemPath("/../../../../").string(), "/");
|
||||
}
|
||||
|
||||
TEST_MAIN(FileSystemPath)
|
Loading…
Reference in a new issue