File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -596,6 +596,13 @@ if (BUILD_LAGOM)
596
596
lagom_test (${source} LIBS LagomSQL )
597
597
endforeach ()
598
598
599
+ # TextCodec
600
+ file (GLOB LIBTEXTCODEC_TESTS CONFIGURE_DEPENDS "../../Tests/LibTextCodec/*.cpp" )
601
+ foreach (source ${LIBTEXTCODEC_TESTS} )
602
+ lagom_test (${source} LIBS LagomTextCodec
603
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /../../Tests/LibTextCodec )
604
+ endforeach ()
605
+
599
606
# TLS
600
607
file (GLOB LIBTLS_TESTS CONFIGURE_DEPENDS "../../Tests/LibTLS/*.cpp" )
601
608
foreach (source ${LIBTLS_TESTS} )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ add_subdirectory(LibPthread)
17
17
add_subdirectory (LibRegex )
18
18
add_subdirectory (LibSQL )
19
19
add_subdirectory (LibTest )
20
+ add_subdirectory (LibTextCodec )
20
21
add_subdirectory (LibThreading )
21
22
add_subdirectory (LibTimeZone )
22
23
add_subdirectory (LibUnicode )
Original file line number Diff line number Diff line change
1
+ set (TEST_SOURCES
2
+ TestTextDecoders.cpp
3
+ )
4
+
5
+ foreach (source IN LISTS TEST_SOURCES )
6
+ serenity_test ("${source} " LibTextCodec LIBS LibTextCodec )
7
+ endforeach ()
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2022, the SerenityOS developers.
3
+ *
4
+ * SPDX-License-Identifier: BSD-2-Clause
5
+ */
6
+
7
+ #include < AK/Vector.h>
8
+ #include < LibTest/TestCase.h>
9
+ #include < LibTextCodec/Decoder.h>
10
+
11
+ TEST_CASE (test_utf8_decode)
12
+ {
13
+ auto decoder = TextCodec::UTF8Decoder ();
14
+ // Bytes for U+1F600 GRINNING FACE
15
+ auto test_string = " \xf0\x9f\x98\x80 " ;
16
+
17
+ Vector<u32 > processed_code_points;
18
+ decoder.process (test_string, [&](u32 code_point) {
19
+ processed_code_points.append (code_point);
20
+ });
21
+ EXPECT (processed_code_points.size () == 1 );
22
+ EXPECT (processed_code_points[0 ] == 0x1F600 );
23
+
24
+ EXPECT (decoder.to_utf8 (test_string) == test_string);
25
+ }
You can’t perform that action at this time.
0 commit comments