def GenTest()

in ext/gtest-1.8.0/googletest/scripts/gen_gtest_pred_impl.py [0:0]


  def GenTest(use_format, use_assert, expect_failure,
              use_functor, use_user_type):
    """Returns the test for a predicate assertion macro.

    Args:
      use_format:     true iff the assertion is a *_PRED_FORMAT*.
      use_assert:     true iff the assertion is a ASSERT_*.
      expect_failure: true iff the assertion is expected to fail.
      use_functor:    true iff the first argument of the assertion is
                      a functor (as opposed to a function)
      use_user_type:  true iff the predicate functor/function takes
                      argument(s) of a user-defined type.

    Example:

      GenTest(1, 0, 0, 1, 0) returns a test that tests the behavior
      of a successful EXPECT_PRED_FORMATn() that takes a functor
      whose arguments have built-in types."""

    if use_assert:
      assrt = 'ASSERT'  # 'assert' is reserved, so we cannot use
                        # that identifier here.
    else:
      assrt = 'EXPECT'

    assertion = assrt + '_PRED'

    if use_format:
      pred_format = 'PredFormat'
      assertion += '_FORMAT'
    else:
      pred_format = 'Pred'

    assertion += '%(n)s' % DEFS

    if use_functor:
      pred_format_type = 'functor'
      pred_format += 'Functor%(n)s()'
    else:
      pred_format_type = 'function'
      pred_format += 'Function%(n)s'
      if not use_format:
        if use_user_type:
          pred_format += 'Bool'
        else:
          pred_format += 'Int'

    test_name = pred_format_type.title()

    if use_user_type:
      arg_type = 'user-defined type (Bool)'
      test_name += 'OnUserType'
      if expect_failure:
        arg = 'Bool(n%s_++)'
      else:
        arg = 'Bool(++n%s_)'
    else:
      arg_type = 'built-in type (int)'
      test_name += 'OnBuiltInType'
      if expect_failure:
        arg = 'n%s_++'
      else:
        arg = '++n%s_'

    if expect_failure:
      successful_or_failed = 'failed'
      expected_or_not = 'expected.'
      test_name +=  'Failure'
    else:
      successful_or_failed = 'successful'
      expected_or_not = 'UNEXPECTED!'
      test_name +=  'Success'

    # A map that defines the values used in the test template.
    defs = DEFS.copy()
    defs.update({
      'assert' : assrt,
      'assertion' : assertion,
      'test_name' : test_name,
      'pf_type' : pred_format_type,
      'pf' : pred_format,
      'arg_type' : arg_type,
      'arg' : arg,
      'successful' : successful_or_failed,
      'expected' : expected_or_not,
      })

    test = """