1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "pdf/file_extension.h"
7 #include "testing/gtest/include/gtest/gtest.h"
11 TEST(FileExtensionTest, FileNameToExtensionIndex) {
12 // File name with the first known file extension.
13 EXPECT_EQ(ExtensionIndex::k3ga, FileNameToExtensionIndex(u"first.3ga"));
15 // File name with the last known file extension.
16 EXPECT_EQ(ExtensionIndex::kTini, FileNameToExtensionIndex(u"last.tini"));
18 // File name without an extension.
19 EXPECT_EQ(ExtensionIndex::kEmptyExt,
20 FileNameToExtensionIndex(u"file_no_ext"));
22 // File name with an unrecognized file extension.
23 EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file.xyz"));
25 // File name with non-ASCII characters.
26 EXPECT_EQ(ExtensionIndex::kPdf, FileNameToExtensionIndex(u"你好.pdf"));
29 EXPECT_EQ(ExtensionIndex::kEmptyExt, FileNameToExtensionIndex(u""));
31 // File name with an extension which contains non-ASCII characters.
32 EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file.你好"));
34 // File name which ends with a dot.
35 EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file."));
38 } // namespace chrome_pdf