mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(unicode): add SUniSPutUTF8
This commit is contained in:
parent
4bef36fcae
commit
9e00ad7036
3 changed files with 85 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "storm/Unicode.hpp"
|
||||
#include "storm/String.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
TEST_CASE("SUniSGetUTF8", "[unicode]") {
|
||||
|
|
@ -30,3 +31,31 @@ TEST_CASE("SUniSGetUTF8", "[unicode]") {
|
|||
REQUIRE(chars == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("SUniSPutUTF8", "[unicode]") {
|
||||
SECTION("writes ascii-range utf-8 first character") {
|
||||
auto code = 'f';
|
||||
char buffer[100] = { 0 };
|
||||
SUniSPutUTF8(code, buffer);
|
||||
|
||||
REQUIRE(SStrLen(buffer) == 1);
|
||||
REQUIRE(!SStrCmp(buffer, "f", SStrLen(buffer)));
|
||||
}
|
||||
|
||||
SECTION("writes non-ascii-range utf-8 first character") {
|
||||
auto code = 0x1F642;
|
||||
char buffer[100] = { 0 };
|
||||
SUniSPutUTF8(code, buffer);
|
||||
|
||||
REQUIRE(SStrLen(buffer) == 4);
|
||||
REQUIRE(!SStrCmp(buffer, "\xF0\x9F\x99\x82", SStrLen(buffer)));
|
||||
}
|
||||
|
||||
SECTION("writes null first character") {
|
||||
auto code = '\0';
|
||||
char buffer[100] = { 0 };
|
||||
SUniSPutUTF8(code, buffer);
|
||||
|
||||
REQUIRE(SStrLen(buffer) == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue