~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/pagespeed/kernel/base/gtest.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Google Inc.
3
 
 *
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 *
8
 
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 
 *
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
 
17
 
// Author: jmarantz@google.com (Joshua Marantz)
18
 
//
19
 
 
20
 
#ifndef PAGESPEED_KERNEL_BASE_GTEST_H_
21
 
#define PAGESPEED_KERNEL_BASE_GTEST_H_
22
 
 
23
 
#include "pagespeed/kernel/base/string.h"
24
 
#include "pagespeed/kernel/base/string_util.h"
25
 
#include "testing/gtest/include/gtest/gtest.h"
26
 
 
27
 
namespace net_instaweb {
28
 
 
29
 
GoogleString GTestSrcDir();
30
 
GoogleString GTestTempDir();
31
 
 
32
 
}  // namespace net_instaweb
33
 
 
34
 
namespace testing {
35
 
namespace internal {
36
 
 
37
 
// Allows EXPECT_STREQ to be used on StringPiece.
38
 
inline GTEST_API_ AssertionResult CmpHelperSTREQ(
39
 
    const char* expected_expression,
40
 
    const char* actual_expression,
41
 
    const StringPiece& expected,
42
 
    const StringPiece& actual) {
43
 
  return CmpHelperSTREQ(expected_expression, actual_expression,
44
 
                        expected.as_string().c_str(),
45
 
                        actual.as_string().c_str());
46
 
}
47
 
 
48
 
// Allows EXPECT_STRNE to be used on StringPiece.
49
 
inline GTEST_API_ AssertionResult CmpHelperSTRNE(
50
 
    const char* expected_expression,
51
 
    const char* actual_expression,
52
 
    const StringPiece& expected,
53
 
    const StringPiece& actual) {
54
 
  return CmpHelperSTRNE(expected_expression, actual_expression,
55
 
                        expected.as_string().c_str(),
56
 
                        actual.as_string().c_str());
57
 
}
58
 
 
59
 
// EXPECT_SUBSTR and EXPECT_SUBSTR_NE allows a simple way to search for a
60
 
// substring. Works on StringPiece, char* and GoogleString.
61
 
#define EXPECT_HAS_SUBSTR(needle, haystack) \
62
 
  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSUBSTR, needle, haystack)
63
 
 
64
 
#define EXPECT_HAS_SUBSTR_NE(needle, haystack) \
65
 
  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSUBSTRNE, needle, haystack)
66
 
 
67
 
template <typename StringType>
68
 
inline GTEST_API_ AssertionResult CmpHelperSUBSTR(
69
 
    const char* haystack_expression,
70
 
    const char* needle_expression,
71
 
    const StringType haystack,
72
 
    const StringPiece& needle) {
73
 
  return ::testing::IsSubstring(haystack_expression, needle_expression,
74
 
                                haystack, needle.as_string());
75
 
}
76
 
 
77
 
template <typename StringType1, typename StringType2>
78
 
inline GTEST_API_ AssertionResult CmpHelperSUBSTR(
79
 
    const char* haystack_expression,
80
 
    const char* needle_expression,
81
 
    const StringType1 haystack,
82
 
    const StringType2 needle) {
83
 
  return ::testing::IsSubstring(haystack_expression, needle_expression,
84
 
                                haystack, needle);
85
 
}
86
 
 
87
 
template <typename StringType>
88
 
inline GTEST_API_ AssertionResult CmpHelperSUBSTRNE(
89
 
    const char* haystack_expression,
90
 
    const char* needle_expression,
91
 
    const StringType haystack,
92
 
    const StringPiece& needle) {
93
 
  return ::testing::IsNotSubstring(haystack_expression, needle_expression,
94
 
                                   haystack, needle.as_string());
95
 
}
96
 
 
97
 
template <typename StringType1, typename StringType2>
98
 
inline GTEST_API_ AssertionResult CmpHelperSUBSTRNE(
99
 
    const char* haystack_expression,
100
 
    const char* needle_expression,
101
 
    const StringType1 haystack,
102
 
    const StringType2 needle) {
103
 
  return ::testing::IsNotSubstring(haystack_expression, needle_expression,
104
 
                                   haystack, needle);
105
 
}
106
 
 
107
 
}  // namespace internal
108
 
}  // namespace testing
109
 
 
110
 
#endif  // PAGESPEED_KERNEL_BASE_GTEST_H_