Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: tools/battor_agent/serial_utils_unittest.cc

Issue 1966413002: [battor agent] Move code for stringifying bytes into a util file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed signed/unsigned char problems Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/battor_agent/serial_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/battor_agent/serial_utils_unittest.cc
diff --git a/tools/battor_agent/serial_utils_unittest.cc b/tools/battor_agent/serial_utils_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..608b52fff2d342cc1289a3a421f620bc347fe4bd
--- /dev/null
+++ b/tools/battor_agent/serial_utils_unittest.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/battor_agent/serial_utils.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace testing;
+
+namespace battor {
+
+TEST(SerialUtilsTest, CharVectorToStringLengthZero) {
+ EXPECT_EQ("", CharVectorToString(std::vector<char>()));
+}
+
+TEST(SerialUtilsTest, CharVectorToStringLengthOne) {
+ EXPECT_EQ("0x41", CharVectorToString(std::vector<char>({'A'})));
+}
+
+TEST(SerialUtilsTest, CharVectorToStringLengthTwo) {
+ EXPECT_EQ("0x41 0x4a",
+ CharVectorToString(std::vector<char>({'A', 'J'})));
+}
+
+TEST(SerialUtilsTest, CharArrayToStringLengthOne) {
+ const char arr[] = {'A'};
+ EXPECT_EQ("0x41", CharArrayToString(arr, sizeof(arr)));
+}
+
+TEST(SerialUtilsTest, CharArrayToStringLengthTwo) {
+ const char arr[] = {'A', 'J'};
+ EXPECT_EQ("0x41 0x4a", CharArrayToString(arr, sizeof(arr)));
+}
+
+} // namespace battor
« no previous file with comments | « tools/battor_agent/serial_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698