mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
chore(test): add tests for GxuDetermineQuotedCode
This commit is contained in:
parent
8d28d35bd1
commit
1ae694ccd1
@ -1,5 +1,11 @@
|
||||
if(WHOA_SYSTEM_MAC)
|
||||
file(GLOB PRIVATE_SOURCES "Test.cpp" "stub/Mac.mm" "gx/*.cpp" "util/*.cpp")
|
||||
file(GLOB PRIVATE_SOURCES
|
||||
"Test.cpp"
|
||||
"stub/Mac.mm"
|
||||
"gx/*.cpp"
|
||||
"gx/font/*.cpp"
|
||||
"util/*.cpp"
|
||||
)
|
||||
|
||||
set_source_files_properties(${PRIVATE_SOURCES}
|
||||
PROPERTIES COMPILE_FLAGS "-x objective-c++"
|
||||
@ -20,7 +26,12 @@ if(WHOA_SYSTEM_MAC)
|
||||
endif()
|
||||
|
||||
if(WHOA_SYSTEM_WIN OR WHOA_SYSTEM_LINUX)
|
||||
file(GLOB PRIVATE_SOURCES "Test.cpp" "gx/*.cpp" "util/*.cpp")
|
||||
file(GLOB PRIVATE_SOURCES
|
||||
"Test.cpp"
|
||||
"gx/*.cpp"
|
||||
"gx/font/*.cpp"
|
||||
"util/*.cpp"
|
||||
)
|
||||
|
||||
add_executable(WhoaTest ${PRIVATE_SOURCES})
|
||||
|
||||
|
||||
73
test/gx/font/GxuFont.cpp
Normal file
73
test/gx/font/GxuFont.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "gx/font/GxuFont.hpp"
|
||||
#include <cstdint>
|
||||
#include "catch.hpp"
|
||||
|
||||
TEST_CASE("GxuDetermineQuotedCode", "[gx]") {
|
||||
SECTION("does not recognize non-quoted code") {
|
||||
const char* str = "test1";
|
||||
uint32_t flags = 0x0;
|
||||
|
||||
int32_t advance;
|
||||
uint32_t code;
|
||||
QUOTEDCODE quotedCode;
|
||||
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_INVALIDCODE);
|
||||
REQUIRE(advance == 1);
|
||||
}
|
||||
|
||||
SECTION("recognizes newlines") {
|
||||
const char* str = "test1\ntest2\rtest3\r\ntest4";
|
||||
uint32_t flags = 0x0;
|
||||
|
||||
int32_t advance;
|
||||
uint32_t code;
|
||||
QUOTEDCODE quotedCode;
|
||||
|
||||
// \n
|
||||
str += 5;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 1);
|
||||
str += advance;
|
||||
|
||||
// \r
|
||||
str += 5;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 1);
|
||||
str += advance;
|
||||
|
||||
// \r\n
|
||||
str += 5;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 2);
|
||||
}
|
||||
|
||||
SECTION("recognizes quoted newlines") {
|
||||
const char* str = "test1|ntest2|n|ntest3";
|
||||
uint32_t flags = 0x0;
|
||||
|
||||
int32_t advance;
|
||||
uint32_t code;
|
||||
QUOTEDCODE quotedCode;
|
||||
|
||||
// |n
|
||||
str += 5;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 2);
|
||||
str += advance;
|
||||
|
||||
// |n|n
|
||||
str += 5;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 2);
|
||||
str += advance;
|
||||
quotedCode = GxuDetermineQuotedCode(str, advance, nullptr, flags, code);
|
||||
REQUIRE(quotedCode == CODE_NEWLINE);
|
||||
REQUIRE(advance == 2);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user