object-introspection/test/test_container_info.cpp
Jake Hillion b5b94ed236 container_info: switch to boost::regex (#465)
Summary:

OI was previously using `std::regex_match` to match container names. This was bad because `libstdc++`'s implementation of regex is awful. In the case of limited inlining it was causing a stack overflow when running CodeGen for large types (I think types with large names but I never got to the bottom of it).

Replace this with the competent `boost::regex_match` that we already have a dependency on.

Reviewed By: ajor

Differential Revision: D53002752
2024-01-23 10:58:58 -08:00

22 lines
862 B
C++

#include <gtest/gtest.h>
#include "oi/ContainerInfo.h"
TEST(ContainerInfoTest, matcher) {
ContainerInfo info{"std::vector", SEQ_TYPE, "vector"};
EXPECT_TRUE(info.matches("std::vector<int>"));
EXPECT_TRUE(info.matches("std::vector<std::list<int>>"));
EXPECT_TRUE(info.matches("std::vector"));
EXPECT_FALSE(info.matches("vector"));
EXPECT_FALSE(info.matches("non_std::vector<int>"));
EXPECT_FALSE(info.matches("std::vector_other<int>"));
EXPECT_FALSE(info.matches("std::list<std::vector<int>>"));
EXPECT_FALSE(info.matches("std::vector::value_type"));
EXPECT_FALSE(info.matches("std::vector<int>::value_type"));
EXPECT_FALSE(info.matches("std::vector<std::vector<int>>::value_type"));
// Uh-oh, here's a case that I don't think regexes are powerful enough to
// match: EXPECT_FALSE(info.matches("std::vector<int>::subtype<bool>"));
}