From 0d3ef65dcdefd06d760257d99d53ff922e9705bc Mon Sep 17 00:00:00 2001 From: Rick Gibbed Date: Fri, 25 Jun 2021 23:06:08 -0500 Subject: [PATCH] Add more UTF-8 path tests. Add more UTF-8 path tests to catch newly discovered issues. --- src/xenia/base/testing/utf8_test.cc | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/xenia/base/testing/utf8_test.cc b/src/xenia/base/testing/utf8_test.cc index 9a33ff4fb..37255549d 100644 --- a/src/xenia/base/testing/utf8_test.cc +++ b/src/xenia/base/testing/utf8_test.cc @@ -388,20 +388,39 @@ TEST_CASE("UTF-8 Fix Path Separators", "[utf8]") { TEST_CASE("UTF-8 Find Name From Path", "[utf8]") { TEST_PATH(utf8::find_name_from_path, "/", ""); + TEST_PATH(utf8::find_name_from_path, "//", ""); + TEST_PATH(utf8::find_name_from_path, "///", ""); TEST_PATH(utf8::find_name_from_path, "foo/bar/baz/qux/", "qux"); + TEST_PATH(utf8::find_name_from_path, "foo/bar/baz/qux//", "qux"); + TEST_PATH(utf8::find_name_from_path, "foo/bar/baz/qux///", "qux"); TEST_PATH(utf8::find_name_from_path, "foo/bar/baz/qux.txt", "qux.txt"); TEST_PATH(utf8::find_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "ほげほげ"); TEST_PATH(utf8::find_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ.txt"); + TEST_PATH(utf8::find_name_from_path, "/foo", "foo"); + TEST_PATH(utf8::find_name_from_path, "//foo", "foo"); + TEST_PATH(utf8::find_name_from_path, "///foo", "foo"); TEST_PATH(utf8::find_name_from_path, "/foo/bar/baz/qux.txt", "qux.txt"); TEST_PATH(utf8::find_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "ほげほげ"); TEST_PATH(utf8::find_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ.txt"); TEST_PATH(utf8::find_name_from_path, "X:/foo/bar/baz/qux.txt", "qux.txt"); TEST_PATH(utf8::find_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげほげ"); + TEST_PATH(utf8::find_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "ほげほげ"); TEST_PATH(utf8::find_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ.txt"); TEST_PATH(utf8::find_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら.ほげほげ", @@ -413,26 +432,44 @@ TEST_CASE("UTF-8 Find Name From Path", "[utf8]") { TEST_CASE("UTF-8 Find Base Name From Path", "[utf8]") { TEST_PATH(utf8::find_base_name_from_path, "foo/bar/baz/qux.txt", "qux"); TEST_PATH(utf8::find_base_name_from_path, "foo/bar/baz/qux/", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "foo/bar/baz/qux//", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "foo/bar/baz/qux///", "qux"); TEST_PATH(utf8::find_base_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "ほげ/ぴよ/ふが/ほげら.ほげほげ", "ほげら"); TEST_PATH(utf8::find_base_name_from_path, "/foo/bar/baz/qux.txt", "qux"); TEST_PATH(utf8::find_base_name_from_path, "/foo/bar/baz/qux/", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "/foo/bar/baz/qux//", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "/foo/bar/baz/qux///", "qux"); TEST_PATH(utf8::find_base_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, + "/ほげ/ぴよ/ふが/ほげら/ほげほげ///", "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "/ほげ/ぴよ/ふが/ほげら.ほげほげ", "ほげら"); TEST_PATH(utf8::find_base_name_from_path, "X:/foo/bar/baz/qux.txt", "qux"); TEST_PATH(utf8::find_base_name_from_path, "X:/foo/bar/baz/qux/", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "X:/foo/bar/baz/qux//", "qux"); + TEST_PATH(utf8::find_base_name_from_path, "X:/foo/bar/baz/qux///", "qux"); TEST_PATH(utf8::find_base_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ.txt", "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, + "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ//", "ほげほげ"); + TEST_PATH(utf8::find_base_name_from_path, + "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ///", "ほげほげ"); TEST_PATH(utf8::find_base_name_from_path, "X:/ほげ/ぴよ/ふが/ほげら.ほげほげ", "ほげら"); } @@ -443,38 +480,79 @@ TEST_CASE("UTF-8 Find Base Path", "[utf8]") { TEST_PATH(utf8::find_base_path, "", ""); TEST_PATH(utf8::find_base_path, "/", ""); TEST_PATH(utf8::find_base_path, "//", ""); + TEST_PATH(utf8::find_base_path, "///", ""); TEST_PATH(utf8::find_base_path, "/foo", ""); + TEST_PATH(utf8::find_base_path, "//foo", ""); + TEST_PATH(utf8::find_base_path, "///foo", ""); TEST_PATH(utf8::find_base_path, "/foo/", ""); + TEST_PATH(utf8::find_base_path, "/foo//", ""); + TEST_PATH(utf8::find_base_path, "/foo///", ""); + TEST_PATH(utf8::find_base_path, "//foo/", ""); + TEST_PATH(utf8::find_base_path, "//foo//", ""); + TEST_PATH(utf8::find_base_path, "//foo///", ""); + TEST_PATH(utf8::find_base_path, "///foo/", ""); + TEST_PATH(utf8::find_base_path, "///foo//", ""); + TEST_PATH(utf8::find_base_path, "///foo///", ""); TEST_PATH(utf8::find_base_path, "/foo/bar", "/foo"); TEST_PATH(utf8::find_base_path, "/foo/bar/", "/foo"); + TEST_PATH(utf8::find_base_path, "/foo/bar//", "/foo"); + TEST_PATH(utf8::find_base_path, "/foo/bar///", "/foo"); TEST_PATH(utf8::find_base_path, "/foo/bar/baz/qux", "/foo/bar/baz"); TEST_PATH(utf8::find_base_path, "/foo/bar/baz/qux/", "/foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "/foo/bar/baz/qux//", "/foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "/foo/bar/baz/qux///", "/foo/bar/baz"); TEST_PATH(utf8::find_base_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ", "/ほげ/ぴよ/ふが/ほげら"); TEST_PATH(utf8::find_base_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "/ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "/ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "/ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "/ほげ/ぴよ/ふが/ほげら"); TEST_PATH(utf8::find_base_path, "foo", ""); TEST_PATH(utf8::find_base_path, "foo/", ""); + TEST_PATH(utf8::find_base_path, "foo//", ""); + TEST_PATH(utf8::find_base_path, "foo///", ""); TEST_PATH(utf8::find_base_path, "foo/bar", "foo"); TEST_PATH(utf8::find_base_path, "foo/bar/", "foo"); + TEST_PATH(utf8::find_base_path, "foo/bar//", "foo"); + TEST_PATH(utf8::find_base_path, "foo/bar///", "foo"); TEST_PATH(utf8::find_base_path, "foo/bar/baz/qux", "foo/bar/baz"); TEST_PATH(utf8::find_base_path, "foo/bar/baz/qux/", "foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "foo/bar/baz/qux//", "foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "foo/bar/baz/qux///", "foo/bar/baz"); TEST_PATH(utf8::find_base_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ", "ほげ/ぴよ/ふが/ほげら"); TEST_PATH(utf8::find_base_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ/", "ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "ほげ/ぴよ/ふが/ほげら"); TEST_PATH(utf8::find_base_path, "X:", ""); TEST_PATH(utf8::find_base_path, "X:/", ""); + TEST_PATH(utf8::find_base_path, "X://", ""); + TEST_PATH(utf8::find_base_path, "X:///", ""); TEST_PATH(utf8::find_base_path, "X:/foo", "X:"); TEST_PATH(utf8::find_base_path, "X:/foo/", "X:"); + TEST_PATH(utf8::find_base_path, "X:/foo//", "X:"); + TEST_PATH(utf8::find_base_path, "X:/foo///", "X:"); TEST_PATH(utf8::find_base_path, "X:/foo/bar", "X:/foo"); TEST_PATH(utf8::find_base_path, "X:/foo/bar/", "X:/foo"); + TEST_PATH(utf8::find_base_path, "X:/foo/bar//", "X:/foo"); + TEST_PATH(utf8::find_base_path, "X:/foo/bar///", "X:/foo"); TEST_PATH(utf8::find_base_path, "X:/foo/bar/baz/qux", "X:/foo/bar/baz"); TEST_PATH(utf8::find_base_path, "X:/foo/bar/baz/qux/", "X:/foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "X:/foo/bar/baz/qux//", "X:/foo/bar/baz"); + TEST_PATH(utf8::find_base_path, "X:/foo/bar/baz/qux///", "X:/foo/bar/baz"); TEST_PATH(utf8::find_base_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ", "X:/ほげ/ぴよ/ふが/ほげら"); TEST_PATH(utf8::find_base_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ/", "X:/ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ//", + "X:/ほげ/ぴよ/ふが/ほげら"); + TEST_PATH(utf8::find_base_path, "X:/ほげ/ぴよ/ふが/ほげら/ほげほげ///", + "X:/ほげ/ぴよ/ふが/ほげら"); } // TODO(gibbed): find_base_guest_path @@ -482,6 +560,8 @@ TEST_CASE("UTF-8 Find Base Path", "[utf8]") { TEST_CASE("UTF-8 Canonicalize Path", "[utf8]") { TEST_PATH(utf8::canonicalize_path, "foo/bar/baz/qux", "foo/bar/baz/qux"); TEST_PATH(utf8::canonicalize_path, "foo/bar/baz/qux/", "foo/bar/baz/qux"); + TEST_PATH(utf8::canonicalize_path, "foo/bar/baz/qux//", "foo/bar/baz/qux"); + TEST_PATH(utf8::canonicalize_path, "foo/bar/baz/qux///", "foo/bar/baz/qux"); TEST_PATH(utf8::canonicalize_path, "foo/./baz/qux", "foo/baz/qux"); TEST_PATH(utf8::canonicalize_path, "foo/./baz/qux/", "foo/baz/qux"); TEST_PATH(utf8::canonicalize_path, "foo/../baz/qux", "baz/qux");