google test 学习笔记2-google test Advanced guide

Kimi K2.5深度集成Cursor:重构AI原生开发工作流 大模型如何真正融入日常编码?关键在于从‘调用API’转向‘IDE内生智能’。Kimi K2.5通过Syntax-Aware Attention、代码AST感知与本地Agent Runtime,实现了对上下文语义的高保真理解与毫秒级响应,显著提升代码定位精度与生成稳定性。其技术价值不仅体现为推理效率优化,更在于将AI能力嵌入开发闭环——支持精准重构、自动文档生成、根因级Bug定位与高覆盖测试生成。典型应用场景包括中大型代码库的快速熟悉、遗留系统现代化改造及高频重复开发任务自动化。本文聚焦Kimi K2.5与C 阅读详情

Now that you have read Primer and learned how to write tests using Google Test, it’s time to learn some new tricks. This document will show you more assertions as well as how to construct complex failure messages, propagate fatal failures, reuse and speed up your test fixtures, and use various flags with your tests.
这篇教程会展示 更多类型的断言、如何去构建一个复杂的失败消息、传播失败的消息、重用fixtures并提速测试过程以及如何使用丰富的gtest flags
Advanced Guide共分为:
1. More Assertions
2. Teaching Google Test How to Print Your Values
3. Death Tests
4. Using Assertions in Sub-routines
5. Logging Additional Information
6. Sharing Resources Between Tests in the Same Test Case
7. Global Set-Up and Tear-Down
8. Value Parameterized Tests
9. Typed Tests
10. Type-Parameterized Tests
11. Testing Private Code
12. Catching Failures
13. Getting the Current Test’s Name
14. Extending Google Test by Handling Test Events
15. Running Test Programs: Advanced Options

有的部分部分比较长,有的部分比较短。
这是Advanced Guide的第一部分:更多的断言

content

More Assertions

更多的断言

This section covers some less frequently used, but still significant,
assertions.
这一部分包含了一些不常用的,但是依然很重要的ASSERTIONS

Explicit Success and Failure

明确的成功or失败

These three assertions do not actually test a value or expression. Instead,
they generate a success or failure directly. Like the macros that actually
perform a test, you may stream a custom failure message into the them.
下面这三个宏,并不是用来 检测一个值或是表达式,它们只是产生一个SUCCESS或者FAILURE的消息而已。你可以用它来流输出一个自定义的消息。

SUCCEED();

Generates a success. This does NOT make the overall test succeed. A test is considered successful only if none of its assertions fail during its execution.
SUCCEED()宏生成一个success消息,但是,它并不能表明这一条测试是成功的,只有当一个测试的所有断言都是成功的,这个测试才是成功的。

Note: SUCCEED() is purely documentary and currently doesn’t generate any user-visible output. However, we may add SUCCEED() messages to Google Test’s output in the future.
目前,SUCCEED()并不能产生一个用户可见的输出,我们(the author)可能会在未来为它增加一些功能

FAIL();ADD_FAILURE();ADD_FAILURE_AT("file_path",line_number);

FAIL() generates a fatal failure, while ADD_FAILURE() and ADD_FAILURE_AT() generate a nonfatal failure. These are useful when control flow, rather than a Boolean expression, deteremines the test’s success or failure. For example, you might want to write something like:
FAIL()产生一个fatal failure,而ADD_FAILURE()和ADD_FAILURE_AT()产生一个nonfatal failure。 在一些控制流程中,它们会比一些布尔表达式更有用,比如有一些分支是不能走的,见下例:

switch(expression) {
  case 1: ... some checks ...
  case 2: ... some other checks
  ...
  default: FAIL() << "We shouldn't get here.";
}

Availability: Linux, Windows, Mac.

Exception Assertions

异常断言

These are for verifying that a piece of code throws (or does not throw) an exception of the given type:
这些宏用来验证一些代码是否的,抛出了指定的异常

Fatal assertionNonfatal assertionVerifies
ASSERT_THROW(statement, exception_type);EXPECT_THROW(statement, exception_type);statement throws an exception of the given type
ASSERT_ANY_THROW(statement);EXPECT_ANY_THROW(statement);statement throws an exception of any type
ASSERT_NO_THROW(statement);EXPECT_NO_THROW(statement);statement doesn’t throw any exception

Examples:

ASSERT_THROW(Foo(5), bar_exception);


EXPECT_NO_THROW({
  int n = 5;
  Bar(&n);
});

Availability: Linux, Windows, Mac; since version 1.1.0.

Predicate Assertions for Better Error Messages

预测断言(为了更好的错误信息)

Even though Google Test has a rich set of assertions, they can never be complete, as it’s impossible (nor a good idea) to anticipate all the scenarios a user might run into. Therefore, sometimes a user has to use EXPECT_TRUE() to check a complex expression, for lack of a better macro. This has the problem of not showing you the values of the parts of the expression, making it hard to understand what went wrong. As a workaround, some users choose to construct the failure message by themselves, streaming it into EXPECT_TRUE(). However, this is awkward especially when the expression has side-effects or is expensive to evaluate.
尽管gtest提供了丰富多样的断言,但它不可能覆盖所有的用户可能需要的使用情况,有时候,用户不得不用EXPECT_TURE去检查一个比较复杂的表达式,因为没有合适的宏可以用,在这种情况下,一旦出错的话,并不能把相关的参数信息打印出来,作为一个workaround,一些用户就自已构造了一些错误信息输出。这样处理显得很尴尬很笨拙,尤其是这个复杂的表达式有side-effect或这个表达式拆分估值比较麻烦的时候

Google Test gives you three different options to solve this problem:
针对这种问题, gtest 提供了三种不同的选择来解决

Using an Existing Boolean Function

使用一个已经存在的布尔型的函数

If you already have a function or a functor that returns bool (or a type that can be implicitly converted to bool), you can use it in a predicate assertion to get the function arguments printed for free:
如果你已经有一个返回布尔的函数(没有可以临时写一个),那么你可以使用下面的函数:

Fatal assertionNonfatal assertionVerifies
ASSERT_PRED1(pred1, val1);EXPECT_PRED1(pred1, val1);pred1(val1) returns true
ASSERT_PRED2(pred2, val1, val2);EXPECT_PRED2(pred2, val1, val2);pred2(val1, val2) returns true
………

In the above, predn is an n-ary predicate function or functor, where val1, val2, …, and valn are its arguments. The assertion succeeds if the predicate returns true when applied to the given arguments, and fails otherwise. When the assertion fails, it prints the value of each argument. In either case, the arguments are evaluated exactly once.
predn 的 n,可以是0,1,2,3,4,5(所说目前只支持5个), 表示了后面有几个值,如果这个宏失败了的话,就会打印出所有的表达式的结果(val),这引起参数表达式只会被计算一次。

Here’s an example. Given

// Returns true iff m and n have no common divisors except 1.
bool MutuallyPrime(int m, int n) { ... }
const int a = 3;
const int b = 4;
const int c = 10;

the assertion EXPECT_PRED2(MutuallyPrime, a, b); will succeed, while the
assertion EXPECT_PRED2(MutuallyPrime, b, c); will fail with the message
EXPECT_PRED2(MutuallyPrime, b, c);失败后,会打印如下结果,可以看出,它会自动打印传入的参数:b,c的值。

!MutuallyPrime(b, c) is false, where
b is 4
c is 10

Notes:

  1. If you see a compiler error “no matching function to call” when using ASSERT_PRED* or EXPECT_PRED*, please see this for how to resolve it.
  2. Currently we only provide predicate assertions of arity <= 5. If you need a higher-arity assertion, let us know.

确实最大只到5
Availability: Linux, Windows, Mac

Using a Function That Returns an AssertionResult

使用返回值为 AssertionResult 类型的函数

While EXPECT_PRED*() and friends are handy for a quick job, the syntax is not satisfactory: you have to use different macros for different arities, and it feels more like Lisp than C++. The ::testing::AssertionResult class solves this problem.
虽然EXPECT_PRED*()和它的小伙伴们能快速处理多个参数的问题,但是这个语法看起来不是很优美,因为不同的参数个数,你得调用不同的宏,如果多于5个目前还没有办法处理,这样看起来更像是Lisp,而不是C++。 而类 ::testing::AssertionResult 可以解决这个问题

An AssertionResult object represents the result of an assertion (whether it’s a success or a failure, and an associated message). You can create an AssertionResult using one of these factory functions:
一个AssertionResult对象代表了一个断言结果(不管是SUCCESS或者是FAILURE,都有一个消息)。你可以使用这些工厂方法来创建一个AssertionResult对象。

namespace testing {


// Returns an AssertionResult object to indicate that an assertion has
// succeeded.
AssertionResult AssertionSuccess();


// Returns an AssertionResult object to indicate that an assertion has
// failed.
AssertionResult AssertionFailure();


}

You can then use the << operator to stream messages to the AssertionResult object.
通过AssertionResult对象,可以使用流操作符<<来输出一些需要的信息。

