From f94671c33d0b48a87bdce78dd755a450479323cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 30 Apr 2017 16:29:48 +0200 Subject: [PATCH] KPath.Adopt(): Fixed path length. * Issue was hidden due to inappropriate test values; changed test to uncover it. --- src/system/kernel/fs/KPath.cpp | 1 + src/tests/system/kernel/fs/KPathTest.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/fs/KPath.cpp b/src/system/kernel/fs/KPath.cpp index 0f86345af4..815b0dafbc 100644 --- a/src/system/kernel/fs/KPath.cpp +++ b/src/system/kernel/fs/KPath.cpp @@ -96,6 +96,7 @@ KPath::Adopt(KPath& other) fBuffer = other.fBuffer; fBufferSize = other.fBufferSize; + fPathLength = other.fPathLength; other.fBuffer = NULL; other.fBufferSize = 0; diff --git a/src/tests/system/kernel/fs/KPathTest.cpp b/src/tests/system/kernel/fs/KPathTest.cpp index 117c605c5a..9617c4bcfa 100644 --- a/src/tests/system/kernel/fs/KPathTest.cpp +++ b/src/tests/system/kernel/fs/KPathTest.cpp @@ -179,19 +179,19 @@ KPathTest::TestRemoveLeaf() void KPathTest::TestAdopt() { - KPath one("one", false, 10); + KPath one("first", false, 10); CPPUNIT_ASSERT(one.InitCheck() == B_OK); CPPUNIT_ASSERT(one.BufferSize() == 10); - CPPUNIT_ASSERT(one.Length() == 3); - KPath two("two", false, 20); + CPPUNIT_ASSERT(one.Length() == 5); + KPath two("second", false, 20); CPPUNIT_ASSERT(two.InitCheck() == B_OK); CPPUNIT_ASSERT(two.BufferSize() == 20); one.Adopt(two); CPPUNIT_ASSERT(one.InitCheck() == B_OK); CPPUNIT_ASSERT(one.BufferSize() == 20); - CPPUNIT_ASSERT(one.Length() == 3); - CPPUNIT_ASSERT(strcmp(one.Path(), "two") == 0); + CPPUNIT_ASSERT(one.Length() == 6); + CPPUNIT_ASSERT(strcmp(one.Path(), "second") == 0); CPPUNIT_ASSERT(two.Length() == 0); CPPUNIT_ASSERT(two.BufferSize() == 0); // CPPUNIT_ASSERT(two.InitCheck() == B_NO_INIT);