MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / TEST

Function TEST

test/UnitTests/TGitPathTest.cpp:28–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "AutoTempDir.h"
27
28TEST(CTGitPath, GetDirectoryTest)
29{
30 // Bit tricky, this test, because we need to know something about the file
31 // layout on the machine which is running the test
32 TCHAR winDir[MAX_PATH + 1] = { 0 };
33 ASSERT_NE(0u, GetWindowsDirectory(winDir, _countof(winDir)));
34 CString sWinDir(winDir);
35
36 CTGitPath testPath;
37 // This is a file which we know will always be there
38 testPath.SetFromUnknown(sWinDir + L"\\win.ini");
39 EXPECT_TRUE(testPath.Exists());
40 EXPECT_FALSE(testPath.IsDirectory());
41 EXPECT_STREQ(sWinDir,testPath.GetDirectory().GetWinPathString());
42 EXPECT_STREQ(sWinDir,testPath.GetDirectoryOrParentIfDeleted().GetWinPathString());
43 EXPECT_STREQ(sWinDir, testPath.GetContainingDirectory().GetWinPathString());
44
45 // This is a file MS is unlikely to add
46 testPath.SetFromUnknown(sWinDir + L"\\windows_sucks.ini");
47 EXPECT_FALSE(testPath.Exists());
48 EXPECT_FALSE(testPath.IsDirectory());
49 EXPECT_STREQ(testPath.GetWinPathString(),testPath.GetDirectory().GetWinPathString());
50 EXPECT_STREQ(sWinDir,testPath.GetDirectoryOrParentIfDeleted().GetWinPathString());
51 EXPECT_STREQ(sWinDir, testPath.GetContainingDirectory().GetWinPathString());
52
53 // Now do the test on the win directory itself - It's hard to be sure about the containing directory
54 // but we know it must be different to the directory itself
55 testPath.SetFromUnknown(sWinDir);
56 EXPECT_TRUE(testPath.IsDirectory());
57 EXPECT_STREQ(sWinDir, testPath.GetDirectory().GetWinPathString());
58 EXPECT_STRNE(sWinDir, testPath.GetContainingDirectory().GetWinPathString());
59 EXPECT_GT(sWinDir.GetLength(), testPath.GetContainingDirectory().GetWinPathString().GetLength());
60
61 // Try a root path
62 testPath.SetFromUnknown(L"C:\\");
63 EXPECT_TRUE(testPath.IsDirectory());
64 EXPECT_TRUE(testPath.GetDirectory().GetWinPathString().CompareNoCase(L"C:\\") == 0);
65 EXPECT_TRUE(testPath.GetContainingDirectory().IsEmpty());
66 // Try a root UNC path
67 testPath.SetFromUnknown(L"\\MYSTATION");
68 EXPECT_TRUE(testPath.GetContainingDirectory().IsEmpty());
69
70 // test the UI path methods
71 testPath.SetFromUnknown(L"c:\\testing%20test");
72 EXPECT_TRUE(testPath.GetUIFileOrDirectoryName().CompareNoCase(L"testing%20test") == 0);
73
74 //testPath.SetFromUnknown(L"http://server.com/testing%20special%20chars%20%c3%a4%c3%b6%c3%bc");
75 //EXPECT_TRUE(testPath.GetUIFileOrDirectoryName().CompareNoCase(L"testing special chars \344\366\374") == 0);
76}
77
78TEST(CTGitPath, AdminDirTest)
79{

Callers

nothing calls this directly

Calls 15

CStringClass · 0.85
setFlagOnFileInIndexFunction · 0.85
SetFromUnknownMethod · 0.80
GetDirectoryMethod · 0.80
IsAdminDirMethod · 0.80
RemoveAdminPathsMethod · 0.80
SortByPathnameMethod · 0.80
AppendRawStringMethod · 0.80
GetFileExtensionMethod · 0.80

Tested by

no test coverage detected