google test matcher

Posted by shensunbo on August 8, 2024

simple matcher

  1. _: The “don’t care” matcher. Matches any value.
  2. Eq(value): Matches a value that is equal to the specified value.
  3. Ne(value): Matches a value that is not equal to the specified value.
  4. Gt(value): Matches a value that is greater than the specified value.
  5. Lt(value): Matches a value that is less than the specified value.
  6. Ge(value): Matches a value that is greater than or equal to the specified value.
  7. Le(value): Matches a value that is less than or equal to the specified value.
  8. StrEq(string): Matches a string that is equal to the specified string.
  9. StrNe(string): Matches a string that is not equal to the specified string.

Combining Matchers

  1. AllOf(m1, m2, …, mn): argument matches all of the matchers m1 to mn
  2. AnyOf(m1, m2, …, mn): argument matches at least one of the matchers m1 to mn
  3. Not(m): argument doesn’t match matcher m
  4. Conditional(cond, m1, m2): Matches matcher m1 if cond evaluates to true, else matches m2