TestRules.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2014 The Android Open Source Project
  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. #ifndef H_AAPT_SPLIT_TEST_RULES
  17. #define H_AAPT_SPLIT_TEST_RULES
  18. #include "Rule.h"
  19. #include <gtest/gtest.h>
  20. namespace split {
  21. namespace test {
  22. struct AndRule : public Rule {
  23. AndRule() {
  24. op = Rule::AND_SUBRULES;
  25. }
  26. AndRule& add(const Rule& rhs) {
  27. subrules.add(new Rule(rhs));
  28. return *this;
  29. }
  30. };
  31. struct OrRule : public Rule {
  32. OrRule() {
  33. op = Rule::OR_SUBRULES;
  34. }
  35. OrRule& add(const Rule& rhs) {
  36. subrules.add(new Rule(rhs));
  37. return *this;
  38. }
  39. };
  40. const Rule EqRule(Rule::Key key, long value);
  41. const Rule LtRule(Rule::Key key, long value);
  42. const Rule GtRule(Rule::Key key, long value);
  43. const Rule ContainsAnyRule(Rule::Key key, const char* str1);
  44. const Rule ContainsAnyRule(Rule::Key key, const char* str1, const char* str2);
  45. const Rule AlwaysTrue();
  46. ::testing::AssertionResult RulePredFormat(
  47. const char* actualExpr, const char* expectedExpr,
  48. const android::sp<Rule>& actual, const Rule& expected);
  49. #define EXPECT_RULES_EQ(actual, expected) \
  50. EXPECT_PRED_FORMAT2(::split::test::RulePredFormat, actual, expected)
  51. } // namespace test
  52. } // namespace split
  53. #endif // H_AAPT_SPLIT_TEST_RULES