// Copyright 2017 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "xfa/fgas/crt/cfgas_stringformatter.h" #include <iterator> #include "build/build_config.h" #include "core/fpdfapi/page/cpdf_pagemodule.h" #include "core/fxcrt/cfx_datetime.h" #include "testing/fx_string_testhelpers.h" #include "testing/fxgc_unittest.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/scoped_set_tz.h" #include "v8/include/cppgc/persistent.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" ElementsAre; class CFGAS_StringFormatterTest : public FXGCUnitTest { … }; // TODO(dsinclair): Looks like the formatter/parser does not handle the various // 'g' flags. TEST_F(CFGAS_StringFormatterTest, DateFormat) { … } TEST_F(CFGAS_StringFormatterTest, TimeFormat) { … } TEST_F(CFGAS_StringFormatterTest, DateTimeFormat) { … } TEST_F(CFGAS_StringFormatterTest, TimeDateFormat) { … } TEST_F(CFGAS_StringFormatterTest, DateParse) { … } // TODO(dsinclair): GetDateTimeFormat is broken and doesn't allow just returning // a parsed Time. It will assume it's a Date. The method needs to be re-written. // TEST_F(CFGAS_StringFormatterTest, TimeParse) { // struct { // const wchar_t* locale; // const wchar_t* input; // const wchar_t* pattern; // CFX_DateTime output; // } tests[] = { // {L"en", L"18:00", L"HH:MM", CFX_DateTime(0, 0, 0, 18, 0, 0, 0)}, // {L"en", L"12.59 Uhr", L"H.MM 'Uhr'", CFX_DateTime(0, 0, 0, 12, 59, 0, // 0)}, {L"en", L"1:05:10 PM PST", L"h:MM:SS A Z", // CFX_DateTime(0, 0, 0, 17, 05, 10, 0)}}; // // Note, none of the full width date symbols are listed here as they are // // not supported. In theory there are the full width versions of kkk, // // kkkk, HHH, HHHH, KKK, KKKK, MMM, MMMM, SSS, SSSS plus 2 more that the // // spec apparently forgot to list the symbol. // for (size_t i = 0; i < std::size(tests); ++i) { // CFX_DateTime result; // EXPECT_TRUE(fmt(tests[i].locale) // ->ParseDateTime(tests[i].input, tests[i].pattern, // CFGAS_StringFormatter::DateTimeType::kTime, // &result)); // EXPECT_EQ(tests[i].output, result) << " TEST: " << i; // } // } TEST_F(CFGAS_StringFormatterTest, SplitFormatString) { … } TEST_F(CFGAS_StringFormatterTest, NumParse) { … } TEST_F(CFGAS_StringFormatterTest, NumFormat) { … } TEST_F(CFGAS_StringFormatterTest, TextParse) { … } TEST_F(CFGAS_StringFormatterTest, InvalidTextParse) { … } TEST_F(CFGAS_StringFormatterTest, TextFormat) { … } TEST_F(CFGAS_StringFormatterTest, NullParse) { … } TEST_F(CFGAS_StringFormatterTest, NullFormat) { … } TEST_F(CFGAS_StringFormatterTest, ZeroParse) { … } TEST_F(CFGAS_StringFormatterTest, ZeroFormat) { … } TEST_F(CFGAS_StringFormatterTest, GetCategory) { … }