mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This caused us to lose our gn check certification. :( Turns out gn check was just ignoring all the header paths it didn't understand and so gn check passing for sky wasn't meaning much. I tried to straighten out some of the mess in this CL, but its going to take several more rounds of massaging before gn check passes again. On the bright side (almost) all of our headers are absolute now. Turns out my script (attached to the bug) didn't notice ../ includes but I'll fix that in the next patch. R=abarth@chromium.org BUG=435361 Review URL: https://codereview.chromium.org/746023002
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
|
|
#include "sky/engine/wtf/text/TextCodecReplacement.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
#include "sky/engine/wtf/OwnPtr.h"
|
|
#include "sky/engine/wtf/text/CString.h"
|
|
#include "sky/engine/wtf/text/TextCodec.h"
|
|
#include "sky/engine/wtf/text/TextEncoding.h"
|
|
#include "sky/engine/wtf/text/TextEncodingRegistry.h"
|
|
#include "sky/engine/wtf/text/WTFString.h"
|
|
|
|
namespace WTF {
|
|
|
|
namespace {
|
|
|
|
// Just one example, others are listed in the codec implementation.
|
|
const char* replacementAlias = "iso-2022-kr";
|
|
|
|
TEST(TextCodecReplacement, Aliases)
|
|
{
|
|
// "replacement" is not a valid alias for itself
|
|
EXPECT_FALSE(TextEncoding("replacement").isValid());
|
|
EXPECT_FALSE(TextEncoding("rEpLaCeMeNt").isValid());
|
|
|
|
EXPECT_TRUE(TextEncoding(replacementAlias).isValid());
|
|
EXPECT_STREQ("replacement", TextEncoding(replacementAlias).name());
|
|
}
|
|
|
|
TEST(TextCodecReplacement, DecodesToFFFD)
|
|
{
|
|
TextEncoding encoding(replacementAlias);
|
|
OwnPtr<TextCodec> codec(newTextCodec(encoding));
|
|
|
|
bool sawError = false;
|
|
const char testCase[] = "hello world";
|
|
size_t testCaseSize = sizeof(testCase) - 1;
|
|
|
|
const String result = codec->decode(testCase, testCaseSize, DataEOF, false, sawError);
|
|
EXPECT_TRUE(sawError);
|
|
ASSERT_EQ(1u, result.length());
|
|
EXPECT_EQ(0xFFFDU, result[0]);
|
|
}
|
|
|
|
TEST(TextCodecReplacement, EncodesToUTF8)
|
|
{
|
|
TextEncoding encoding(replacementAlias);
|
|
OwnPtr<TextCodec> codec(newTextCodec(encoding));
|
|
|
|
// "Kanji" in Chinese characters.
|
|
const UChar testCase[] = { 0x6F22, 0x5B57 };
|
|
size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
|
|
CString result = codec->encode(testCase, testCaseSize, QuestionMarksForUnencodables);
|
|
|
|
EXPECT_STREQ("\xE6\xBC\xA2\xE5\xAD\x97", result.data());
|
|
}
|
|
|
|
} // namespace
|
|
|
|
} // namespace WTF
|