summaryrefslogtreecommitdiff
path: root/libs/androidfw/tests/ObbFile_test.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-08-29 12:29:31 -0700
committerAdam Lesinski <adamlesinski@google.com>2014-08-29 12:29:31 -0700
commitd79e33379d56e20b7dd67baa992409b72a335ded (patch)
tree94ad4f94d041493db6e92768299bd1ece0972dc0 /libs/androidfw/tests/ObbFile_test.cpp
parent5283faba4a75a4d1fd9990637d22768e423895e3 (diff)
Clean up test allocations so real memory leaks are more visible
Change-Id: Ic405f08c8d8e3e7fc4e4a991671e980752c19899
Diffstat (limited to 'libs/androidfw/tests/ObbFile_test.cpp')
-rw-r--r--libs/androidfw/tests/ObbFile_test.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/libs/androidfw/tests/ObbFile_test.cpp b/libs/androidfw/tests/ObbFile_test.cpp
index 7a4dd1373138..115112128636 100644
--- a/libs/androidfw/tests/ObbFile_test.cpp
+++ b/libs/androidfw/tests/ObbFile_test.cpp
@@ -34,20 +34,18 @@ namespace android {
class ObbFileTest : public testing::Test {
protected:
sp<ObbFile> mObbFile;
- char* mExternalStorage;
- char* mFileName;
+ String8 mFileName;
virtual void SetUp() {
mObbFile = new ObbFile();
- mExternalStorage = getenv("EXTERNAL_STORAGE");
+ char* externalStorage = getenv("EXTERNAL_STORAGE");
- const int totalLen = strlen(mExternalStorage) + strlen(TEST_FILENAME) + 1;
- mFileName = new char[totalLen];
- snprintf(mFileName, totalLen, "%s%s", mExternalStorage, TEST_FILENAME);
+ mFileName.append(externalStorage);
+ mFileName.append(TEST_FILENAME);
- int fd = ::open(mFileName, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ int fd = ::open(mFileName.string(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
- FAIL() << "Couldn't create " << mFileName << " for tests";
+ FAIL() << "Couldn't create " << mFileName.string() << " for tests";
}
}
@@ -71,12 +69,12 @@ TEST_F(ObbFileTest, WriteThenRead) {
EXPECT_TRUE(mObbFile->setSalt(salt, SALT_SIZE))
<< "Salt should be successfully set";
- EXPECT_TRUE(mObbFile->writeTo(mFileName))
+ EXPECT_TRUE(mObbFile->writeTo(mFileName.string()))
<< "couldn't write to fake .obb file";
mObbFile = new ObbFile();
- EXPECT_TRUE(mObbFile->readFrom(mFileName))
+ EXPECT_TRUE(mObbFile->readFrom(mFileName.string()))
<< "couldn't read from fake .obb file";
EXPECT_EQ(versionNum, mObbFile->getVersion())