[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / test / TestUtil.cpp
blob827c3104f242de2832b91be9102fafa1985c639a
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "Util.h"
11 #include <gtest/gtest.h>
13 TEST(TestUtil, GetQualifiedFilename)
15 std::string file = "../foo";
16 CUtil::GetQualifiedFilename("smb://", file);
17 EXPECT_EQ(file, "foo");
18 file = "C:\\foo\\bar";
19 CUtil::GetQualifiedFilename("smb://", file);
20 EXPECT_EQ(file, "C:\\foo\\bar");
21 file = "../foo/./bar";
22 CUtil::GetQualifiedFilename("smb://my/path", file);
23 EXPECT_EQ(file, "smb://my/foo/bar");
24 file = "smb://foo/bar/";
25 CUtil::GetQualifiedFilename("upnp://", file);
26 EXPECT_EQ(file, "smb://foo/bar/");
29 TEST(TestUtil, MakeLegalPath)
31 std::string path;
32 #ifdef TARGET_WINDOWS
33 path = "C:\\foo\\bar";
34 EXPECT_EQ(CUtil::MakeLegalPath(path), "C:\\foo\\bar");
35 path = "C:\\foo:\\bar\\";
36 EXPECT_EQ(CUtil::MakeLegalPath(path), "C:\\foo_\\bar\\");
37 #else
38 path = "/foo/bar/";
39 EXPECT_EQ(CUtil::MakeLegalPath(path),"/foo/bar/");
40 path = "/foo?/bar";
41 EXPECT_EQ(CUtil::MakeLegalPath(path),"/foo_/bar");
42 #endif
43 path = "smb://foo/bar";
44 EXPECT_EQ(CUtil::MakeLegalPath(path), "smb://foo/bar");
45 path = "smb://foo/bar?/";
46 EXPECT_EQ(CUtil::MakeLegalPath(path), "smb://foo/bar_/");
49 TEST(TestUtil, MakeShortenPath)
51 std::string result;
52 EXPECT_EQ(true, CUtil::MakeShortenPath("smb://test/string/is/long/and/very/much/so", result, 10));
53 EXPECT_EQ("smb:/../so", result);
55 EXPECT_EQ(true, CUtil::MakeShortenPath("smb://test/string/is/long/and/very/much/so", result, 30));
56 EXPECT_EQ("smb://../../../../../../../so", result);
58 EXPECT_EQ(true, CUtil::MakeShortenPath("smb://test//string/is/long/and/very//much/so", result, 30));
59 EXPECT_EQ("smb:/../../../../../so", result);
61 EXPECT_EQ(true, CUtil::MakeShortenPath("//test//string/is/long/and/very//much/so", result, 30));
62 EXPECT_EQ("/../../../../../so", result);
65 TEST(TestUtil, ValidatePath)
67 std::string path;
68 #ifdef TARGET_WINDOWS
69 path = "C:/foo/bar/";
70 EXPECT_EQ(CUtil::ValidatePath(path), "C:\\foo\\bar\\");
71 path = "C:\\\\foo\\\\bar\\";
72 EXPECT_EQ(CUtil::ValidatePath(path, true), "C:\\foo\\bar\\");
73 path = "\\\\foo\\\\bar\\";
74 EXPECT_EQ(CUtil::ValidatePath(path, true), "\\\\foo\\bar\\");
75 #else
76 path = "\\foo\\bar\\";
77 EXPECT_EQ(CUtil::ValidatePath(path), "/foo/bar/");
78 path = "/foo//bar/";
79 EXPECT_EQ(CUtil::ValidatePath(path, true), "/foo/bar/");
80 #endif
81 path = "smb://foo/bar/";
82 EXPECT_EQ(CUtil::ValidatePath(path), "smb://foo/bar/");
83 path = "smb://foo//bar/";
84 EXPECT_EQ(CUtil::ValidatePath(path, true), "smb://foo/bar/");
85 path = "smb:\\\\foo\\\\bar\\";
86 EXPECT_EQ(CUtil::ValidatePath(path, true), "smb://foo/bar/");