我想了解的目的google-mock,谷歌的C++嘲讽框架.
我gtest早些时候已经合作过,但我仍然无法理解它是什么gmock.我们为什么需要它?
gtest用于单元测试.我们需要什么样gmock的话,如果gmock需要unit testing?
例如,
class Person{
string name;
public:
T& operator*(){
return name;
}
bool operator==(const Person &rhs){
return this->name == rhs.name;
}
bool operator!=(const Person &rhs){
return !(*this == rhs); // Will *this be the string name or the Person?
}
}
Run Code Online (Sandbox Code Playgroud)
如果*this最终提领this的string,而不是一个Person,是有维持的使用一种解决方法*作为类外引用操作?
如果我*不放弃而不放弃使用,那将是一个很大的障碍*this.
我有一个需要编码字符串的函数,它需要能够接受0x00作为有效的'字节'.我的程序需要检查字符串的长度,但是如果我传递"\x00"给std::string该length()方法返回0.
即使字符串是单个空字符,如何获得实际长度?
这个问题基于我发现监控可能内存泄漏的代码,因此它包含一些您可能不希望在常规程序中看到的代码,例如排序指针。
但是,我看到设置了一个指针nullptr,然后将该指针与最大地址进行比较。是否由 C++ 标准保证nullptr总是小于其他指针operator<?
有两个const类型会发出警告/错误.但是,如果已定义类型typedef,则编译器接受它(Visual Studio 2013和在线编译器C++ shell).
#include <iostream>
typedef const int value_type;
int main()
{
const value_type n = 0; //ok
const const int n2 = 0; //error C4114
return 0;
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道为什么?它是一个const (const int),不同于const const int?
@param命令的可选方向参数在此处记录为以下之一:
@param[in]
@param[out]
@param[in,out]
Run Code Online (Sandbox Code Playgroud)
我没有在任何示例网站中看到此信息如何出现在输出中.是否有一个例子说明这些信息应该如何出现在输出中?
我知道以下内容不正确:
int arr[2][3] = {}; //some array initialization here
int** ptr;
ptr = arr;
Run Code Online (Sandbox Code Playgroud)
但我很惊讶以下几行确实有效
int arr[2][3] = {}; //some array initialization here
auto ptr = arr;
int another_arr[2][3] = {}; //some array initialization here
ptr = another_arr;
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释在第二个代码块中分配给ptr的类型是什么,以及下面发生了什么?
如何改变视觉工作室代码终端线显示,就像在putty?
我无法看到终端中的所有线路,是否有办法改变内置终端的总线路数.
unsigned int当我溢出它时会包含什么?具体来说,我想用两个unsigned ints 进行乘法:unsigned int乘法结束后会有什么?
unsigned int someint = 253473829*13482018273;
Run Code Online (Sandbox Code Playgroud) 我正在编写和读取内存映射中的寄存器,如下所示:
//READ
return *((volatile uint32_t *) ( map + offset ));
//WRITE
*((volatile uint32_t *) ( map + offset )) = value;
Run Code Online (Sandbox Code Playgroud)
但是编译器给了我这样的警告:
warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
Run Code Online (Sandbox Code Playgroud)
如何更改我的代码以删除警告?我正在使用C++和Linux.
c++ ×9
pointers ×3
c++11 ×2
arrays ×1
const ×1
dereference ×1
doxygen ×1
googlemock ×1
googletest ×1
nullptr ×1
output ×1
stdstring ×1
terminal ×1
this ×1
typedef ×1