Files

65 lines
2.3 KiB
C++
Raw Permalink Normal View History

2018-06-15 14:07:34 +02:00
/*****************************************************************************
2024-12-31 20:30:04 +01:00
* Copyright (c) 2014-2025 OpenRCT2 developers
2018-06-15 14:07:34 +02:00
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2018-06-22 22:29:03 +02:00
#include "helpers/StringHelpers.hpp"
#include "openrct2/localisation/Language.h"
#include "openrct2/rct12/CSStringConverter.h"
2018-06-22 22:29:03 +02:00
2018-04-15 16:43:28 +01:00
#include <gtest/gtest.h>
using namespace OpenRCT2;
2018-04-15 16:43:28 +01:00
class Localisation : public testing::Test
{
};
///////////////////////////////////////////////////////////////////////////////
// Tests for RCT2StringToUTF8
2018-04-15 16:43:28 +01:00
///////////////////////////////////////////////////////////////////////////////
TEST_F(Localisation, RCT2_to_UTF8_UK)
{
auto input = "The quick brown fox";
auto expected = u8"The quick brown fox";
2025-10-07 20:29:20 +02:00
auto actual = RCT2StringToUTF8(input, RCT2LanguageId::englishUK);
2018-04-15 16:43:28 +01:00
ASSERT_EQ(expected, actual);
}
TEST_F(Localisation, RCT2_to_UTF8_JP)
{
2018-04-15 18:34:09 +01:00
auto input = StringFromHex("ff8374ff8340ff8358ff8367ff8375ff8389ff8345ff8393ff8374ff8348ff8362ff834eff8358");
2018-04-15 16:43:28 +01:00
auto expected = u8"ファストブラウンフォックス";
2025-10-07 20:29:20 +02:00
auto actual = RCT2StringToUTF8(input, RCT2LanguageId::japanese);
2018-04-15 16:43:28 +01:00
ASSERT_EQ(expected, actual);
}
TEST_F(Localisation, RCT2_to_UTF8_ZH_TW)
{
2018-04-15 18:34:09 +01:00
auto input = StringFromHex("ffa7d6ffb374ffaabaffb4c4ffa6e2ffaab0ffaf57");
2018-04-15 16:43:28 +01:00
auto expected = u8"快速的棕色狐狸";
2025-10-07 20:29:20 +02:00
auto actual = RCT2StringToUTF8(input, RCT2LanguageId::chineseTraditional);
2018-04-15 16:43:28 +01:00
ASSERT_EQ(expected, actual);
}
TEST_F(Localisation, RCT2_to_UTF8_PL)
{
auto input = StringFromHex("47F372736b6120446ff76b692054e6637a6f7779");
auto expected = u8"Górska Dołki Tęczowy";
2025-10-07 20:29:20 +02:00
auto actual = RCT2StringToUTF8(input, RCT2LanguageId::englishUK);
2018-04-15 16:43:28 +01:00
ASSERT_EQ(expected, actual);
}
2018-04-19 22:07:12 +01:00
TEST_F(Localisation, RCT2_to_UTF8_ZH_TW_PREMATURE_END)
{
// This string can be found in BATFL.DAT, the last double byte character is missing its second byte.
auto input = StringFromHex("ffa470ffabacffa8aeffbdf8ffa662ffc54bffb944ffa457ffaeb6ffb0caffb76effc2");
auto expected = u8"小型車輛在鐵道上振動搖";
2025-10-07 20:29:20 +02:00
auto actual = RCT2StringToUTF8(input, RCT2LanguageId::chineseTraditional);
2018-04-19 22:07:12 +01:00
ASSERT_EQ(expected, actual);
}