blob: 0dd8f1230d391abe25a5641f74e697a9d75047a5 [file] [log] [blame]
Steve Antonad7bffc2018-01-22 10:21:56 -08001/*
2 * Copyright 2018 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "rtc_base/gunit.h"
12
13#include <string>
14
15#include "rtc_base/stringutils.h"
16
17::testing::AssertionResult AssertStartsWith(const char* str_expr,
18 const char* prefix_expr,
19 const std::string& str,
20 const std::string& prefix) {
21 if (rtc::starts_with(str.c_str(), prefix.c_str())) {
22 return ::testing::AssertionSuccess();
23 } else {
24 return ::testing::AssertionFailure()
25 << str_expr << "\nwhich is\n\"" << str << "\"\ndoes not start with\n"
26 << prefix_expr << "\nwhich is\n\"" << prefix << "\"";
27 }
28}
Steve Anton80dd7b52018-02-16 17:08:42 -080029
30::testing::AssertionResult AssertStringContains(const char* str_expr,
31 const char* substr_expr,
32 const std::string& str,
33 const std::string& substr) {
34 if (str.find(substr) != std::string::npos) {
35 return ::testing::AssertionSuccess();
36 } else {
37 return ::testing::AssertionFailure()
38 << str_expr << "\nwhich is\n\"" << str << "\"\ndoes not contain\n"
39 << substr_expr << "\nwhich is\n\"" << substr << "\"";
40 }
41}