diff --git a/AK/Tests/.gitignore b/AK/Tests/.gitignore new file mode 100644 index 00000000000..3a62d28e3c1 --- /dev/null +++ b/AK/Tests/.gitignore @@ -0,0 +1 @@ +TestString diff --git a/AK/Tests/Makefile b/AK/Tests/Makefile new file mode 100644 index 00000000000..fdec39410e2 --- /dev/null +++ b/AK/Tests/Makefile @@ -0,0 +1,9 @@ +all: TestString + +CXXFLAGS = -std=c++17 -Wall -Wextra + +TestString: TestString.cpp ../String.cpp ../StringImpl.cpp ../StringBuilder.cpp ../StringView.cpp + $(CXX) $(CXXFLAGS) -I../ -I../../ -o $@ TestString.cpp ../String.cpp ../StringImpl.cpp ../StringBuilder.cpp ../StringView.cpp + +clean: + rm -f TestString diff --git a/AK/Tests/TestString.cpp b/AK/Tests/TestString.cpp new file mode 100644 index 00000000000..fb26395a097 --- /dev/null +++ b/AK/Tests/TestString.cpp @@ -0,0 +1,19 @@ +#include + +int main() +{ + ASSERT(String().is_null()); + ASSERT(String().is_empty()); + + ASSERT(!String("").is_null()); + ASSERT(String("").is_empty()); + + String test_string = "ABCDEF"; + ASSERT(!test_string.is_empty()); + ASSERT(!test_string.is_null()); + ASSERT(test_string.length() == 6); + ASSERT(test_string.length() == strlen(test_string.characters())); + ASSERT(!strcmp(test_string.characters(), "ABCDEF")); + + return 0; +}