diff options
author | Takuto Ikuta <tikuta@chromium.org> | 2017-09-04 07:18:32 (GMT) |
---|---|---|
committer | Takuto Ikuta <tikuta@chromium.org> | 2017-09-05 01:35:03 (GMT) |
commit | 480f89984598f46445380ee26599887d2a7c0455 (patch) | |
tree | 16828b43c3627a3d51cf75c99f9071f9b77e947a /src/includes_normalize_test.cc | |
parent | b98941a605d3cc47966d8407ace6e454d781af9b (diff) | |
download | Ninja-480f89984598f46445380ee26599887d2a7c0455.zip Ninja-480f89984598f46445380ee26599887d2a7c0455.tar.gz Ninja-480f89984598f46445380ee26599887d2a7c0455.tar.bz2 |
fix normalizer test for _MAX_PATH
Diffstat (limited to 'src/includes_normalize_test.cc')
-rw-r--r-- | src/includes_normalize_test.cc | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/includes_normalize_test.cc b/src/includes_normalize_test.cc index 0bb14ec..eac36fd 100644 --- a/src/includes_normalize_test.cc +++ b/src/includes_normalize_test.cc @@ -108,36 +108,33 @@ TEST(IncludesNormalize, LongInvalidPath) { normalizer.Normalize(kLongInputString, &result, &err)); EXPECT_EQ("path too long", err); - const char kExactlyMaxPath[] = - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "012345678\\" - "0123456789"; + + // Construct max size path having cwd prefix. + // kExactlyMaxPath = "$cwd\\a\\aaaa...aaaa\0"; + char kExactlyMaxPath[_MAX_PATH + 1]; + ASSERT_NE(_getcwd(kExactlyMaxPath, sizeof kExactlyMaxPath), NULL); + + int cwd_len = strlen(kExactlyMaxPath); + ASSERT_LE(cwd_len + 3 + 1, _MAX_PATH) + kExactlyMaxPath[cwd_len] = '\\'; + kExactlyMaxPath[cwd_len + 1] = 'a'; + kExactlyMaxPath[cwd_len + 2] = '\\'; + + kExactlyMaxPath[cwd_len + 3] = 'a'; + + for (int i = cwd_len + 4; i < _MAX_PATH; ++i) { + if (i > cwd_len + 4 && i < _MAX_PATH - 1 && i % 10 == 0) + kExactlyMaxPath[i] = '\\'; + else + kExactlyMaxPath[i] = 'a'; + } + + kExactlyMaxPath[_MAX_PATH] = '\0'; + EXPECT_EQ(strlen(kExactlyMaxPath), _MAX_PATH); + string forward_slashes(kExactlyMaxPath); replace(forward_slashes.begin(), forward_slashes.end(), '\\', '/'); // Make sure a path that's exactly _MAX_PATH long is canonicalized. - EXPECT_EQ(forward_slashes, + EXPECT_EQ(forward_slashes.substr(cwd_len + 1), NormalizeAndCheckNoError(kExactlyMaxPath)); } |