summaryrefslogtreecommitdiff
path: root/chromeos-dbus-bindings/proxy_generator_unittest.cc
diff options
context:
space:
mode:
authorAlex Deymo <deymo@chromium.org>2015-07-28 13:09:29 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-29 08:45:26 +0000
commitf211ae662aee9b2d4cb8538e9845b5389ba0cc3e (patch)
treed78ac655859eee134d5d5cb9393b05873d7601a5 /chromeos-dbus-bindings/proxy_generator_unittest.cc
parentd0cb3fe72b7070d373bf960550b7cbfb0adbe843 (diff)
downloaddbus-binding-generator-f211ae662aee9b2d4cb8538e9845b5389ba0cc3e.tar.gz
chromeos-dbus-bindings: Print output diff when failing a test.
To help test-driven-development techniques and prevent lazy developers from copy-pasting the output of the test into the expected results without inspecting them, this patch shows the unified diff between the expected result and the generated file. It is still possible to update the unittest code by appliying the patch to the *_unittest.cc file. BUG=None TEST=Modified an expected result and saw the diff on the unittest. Change-Id: If24479fed1fa3be67f2a99c092206bf27cf2b110 Reviewed-on: https://chromium-review.googlesource.com/289300 Reviewed-by: Alex Deymo <deymo@chromium.org> Commit-Queue: Alex Deymo <deymo@chromium.org> Trybot-Ready: Alex Deymo <deymo@chromium.org> Tested-by: Alex Deymo <deymo@chromium.org>
Diffstat (limited to 'chromeos-dbus-bindings/proxy_generator_unittest.cc')
-rw-r--r--chromeos-dbus-bindings/proxy_generator_unittest.cc22
1 files changed, 7 insertions, 15 deletions
diff --git a/chromeos-dbus-bindings/proxy_generator_unittest.cc b/chromeos-dbus-bindings/proxy_generator_unittest.cc
index 165bd61..8840f41 100644
--- a/chromeos-dbus-bindings/proxy_generator_unittest.cc
+++ b/chromeos-dbus-bindings/proxy_generator_unittest.cc
@@ -13,6 +13,7 @@
#include <gtest/gtest.h>
#include "chromeos-dbus-bindings/interface.h"
+#include "chromeos-dbus-bindings/test_utils.h"
using std::string;
using std::vector;
@@ -1306,9 +1307,7 @@ TEST_F(ProxyGeneratorTest, GenerateAdaptors) {
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for
// the content we need within the string.
- EXPECT_NE(string::npos, contents.find(kExpectedContent))
- << "Expected to find the following content...\n"
- << kExpectedContent << "...within content...\n" << contents;
+ test_utils::EXPECT_TEXT_CONTAINED(kExpectedContent, contents);
}
TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithServiceName) {
@@ -1327,9 +1326,7 @@ TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithServiceName) {
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for
// the content we need within the string.
- EXPECT_NE(string::npos, contents.find(kExpectedContentWithService))
- << "Expected to find the following content...\n"
- << kExpectedContentWithService << "...within content...\n" << contents;
+ test_utils::EXPECT_TEXT_CONTAINED(kExpectedContentWithService, contents);
}
TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithObjectManager) {
@@ -1350,10 +1347,8 @@ TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithObjectManager) {
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for
// the content we need within the string.
- EXPECT_NE(string::npos, contents.find(kExpectedContentWithObjectManager))
- << "Expected to find the following content...\n"
- << kExpectedContentWithObjectManager << "...within content...\n"
- << contents;
+ test_utils::EXPECT_TEXT_CONTAINED(
+ kExpectedContentWithObjectManager, contents);
}
TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithObjectManagerAndServiceName) {
@@ -1374,11 +1369,8 @@ TEST_F(ProxyGeneratorTest, GenerateAdaptorsWithObjectManagerAndServiceName) {
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for
// the content we need within the string.
- EXPECT_NE(string::npos,
- contents.find(kExpectedContentWithObjectManagerAndServiceName))
- << "Expected to find the following content...\n"
- << kExpectedContentWithObjectManagerAndServiceName
- << "...within content...\n" << contents;
+ test_utils::EXPECT_TEXT_CONTAINED(
+ kExpectedContentWithObjectManagerAndServiceName, contents);
}
} // namespace chromeos_dbus_bindings