是否有针对 STL 容器的单元测试?
Is there unit tests for STL containers?
是否有现成的单元测试来测试 STL 容器是否正常工作,编译器创建者使用的东西?
我正在用 C 语言对 STL 进行简单移植,需要测试数据结构,我认为 STL 单元测试已经存在,但没有找到任何东西
Is there unit tests for STL containers?
STL does not exist anymore. Read the C++11 standard n3337 and see this C++ reference website. Consider also using Boost.
最近都GCC and recent Clang provide testsuites for the standard C++ containers library, whose implementation is practically tied to the compiler (because of compiler optimizations)
I'm making a simple port of the STL in C
然后 - 至少寻找灵感 - 到 Glib (from GTK) and SGLIB. I tend to think that you could use one of them. Given the complexity of the standard C++ library, I believe you won't be able to make from scratch in just a few weeks a simple port of it to C if you care about efficiency. Look also into MILEPOST GCC and read this paper then Artificial Beings: the conscience of a conscious machine ISBN:9781848211018 中寻找一些有趣的见解。
否则,一定要阅读Introduction to algorithms
请注意,您通常可以用 C++ 编写一个可从 C 调用的库(适当且系统地使用 extern "C"
)。一个很好的例子当然是基于 libgccjit (which you could consider using, for some partial evaluation 的方法:您可以生成适合特定问题实例的专用机器代码。
如果您使用 C 编写通用容器库,请考虑使用 Frama-C on it, and with a recent GCC, compile it with all warnings and static analysis options. You might even consider writing your GCC plugin 检查您的库的用户是否正确使用它。
另见欧洲 DECODER 项目。
是否有现成的单元测试来测试 STL 容器是否正常工作,编译器创建者使用的东西?
我正在用 C 语言对 STL 进行简单移植,需要测试数据结构,我认为 STL 单元测试已经存在,但没有找到任何东西
Is there unit tests for STL containers?
STL does not exist anymore. Read the C++11 standard n3337 and see this C++ reference website. Consider also using Boost.
最近都GCC and recent Clang provide testsuites for the standard C++ containers library, whose implementation is practically tied to the compiler (because of compiler optimizations)
I'm making a simple port of the STL in C
然后 - 至少寻找灵感 - 到 Glib (from GTK) and SGLIB. I tend to think that you could use one of them. Given the complexity of the standard C++ library, I believe you won't be able to make from scratch in just a few weeks a simple port of it to C if you care about efficiency. Look also into MILEPOST GCC and read this paper then Artificial Beings: the conscience of a conscious machine ISBN:9781848211018 中寻找一些有趣的见解。
否则,一定要阅读Introduction to algorithms
请注意,您通常可以用 C++ 编写一个可从 C 调用的库(适当且系统地使用 extern "C"
)。一个很好的例子当然是基于 libgccjit (which you could consider using, for some partial evaluation 的方法:您可以生成适合特定问题实例的专用机器代码。
如果您使用 C 编写通用容器库,请考虑使用 Frama-C on it, and with a recent GCC, compile it with all warnings and static analysis options. You might even consider writing your GCC plugin 检查您的库的用户是否正确使用它。
另见欧洲 DECODER 项目。