original_docstring: Writes the service unit test for a command.
docstring: Writes the service unit test for a command.
docstring_tokens: Writes the service unit test for a command .
code: def WriteServiceUnitTest(self, func, file, *extras):
      """Writes the service unit test for a command."""
      expected_call = "EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));"
      if func.GetInfo("first_element_only"):
        gl_arg_strings = [
          arg.GetValidGLArg(func) for arg in func.GetOriginalArgs()
        ]
        gl_arg_strings[-1] = "*" + gl_arg_strings[-1]
        expected_call = ("EXPECT_CALL(*gl_, %%(gl_func_name)s(%s));" %
            ", ".join(gl_arg_strings))
      valid_test = """
  TEST_P(%(test_name)s, %(name)sValidArgs) {
    SpecializedSetup<cmds::%(name)s, 0>(true);
    cmds::%(name)s cmd;
    cmd.Init(%(args)s);
    GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
    %(expected_call)s
    EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
    EXPECT_EQ(GL_NO_ERROR, GetGLError());
  }
  """
      extra = {
        'data_type': self.GetArrayType(func),
        'data_value': func.GetInfo('data_value') or '0',
        'expected_call': expected_call,
      }
      self.WriteValidUnitTest(func, file, valid_test, extra, *extras)
  
      invalid_test = """
  TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
    EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
    SpecializedSetup<cmds::%(name)s, 0>(false);
    cmds::%(name)s cmd;
    cmd.Init(%(args)s);
    GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
    EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
  }
  """
      self.WriteInvalidUnitTest(func, file, invalid_test, extra, *extras)
code_tokens: def WriteServiceUnitTest ( self , func , file , * extras ) : expected_call = "EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));" if func . GetInfo ( "first_element_only" ) : gl_arg_strings = [ arg . GetValidGLArg ( func ) for arg in func . GetOriginalArgs ( ) ] gl_arg_strings [ - 1 ] = "*" + gl_arg_strings [ - 1 ] expected_call = ( "EXPECT_CALL(*gl_, %%(gl_func_name)s(%s));" % ", " . join ( gl_arg_strings ) ) valid_test = """
  TEST_P(%(test_name)s, %(name)sValidArgs) {
    SpecializedSetup<cmds::%(name)s, 0>(true);
    cmds::%(name)s cmd;
    cmd.Init(%(args)s);
    GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
    %(expected_call)s
    EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
    EXPECT_EQ(GL_NO_ERROR, GetGLError());
  }
  """ extra = { 'data_type' : self . GetArrayType ( func ) , 'data_value' : func . GetInfo ( 'data_value' ) or '0' , 'expected_call' : expected_call , } self . WriteValidUnitTest ( func , file , valid_test , extra , * extras ) invalid_test = """
  TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
    EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
    SpecializedSetup<cmds::%(name)s, 0>(false);
    cmds::%(name)s cmd;
    cmd.Init(%(args)s);
    GetSharedMemoryAs<%(data_type)s*>()[0] = %(data_value)s;
    EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
  }
  """ self . WriteInvalidUnitTest ( func , file , invalid_test , extra , * extras )
short_docstring: Writes the service unit test for a command.
short_docstring_tokens: Writes the service unit test for a command .
comment: """Writes the service unit test for a command."""