27 const char kEngNonLigatureText[] =
"fidelity effigy ſteep";
30 const char kEngLigatureText[] =
"fidelity effigy ſteep";
33 const char kRenderableEngLigatureText[] =
"fidelity effigy ſteep";
35 class LigatureTableTest :
public ::testing::Test {
37 void SetUp()
override {
38 static std::locale system_locale(
"");
39 std::locale::global(system_locale);
40 lig_table_ = LigatureTable::Get();
43 static void SetUpTestCase() {
44 FLAGS_fonts_dir = TESTING_DIR;
47 LigatureTable* lig_table_;
50 TEST_F(LigatureTableTest, DoesFillLigatureTables) {
51 EXPECT_GT(lig_table_->norm_to_lig_table().size(), 0);
52 EXPECT_GT(lig_table_->lig_to_norm_table().size(), 0);
55 TEST_F(LigatureTableTest, DoesAddLigatures) {
56 EXPECT_STREQ(kEngLigatureText,
57 lig_table_->AddLigatures(kEngNonLigatureText,
nullptr).c_str());
60 TEST_F(LigatureTableTest, DoesAddLigaturesWithSupportedFont) {
62 EXPECT_TRUE(font.ParseFontDescriptionName(
"Verdana"));
63 printf(
"1:%s\n", kRenderableEngLigatureText);
64 printf(
"2:%s\n", lig_table_->AddLigatures(kEngNonLigatureText, &font).c_str());
65 EXPECT_STREQ(kRenderableEngLigatureText,
66 lig_table_->AddLigatures(kEngNonLigatureText, &font).c_str());
69 TEST_F(LigatureTableTest, DoesNotAddLigaturesWithUnsupportedFont) {
71 EXPECT_TRUE(font.ParseFontDescriptionName(
"Lohit Hindi"));
72 EXPECT_STREQ(kEngNonLigatureText,
73 lig_table_->AddLigatures(kEngNonLigatureText, &font).c_str());
76 TEST_F(LigatureTableTest, DoesRemoveLigatures) {
77 EXPECT_STREQ(kEngNonLigatureText,
78 lig_table_->RemoveLigatures(kEngLigatureText).c_str());
81 TEST_F(LigatureTableTest, TestCustomLigatures) {
82 const char* kTestCases[] = {
83 "act",
"a\uE003",
"publiſh",
"publi\uE006",
"ſince",
84 "\uE007nce",
"aſleep",
"a\uE008eep",
"neceſſary",
"nece\uE009ary",
86 for (
size_t i = 0; i <
ARRAYSIZE(kTestCases); i += 2) {
87 EXPECT_STREQ(kTestCases[i + 1],
88 lig_table_->AddLigatures(kTestCases[i],
nullptr).c_str());
89 EXPECT_STREQ(kTestCases[i],
90 lig_table_->RemoveLigatures(kTestCases[i + 1]).c_str());
91 EXPECT_STREQ(kTestCases[i],
92 lig_table_->RemoveCustomLigatures(kTestCases[i + 1]).c_str());
96 TEST_F(LigatureTableTest, TestRemovesCustomLigatures) {
97 const char* kTestCases[] = {
102 for (
size_t i = 0; i <
ARRAYSIZE(kTestCases); i += 3) {
103 EXPECT_STREQ(kTestCases[i + 1],
104 lig_table_->AddLigatures(kTestCases[i],
nullptr).c_str());
105 EXPECT_STREQ(kTestCases[i + 2],
106 lig_table_->RemoveCustomLigatures(kTestCases[i + 1]).c_str());