file_extension_unittest.cc 1.3 KB

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