To provide more readable messages in Boolean assertions (e.g. EXPECT_TRUE()), write a predicate function that returns AssertionResult instead of bool. For example, if you define IsEven() as:
在布尔断言中,为了提供更好的更丰富的错误诊断信息,可以构造一个预测函数,返回AssertionResult 代替返回bool:见下例

::testing::AssertionResult IsEven(int n) {
  if ((n % 2) == 0)
    return ::testing::AssertionSuccess();
  else
    return ::testing::AssertionFailure() << n << " is odd";
}

instead of:

bool IsEven(int n) {
  return (n % 2) == 0;
}

the failed assertion EXPECT_TRUE(IsEven(Fib(4))) will print:

Value of: IsEven(Fib(4))
Actual: false (*3 is odd*)
Expected: true

instead of a more opaque

Value of: IsEven(Fib(4))
Actual: false
Expected: true

If you want informative messages in EXPECT_FALSE and ASSERT_FALSE
as well, and are fine with making the predicate slower in the success
case, you can supply a success message:
如果你想要更丰富的信息,同样的,你也可以在SUCCESS 的情况下输出一些自己想要的信息,见下例:

::testing::AssertionResult IsEven(int n) {
  if ((n % 2) == 0)
    return ::testing::AssertionSuccess() << n << " is even";
  else
    return ::testing::AssertionFailure() << n << " is odd";
}

Then the statement EXPECT_FALSE(IsEven(Fib(6))) will print

Value of: IsEven(Fib(6))
Actual: true (8 is even)
Expected: false

Availability: Linux, Windows, Mac; since version 1.4.1.

Using a Predicate-Formatter

使用格式化宏

If you find the default message generated by (ASSERT|EXPECT)_PRED* and (ASSERT|EXPECT)_(TRUE|FALSE) unsatisfactory, or some arguments to your predicate do not support streaming to ostream, you can instead use the following predicate-formatter assertions to fully customize how the message is formatted:
下面的这些宏,可以完全的自定义输出消息的格式

Fatal assertionNonfatal assertionVerifies
ASSERT_PRED_FORMAT1(pred_format1, val1);EXPECT_PRED_FORMAT1(pred_format1, val1`);pred_format1(val1) is successful
ASSERT_PRED_FORMAT2(pred_format2, val1, val2);EXPECT_PRED_FORMAT2(pred_format2, val1, val2);pred_format2(val1, val2) is successful
.........

The difference between this and the previous two groups of macros is that instead of a predicate, (ASSERT|EXPECT)_PRED_FORMAT* take a predicate-formatter (pred_formatn), which is a function or functor with the signature:
这些宏和上面介绍的宏(ASSERT_PRED*)最大的不同是多了_FORMAT*部分,这些宏一般与下面的函数一起使用:

::testing::AssertionResult PredicateFormattern(const char*expr1, const char*expr2, ... const char*exprn, T1val1, T2val2, ... Tnvaln);

where val1, val2, …, and valn are the values of the predicate arguments, and expr1, expr2, …, and exprn are the corresponding expressions as they appear in the source code. The types T1, T2, …, and Tn can be either value types or reference types. For example, if an argument has type Foo, you can declare it as either Foo or const Foo&, whichever is appropriate.
val1, val2, …, valn是运行被测试函数需要的参数,这些参数的类型可以是值类型,也可以是引用类型。 expr1, expr2,…, exprn 是对应于 val* 的字符串。

如果 val1 是引用类型,那么 expr1 应该是什么呢?它一直是字符串,能表示这个对象的哪一部分呢?还是对象的名字?

A predicate-formatter returns a ::testing::AssertionResult object to indicate whether the assertion has succeeded or not. The only way to create such an object is to call one of these factory functions:
一个 predicate-formatter返回一个::testing::AssertionResult的对象,用来标识SUCCESS或者FAILURE。创建 predicate-formatter的唯一办法是使用这个工厂函数。

As an example, let’s improve the failure message in the previous example, which uses EXPECT_PRED2():

// Returns the smallest prime common divisor of m and n,
// or 1 when m and n are mutually prime.
int SmallestPrimeCommonDivisor(int m, int n) { ... }


// A predicate-formatter for asserting that two integers are mutually prime.
::testing::AssertionResult AssertMutuallyPrime(const char* m_expr,
                                               const char* n_expr,
                                               int m,
                                               int n) {
  if (MutuallyPrime(m, n))
    return ::testing::AssertionSuccess();


  return ::testing::AssertionFailure()
      << m_expr << " and " << n_expr << " (" << m << " and " << n
      << ") are not mutually prime, " << "as they have a common divisor "
      << SmallestPrimeCommonDivisor(m, n);
}

With this predicate-formatter, we can use

EXPECT_PRED_FORMAT2(AssertMutuallyPrime, b, c);

to generate the message

b and c (4 and 10) are not mutually prime, as they have a common divisor 2.

As you may have realized, many of the assertions we introduced earlier are special cases of (EXPECT|ASSERT)_PRED_FORMAT*. In fact, most of them are indeed defined using (EXPECT|ASSERT)_PRED_FORMAT*.
其实前面介绍的一些简单的断言都是(EXPECT|ASSERT)_PRED_FORMAT*的特例,它们大多数的内部实现都是用的(EXPECT|ASSERT)_PRED_FORMAT*


在使用(EXPECT|ASSERT)_PRED_FORMAT*时,需要一个predicate-formatter函数来配合使用,配合方式如下:

//predicate-formatter
::testing::AssertionResult XXXXXXXXXXX(const char* expr_1,
                                               const char* expr_2,
                                               ... ,
                                               const char* expr_n,
                                               T1 val_1,
                                               T2 val_2,
                                               ... ,
                                               Tn val_n)
{
    //code here
}

//the macro
EXPECT_PRED_FORMATn(XXXXXXXXXXX, val_1,val_2,..., val_n);

需要注意的是,代码中XXXXXXXXXXX部分要完全相同,即要有相同的函数名

Availability: Linux, Windows, Mac.

Floating-Point Comparison

浮点数的比较

Comparing floating-point numbers is tricky. Due to round-off errors, it is very unlikely that two floating-points will match exactly. Therefore, ASSERT_EQ ‘s naive comparison usually doesn’t work. And since floating-points can have a wide value range, no single fixed error bound works. It’s better to compare by a fixed relative error bound, except for values close to 0 due to the loss of precision there.
浮点数存在截断误差,两个浮点数之间一般不能精确的相等,所以之间的比较宏都不能用于浮点数的比较,而且浮点数表示的范围很大,远比同样占据4个字节的int表示的范围大,那么它的分辨率一定是很低。所以最好使用相对误差来进行比较,除了跟0相比。

In general, for floating-point comparison to make sense, the user needs to carefully choose the error bound. If they don’t want or care to, comparing in terms of Units in the Last Place (ULPs) is a good default, and Google Test provides assertions to do this. Full details about ULPs are quite long; if you want to learn more, see this article on float comparison.
一般来说,对于浮点数的比较,用户需要自已指定误差范围,如果不想指定或是对这个不关心的话, 使用ULPs是一个非常好的选择,gtest也提供了相应的断言。

需要注意的是,由于浮点表示的范围非常大,以常用的float和int为例,他们都占据4个字节,但是float的范围很大,float是使用的二进制的科学计数法,对应到十进制来说,只有6到7位的有效数字,如果一个float比较大时,用非科学计数法表示时,其小数位乃至个位、十位,都有可能是不精确的,所以在比较时,可以考虑两数相减再与0.0f比较,情况会好一点。

Floating-Point Macros

浮点数比较的宏

Fatal assertionNonfatal assertionVerifies
ASSERT_FLOAT_EQ(expected, actual);EXPECT_FLOAT_EQ(expected, actual);the two float values are almost equal
ASSERT_DOUBLE_EQ(expected, actual);EXPECT_DOUBLE_EQ(expected, actual);the two double values are almost equal

By “almost equal”, we mean the two values are within 4 ULP’s from each other.
对于浮点数比较下的默认相等,这两个宏指的是小于 有个 ULP’s

The following assertions allow you to choose the acceptable error bound:
下面的宏允许用户自己指定一个精度来进行比较

Fatal assertionNonfatal assertionVerifies
ASSERT_NEAR(val1, val2, abs_error);EXPECT_NEAR(val1, val2, abs_error);the difference between val1 and val2 doesn’t exceed the given absolute error

Availability: Linux, Windows, Mac.

Floating-Point Predicate-Format Functions

浮点数的预测格式比较

Some floating-point operations are useful, but not that often used. In order to avoid an explosion of new macros, we provide them as predicate-format functions that can be used in predicate assertion macros (e.g. EXPECT_PRED_FORMAT2, etc).
虽然一些浮点数的操作很有用,但是却不怎么常用,为了避免定义大量的浮点数相关的宏,这里定义了 predicate-format宏来

EXPECT_PRED_FORMAT2(::testing::FloatLE, val1, val2);
EXPECT_PRED_FORMAT2(::testing::DoubleLE, val1, val2);

Verifies that val1 is less than, or almost equal to, val2. You can replace EXPECT_PRED_FORMAT2 in the above table with ASSERT_PRED_FORMAT2.

Availability: Linux, Windows, Mac.

Windows HRESULT assertions

These assertions test for HRESULT success or failure.

Fatal assertionNonfatal assertionVerifies
ASSERT_HRESULT_SUCCEEDED(expression);EXPECT_HRESULT_SUCCEEDED(expression);expression is a success HRESULT
ASSERT_HRESULT_FAILED(expression);EXPECT_HRESULT_FAILED(expression);expression is a failure HRESULT

The generated output contains the human-readable error message associated with the HRESULT code returned by expression.
这些宏会输出一些人类可读的错误消息

You might use them like this:

CComPtr shell;
ASSERT_HRESULT_SUCCEEDED(shell.CoCreateInstance(L"Shell.Application"));
CComVariant empty;
ASSERT_HRESULT_SUCCEEDED(shell->ShellExecute(CComBSTR(url), empty, empty, empty, empty));

Availability: Windows.

Type Assertions

类型断言

You can call the function

::testing::StaticAssertTypeEq<T1, T2>();

to assert that types T1 and T2 are the same. The function does nothing if the assertion is satisfied. If the types are different, the function call will fail to compile, and the compiler error message will likely (depending on the compiler) show you the actual values of T1 and T2. This is mainly useful inside template code.
::testing::StaticAssertTypeEq<T1, T2>()这货用来比较T1和T2两个类型是否相同,比如是否同为int。如果相同,这个函数什么也不做,如果不相同,这个函数会产生一个编译错误,错误消息会显示T1和T2的真实类型(具体消息的格式及如何显示取决于编译器)。在使用模板的代码中,这个函数会比较有用。

Caveat: When used inside a member function of a class template or a function template, StaticAssertTypeEq<T1, T2>() is effective only if the function is instantiated. For example, given:

template <typename T> class Foo {
public:
  void Bar() { ::testing::StaticAssertTypeEq<int, T>(); }
};

the code:

void Test1() { Foo<bool> foo; }

will not generate a compiler error, as Foo<bool>::Bar() is never
actually instantiated. Instead, you need:

void Test2() { Foo<bool> foo; foo.Bar(); }

to cause a compiler error.

注意: 想要用这个函数来检测模板函数中类型是否匹配或相同,必须保证使用这个函数的代码会被执行到,否则这个函数是不会起作用的。详见上例。

Availability: Linux, Windows, Mac; since version 1.3.0.

Assertion Placement

断言位置

You can use assertions in any C++ function. In particular, it doesn’t have to be a method of the test fixture class. The one constraint is that assertions that generate a fatal failure (FAIL* and ASSERT_*) can only be used in void-returning functions. This is a consequence of Google Test not using exceptions. By placing it in a non-void function you’ll get a confusing compile error like "error: void value not ignored as it ought to be".
可以在代码的任何位置处使用断言,除了产生fatal error 的ASSERT_*等,他们只能在返回值为void的函数内使用。这是因为gtest没有使用异常,如果把它们放在了返回值不为void的函数体内,可能会产生一个编译错类似于:"error: void value not ignored as it ought to be"

If you need to use assertions in a function that returns non-void, one option is to make the function return the value in an out parameter instead. For example, you can rewrite T2 Foo(T1 x) to void Foo(T1 x, T2* result). You need to make sure that *result contains some sensible value even when the function returns prematurely. As the function now returns void, you can use any assertion inside of it.
如果非要返回值不为void的函数内使用这些fatal error的ASSERTION,可以考虑将其返回值封闭成输出参数 rightarrow 使用引用或指针

If changing the function’s type is not an option, you should just use assertions that generate non-fatal failures, such as ADD_FAILURE* and EXPECT_*.
如果不考虑上面将返回值封闭成参数的情况,那么就只能用non-fatal ASSERTIONS了

Note: Constructors and destructors are not considered void-returning functions, according to the C++ language specification, and so you may not use fatal assertions in them. You’ll get a compilation error if you try. A simple workaround is to transfer the entire body of the constructor or destructor to a private void-returning method. However, you should be aware that a fatal assertion failure in a constructor does not terminate the current test, as your intuition might suggest; it merely returns from the constructor early, possibly leaving your object in a partially-constructed state. Likewise, a fatal assertion failure in a destructor may leave your object in a partially-destructed state. Use assertions carefully in these situations!
注意,构造函数和析构函数并不是返回值为void的函数。所以它们也不能用fatal error的assertion,不过可以考虑将他们的函数体拎出来 ,放到一个返回值为void的函数内,这样就可以使用fatal error的assertion了。不过需要注意的是,如果在这些fatal assertion断言失败的话,只会提前退出构造/析构函数,并不会终止程序运算,这样可以会使你的对象处于一个部分构造/析构的状态,所以,在构造/析构函数中使用fatal assertion要非常小心。

Claude Code v2.3.1本地运行Opus 4.8全指南 本地大模型推理正从概念走向工程落地,其核心在于模型格式支持(如GGUF)、轻量级推理引擎(如llama.cpp)与IDE深度集成三者的协同。Opus 4.8作为高性能闭源代码模型,通过量化封装、热加载机制和沙盒化部署,首次实现在消费级设备上免API、免云端、低延迟调用,兼顾隐私性、离线可用性与企业合规要求。该方案特别适用于内网开发、嵌入式编程及开源项目维护等强安全场景,标志着AI编码工具从‘云服务前端’向‘本地智能协作者’的关键演进。 阅读详情

相关推荐

Gemini 3.1 Pro:从问答AI到可验证推理协作者的技术跃迁

大语言模型正从‘回答问题’迈向‘构建可验证推理过程’的新阶段。其核心在于抽象推理能力的实质性突破——不再依赖统计模式匹配,而是建立内部状态机与因果逻辑链,支撑零样本规则推演与跨模态语义锚定。这种能力使AI具备工程级可靠性,能主动预判边界、提供补救路径,并在文本、图像、表格、音频间建立带置信度的证据链。典型应用场景包括科研建模中的假设验证、企业风控中的决策血缘追溯、开发者工作流中的推理链可视化调试,以及日常问题的分步拆解与交叉验证。Gemini 3.1 Pro正是这一范式演进的关键代表,尤其在ARC-AGI-

weixin_34290096的博客 442

Google C++单元测试框架GoogleTest---AdvancedGuide(译文)下

因为AdvancedGuide文档太长,分上下两部分,本文档接googletest--AdvancedGuide(译文)上:Google C++单元测试框架GoogleTest---AdvancedGuide(译文)上。 一、在子程序中使用断言(Using Assertions in Sub-routines) 1.1 将跟踪添加到断言 如果从几个地方调用测试子程序,当其中的断言失败时,可能...

weixin_33800593的博客 390

Claude代码能力解析:从AST感知到MCP协议的工程化实现

代码生成器本质上是将编程范式、工程规范与验证逻辑内化为模型运行时能力的技术系统。其核心原理在于突破传统大语言模型的文本生成范式,转向对抽象语法树(AST)、项目上下文(如pyproject.toml、Git历史)和领域规范(如PEP8、OWASP)的结构化理解与动态调度。这种能力带来显著技术价值:提升代码一致性、降低人工审查成本、增强修改可追溯性。典型应用场景包括PR自动化审查、跨服务API规范对齐、遗留系统安全重构等。Claude3.5正是通过AST感知、Sub-Agents协同与MCP协议集成,实现了A

weixin_30561425的博客 399

Gtest:断言

一、前言 这篇文章主要参考玩转Google开源C++单元测试框架Google Test系列(gtest)之二 - 断言,结合自己平时使用的Linux环境适当删减修改。 Assertion引发的三种结果 Assertions会引发3种结果:success、Non-Fatal Failure、Fatal Failure Non-Fatal Failure 和Fatal Failure啥区...

weixin_34290390的博客 456

google test框架使用中文文档

搜集到的非常不错的google test框架、gmock使用的中文文档。

MavLink协议入门

MAVLink是一个非常轻量化的开源的消息协议,用于无人机之间的通信以及无人机机载设备之间的通信。

ffffffeiyu的博客 2472

google test 学习笔记3-google test Advanced guide

Teaching Google Test How to Print Your Values自定义打印的消息When a test assertion such as EXPECT_EQ fails, Google Test prints the argument values to help you debug. It does this using a user-extensible value

beichen2012的专栏 560

工业级隔离CAN FD收发器ISO1042设计实战:从原理到EMC防护

在工业自动化与伺服驱动系统中,CAN总线是实现设备间可靠通信的关键技术。其核心原理是通过差分信号传输和仲裁机制,在复杂电磁环境中实现多节点实时数据交换。这项技术的核心价值在于为高噪声、高干扰的工业现场提供了稳定、确定性的通信基础,是构建分布式控制系统不可或缺的环节。其典型应用场景包括新能源汽车电池管理、工业机器人伺服控制以及光伏逆变器集群通信等。本文将聚焦于如何通过高性能隔离CAN FD收发器(如TI的ISO1042)来应对地电位差、浪涌和高压串扰等现场挑战,深入解析其集成的电气隔离、±70V总线故障保护和

weixin_26834815的博客 382

Google C++单元测试框架GoogleTest---AdvancedGuide(译文)上

本文是gtest高级测试指南的译文,由于文章太长,分上下两部分。 一、简介    本文档将向您展示更多的断言,以及如何构造复杂的失败消息,传播致命的故障,重用和加速您的测试夹具,并在您的测试使用各种标志。 二、更多断言   本节包括一些不太常用,但仍然重要的断言。   2.1 显式成功和失败   这三个断言实际上不测试值或表达式。 相反,它们直接产生成功或失败。 与实际执行测试的宏类似...

weixin_34342905的博客 261

李大勇matlab密码,基于MatlabSimulink的太阳能热水系统仿真研究 沈超.doc

基于MatlabSimulink的太阳能热水系统仿真研究 沈超中国工程热物理学会 工程热力学与能源利用 编号:141090基于Matlab/Simulink的太阳能热水系统仿真研究沈 超1 1 余 鹏1 李洪欣1 魏新利2郑州大学土木工程学院,郑州 450001郑州大学化工与能源学院,郑州 45...

weixin_42298437的博客 1340

刚入职,软件测试岗,有点迷茫不知道下一步怎么提升自己

软件测试前景和发展都是不错,已经入了软件测试这行业就坚挺下去

大白的博客 2216

googletest 学习笔记

前言googletest 是由 Google 开发的开源 C++ 单元测试框架,在很多开源项目中(如 chromium)都有使用。这篇博客记录在了自己在学习 googletest 的文档《Primer》和《AdvancedGuide》时做的一些笔记,主要是自己对 googletest 的一些特性的理解和总结。

HDM1991的专栏 4021

为什么你的Mac蓝牙总断连?深入解析硬件干扰与系统设置避坑

本文深入解析Mac蓝牙频繁断连的原因,包括硬件干扰(如WiFi同频干扰、USB设备电磁干扰)和系统设置问题,并提供详细的优化方案和诊断工具(如blueutil)使用指南,帮助用户有效解决蓝牙稳定性问题。

ik67890123的博客 679

Claude Code 2.0认证配置与AI编程助手实战指南

AI编程助手作为现代软件开发的重要工具,基于大语言模型技术实现智能代码生成与分析。其核心原理是通过深度学习理解编程语言语义和项目上下文,为开发者提供实时代码补全、错误检测和重构建议。在技术价值层面,AI编程工具能显著提升开发效率,降低人为错误,特别适用于快速原型开发和技术债务清理等场景。以Claude Code为例,这款由Anthropic开发的AI编程助手支持多语言项目和深度上下文理解,通过简化的OAuth 2.0认证机制确保安全访问。在实际应用中,开发者需要掌握环境配置、认证流程和代码生成等核心功能,本

weixin_34268843的博客 421

大模型实战—通义千问大模型微调

这个参数仅针对 llama 类型的模型结构,默认勾选的是 q_proj 和 v_proj,具体的名词不容易理解,我就不多说了,可以简单的认为是对模型的理解能力进行优化,一般这两个就够了。当这个值较高时,适应新任务的能力会增强,但是对基础模型的影响会比较大,有过拟合的风险,尤其是在数据量有限的情况下。为了方便测试,我在云环境也创建了一个镜像,相关的环境都配置好了,可以直接使用几个国内开源的大语言模型,比如清华智谱的ChatGLM3-6B、零一万物的Yi-34B,还有最近阿里云开源的Qwen1.5-32B。

7万+

PyMuPDF为PDF文件添加注释

我将介绍如何使用PyMuPDF库来为PDF文件添加注释,包括文本注释、高亮注释、下划线注释等15种注释的使用方法。

布啦啦 2242

【springboot】万字操作指南 Spring Boot 2.x 升级到 3.x:微服务项目实战

摘要: 本文提供Spring Boot 2.x升级到3.x的实战指南,重点针对微服务项目。升级涉及JDK 17、Spring Framework 6、Jakarta EE等连锁变化,需系统规划版本矩阵(如Spring Boot 3.5.x + Spring Cloud 2025.0.x)。建议升级路线:先统一JDK 17环境,再处理依赖迁移(javax→jakarta)、Spring Security 6适配、OAuth2授权服务器改造等关键步骤。

Cjh20pan的博客 968

git clone出现fatal: unable to access Failed to connect to github.com port 443: Timed out解决方案

本文主要介绍了git clone出现fatal: unable to access Failed to connect to github.com port 443: Timed out解决方案,希望能对使用git的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 23万+

FastAPI框架核心优势与Python Web开发实践

现代Web开发中,高性能API框架是构建微服务的关键技术。FastAPI作为基于Python类型提示的异步框架,通过集成Starlette和Pydantic实现了卓越性能与开发效率的平衡。其核心原理包括类型安全验证、自动文档生成和原生异步支持,特别适合I/O密集型场景。在技术价值方面,FastAPI能提升200%-300%的开发速度,同时保持与NodeJS/Go相当的性能表现。典型应用场景包括微服务架构、数据科学API和实时系统开发。通过Pydantic模型的数据验证和Swagger UI的自动文档,开发者

weixin_34279246的博客 325

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

技术SEO实战:利用信息差与文化元素获取谷歌免费流量

最近在技术圈发现一个有趣的现象:一些海外开发者利用信息差,通过中国传统文化元素在谷歌上获得了大量免费流量。这让我想到,作为技术人,我们是否也经常忽略身边的技术红利?本文就从一个真实案例出发,拆解如何通过技术手段实现流量获取,并分享完整的技术实现方案。 1. 项目背景与核心概念 1.1 现象背后的技术逻辑 这个案例的核心是利用谷歌搜索算法对特定文化内容的偏好。海外用户对中国麻将这类传统文化元素有强烈的好奇心,但相关优质内容相对稀缺。这就形成了一个信息差机会:谁能提供高质量的麻将相关技术内容,谁就能获得搜索引擎

areen7003的博客 975

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

OpenToonz 完整指南:如何用免费开源软件从零基础做出第一支 2D 动画

想做一支 30 秒的动画短片,却发现试过的商业软件要么收费,要么要订阅?其实还有一条专业级的路:OpenToonz,这款免费开源 2D 动画软件,从线稿、合成到导出都能覆盖,全套工具向新手开放,下一步就是做出你的第一帧动画。 ## 它是怎么来的 OpenToonz 由日本 DWANGO 公司发起开源。它的内核源自 Toonz,即吉卜力工作室在长篇动画制作中长期使用的动画制作软件,DWANGO

gitblog_00112的博客 1090

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

LittleBigMouse v6 的 lbm-agent 设计解析:单一决策线程、无 I/O 调和器与跨平台常驻进程

`lbm-agent` 是 LittleBigMouse v6 中全新的常驻进程(resident process):它负责监视系统显示变化、加载用户配置文件(profile)、驱动底层 hook(鼠标拦截引擎),并为未来的前端(UI、托盘)提供统一的本地 API。本文以设计笔记 [docs/v6-agent.md](https://link.gitcode.com/i/1e259bb1b2829

gitblog_00188的博客 941

程序员必读书单

本文系统整理了程序员进阶所需的经典书籍,涵盖编程实践、架构设计、方法论和领导力四大领域。编程实践部分从《代码整洁之道》到《计算机程序设计艺术》,由浅入深;架构设计推荐《设计模式》《领域驱动设计》等经典;方法论包含敏捷开发、持续交付等实用指南;领导力部分精选《高效能人士的七个习惯》《原则》等管理经典。书单特别注重理论与实践结合,既包含《算法导论》等技术专著,也推荐《人月神话》等软技能读物,为程序员提供从编码到架构、从技术到管理的全方位成长路线图。

人无远虑,必有近忧 998

OpenCode 安装指南:5 分钟一键装好开源 AI 编程助手(全平台部署教程)

OpenCode 是一个开源的终端 AI 编程助手:它跑在你的命令行里,帮你解释代码、改代码、跑任务,并且模型可以自由选择,还能被远程驱动。如果你受够了把代码贴进网页对话框来回复制粘贴,这套指南能帮你在 5 分钟内把 OpenCode 装好并跑通第一个任务。 ## 一条命令,先让 OpenCode 跑起来 这节的目标只有一个:别纠结,先用最快的方式装好、看到版本输出,剩下的细节后面再看。 如

gitblog_00257的博客 428

【Linux公有云网站配置实战|企业网络管理课程溯源、完整实训、例题解析与故障排错】

文末整理配套学习网站、网课、专业书籍。早期网络依靠人工经验维护,没有标准化流程、统一配置规范,网络故障频繁,于是各大高校开设企业网络管理相关课程,目的是培养能够维护企业内网、服务器、对外业务网站的专业运维人员。本次实训基于公有云服务器,以Linux操作系统为基础,完整完成云服务器初始化、远程连接、Web服务安装、网站源码部署、防火墙与云安全组放行,最终实现公网用户通过IP访问企业网站。Linux系统凭借稳定、开源、免费的优势成为企业服务器首选,课程新增Linux命令、用户管理、服务部署、防火墙配置内容。

2501_92125808的博客 336
上一篇: google test 学习笔记1-google test primer.md
下一篇: google test 学习笔记3-google test Advanced guide
beichen
博客等级 码龄16年 4粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值