Skip to content

Commit 16375ca

Browse files
author
Julian LALU
committed
Add lipsum tests
1 parent ba67a87 commit 16375ca

File tree

9 files changed

+1689
-6
lines changed

9 files changed

+1689
-6
lines changed

test/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ set_target_properties(${test_project_name}
380380
# GCC Clang -fconstexpr-ops-limit=4294967295 -fconstexpr-steps=4294967295
381381
# Clang-cl -Xclang -fconstexpr-steps=4294967295
382382
if(MSVC)
383-
384-
target_compile_options( ${test_project_name} PRIVATE /Zc:__cplusplus /bigobj /permissive- /EHsc /utf-8 /arch:AVX2 /constexpr:steps2147483647 /constexpr:depth32767)
385383
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
386-
target_compile_options( ${test_project_name} PRIVATE -Xclang -fconstexpr-steps=2147483647)
384+
target_compile_options( ${test_project_name} PRIVATE /Zc:__cplusplus /bigobj /permissive- /EHsc /utf-8 /arch:AVX2 -Xclang -fconstexpr-steps=2147483647)
385+
else()
386+
target_compile_options( ${test_project_name} PRIVATE /Zc:__cplusplus /bigobj /permissive- /EHsc /utf-8 /arch:AVX2 /constexpr:steps2147483647 /constexpr:depth32767)
387387
endif()
388388
# Define them only weh compiling with 64 bits
389389
target_compile_definitions(${test_project_name} PRIVATE __SSE__ __SSE2__ __SSSE3__ __AVX__ __AVX2__)
@@ -392,7 +392,6 @@ elseif(EMSCRIPTEN)
392392
# set_target_properties(${test_project_name} PROPERTIES SUFFIX ".html")
393393
# Uncomment to generate an JS file testable with NodeJS (HTML must be commented)
394394
set_target_properties(${test_project_name} PROPERTIES SUFFIX ".js")
395-
396395
target_link_options(${test_project_name} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-sASSERTIONS> "-sENVIRONMENT=[\"web\",\"node\"]" -sABORTING_MALLOC=0 -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=134217728)
397396
target_compile_options( ${test_project_name} PRIVATE -msse4.2 -msimd128 -fconstexpr-ops-limit=2147483647 -fconstexpr-steps=2147483647)
398397
else()

test/cstring.cpp

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#include <core/cstring.h>
22
#include "string/lipsum/latin_lipsum.h"
33
#include "string/lipsum/russian_lipsum.h"
4+
#include "string/lipsum/korean_lipsum.h"
5+
#include "string/lipsum/japanese_lipsum.h"
6+
#include "string/lipsum/hindi_lipsum.h"
7+
#include "string/lipsum/hebrew_lipsum.h"
8+
#include "string/lipsum/emoji_lipsum.h"
9+
#include "string/lipsum/chinese_lipsum.h"
10+
#include "string/lipsum/arabic_lipsum.h"
11+
412
namespace hud_test
513
{
614
template<typename TCharType>
@@ -72,20 +80,83 @@ GTEST_TEST(cstring, is_vaid_utf8)
7280
const char8 russian_lipsum[] = RUSSIAN_LIPSUM;
7381
return hud::cstring::is_valid_utf8(RUSSIAN_LIPSUM, sizeof(russian_lipsum));
7482
};
83+
const auto test_korean = []() {
84+
// asm volatile("nop");
85+
const char8 korean_lipsum[] = KOREAN_LIPSUM;
86+
return hud::cstring::is_valid_utf8(KOREAN_LIPSUM, sizeof(korean_lipsum));
87+
};
88+
const auto test_japanese = []() {
89+
// asm volatile("nop");
90+
const char8 japanese_lipsum[] = JAPANESE_LIPSUM;
91+
return hud::cstring::is_valid_utf8(JAPANESE_LIPSUM, sizeof(japanese_lipsum));
92+
};
93+
const auto test_hindi = []() {
94+
// asm volatile("nop");
95+
const char8 hindi_lipsum[] = HINDI_LIPSUM;
96+
return hud::cstring::is_valid_utf8(HINDI_LIPSUM, sizeof(hindi_lipsum));
97+
};
98+
const auto test_hebrew = []() {
99+
// asm volatile("nop");
100+
const char8 hebrew_lipsum[] = HEBREW_LIPSUM;
101+
return hud::cstring::is_valid_utf8(HEBREW_LIPSUM, sizeof(hebrew_lipsum));
102+
};
103+
const auto test_emoji = []() {
104+
// asm volatile("nop");
105+
const char8 emoji_lipsum[] = EMOJI_LIPSUM;
106+
return hud::cstring::is_valid_utf8(EMOJI_LIPSUM, sizeof(emoji_lipsum));
107+
};
108+
const auto test_chinese = []() {
109+
// asm volatile("nop");
110+
const char8 chinese_lipsum[] = CHINESE_LIPSUM;
111+
return hud::cstring::is_valid_utf8(CHINESE_LIPSUM, sizeof(chinese_lipsum));
112+
};
113+
const auto test_arabic = []() {
114+
// asm volatile("nop");
115+
const char8 arabic_lipsum[] = ARABIC_LIPSUM;
116+
return hud::cstring::is_valid_utf8(ARABIC_LIPSUM, sizeof(arabic_lipsum));
117+
};
75118
// Non constant
76119
{
77120
const auto result_latin = test_latin();
78121
hud_assert_true(result_latin);
79122
const auto result_russian = test_russian();
80123
hud_assert_true(result_russian);
124+
const auto result_korean = test_korean();
125+
hud_assert_true(result_korean);
126+
const auto result_japanese = test_japanese();
127+
hud_assert_true(result_japanese);
128+
const auto result_hindi = test_hindi();
129+
hud_assert_true(result_hindi);
130+
const auto result_hebrew = test_hebrew();
131+
hud_assert_true(result_hebrew);
132+
const auto result_emoji = test_emoji();
133+
hud_assert_true(result_emoji);
134+
const auto result_chinese = test_chinese();
135+
hud_assert_true(result_chinese);
136+
const auto result_arabic = test_arabic();
137+
hud_assert_true(result_arabic);
81138
}
82139

83140
// Constant
84141
{
85-
constexpr auto result_latin = test_latin();
142+
const auto result_latin = test_latin();
86143
hud_assert_true(result_latin);
87-
constexpr auto result_russian = test_russian();
144+
const auto result_russian = test_russian();
88145
hud_assert_true(result_russian);
146+
constexpr auto result_korean = test_korean();
147+
hud_assert_true(result_korean);
148+
constexpr auto result_japanese = test_japanese();
149+
hud_assert_true(result_japanese);
150+
constexpr auto result_hindi = test_hindi();
151+
hud_assert_true(result_hindi);
152+
constexpr auto result_hebrew = test_hebrew();
153+
hud_assert_true(result_hebrew);
154+
constexpr auto result_emoji = test_emoji();
155+
hud_assert_true(result_emoji);
156+
constexpr auto result_chinese = test_chinese();
157+
hud_assert_true(result_chinese);
158+
constexpr auto result_arabic = test_arabic();
159+
hud_assert_true(result_arabic);
89160
}
90161
}
91162

0 commit comments

Comments
 (0)