mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
AK: Add an extremely primitive unit test for String.
This builds for the host system rather than for Serenity. We need to improve on it a *lot*, but at least it's a place to start.
This commit is contained in:
parent
802612f665
commit
b7cca76ca2
Notes:
sideshowbarker
2024-07-19 13:37:14 +09:00
Author: https://github.com/awesomekling
Commit: b7cca76ca2
3 changed files with 29 additions and 0 deletions
1
AK/Tests/.gitignore
vendored
Normal file
1
AK/Tests/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
TestString
|
9
AK/Tests/Makefile
Normal file
9
AK/Tests/Makefile
Normal file
|
@ -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
|
19
AK/Tests/TestString.cpp
Normal file
19
AK/Tests/TestString.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <AK/AKString.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue