summaryrefslogtreecommitdiff
path: root/adb/adb_utils_test.cpp
diff options
context:
space:
mode:
authorAlex Vallée <avallee@chromium.org>2015-05-06 16:26:00 -0400
committerElliott Hughes <enh@google.com>2015-07-30 15:08:53 -0700
commit47d67c96ec991ef1690b4c07188335cbc4bfa2aa (patch)
tree172e26db49ad9f4d57b47fc17f31622e47b56558 /adb/adb_utils_test.cpp
parenteb0b151369371993a70c2079b8253f6dd24814b7 (diff)
Write mkdirs in more idiomatic C++ style.
~ Rewrote mkdirs to be in C++ style. ~ Replaced adb_dir{start,stop} with std::string params and (r)find. + Added test for mkdirs. Also make base/test_utils.h public and support temporary directories as well as files. Change-Id: I6fcbdc5e0099f3359d3aac6b00c436f250ca1329
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r--adb/adb_utils_test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp
index 7aa610ab50..20dba2771a 100644
--- a/adb/adb_utils_test.cpp
+++ b/adb/adb_utils_test.cpp
@@ -18,6 +18,13 @@
#include <gtest/gtest.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sysdeps.h"
+
+#include <base/test_utils.h>
+
TEST(adb_utils, directory_exists) {
ASSERT_TRUE(directory_exists("/proc"));
ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link.
@@ -132,3 +139,11 @@ TEST(adb_utils, parse_host_and_port) {
EXPECT_FALSE(parse_host_and_port("1.2.3.4:0", &canonical_address, &host, &port, &error));
EXPECT_FALSE(parse_host_and_port("1.2.3.4:65536", &canonical_address, &host, &port, &error));
}
+
+TEST(adb_utils, mkdirs) {
+ TemporaryDir td;
+ EXPECT_TRUE(mkdirs(std::string(td.path) + "/dir/subdir/file"));
+ std::string file = std::string(td.path) + "/file";
+ adb_creat(file.c_str(), 0600);
+ EXPECT_FALSE(mkdirs(file + "/subdir/"));
+}