@@ -65,3 +65,32 @@ TEST_F(PathTrieTest, InsertAndSearchMultiParamPath)
65
65
EXPECT_EQ (std::string (param_idxs[3 ].beg , param_idxs[3 ].end ), " 123" );
66
66
EXPECT_EQ (std::string (param_idxs[5 ].beg , param_idxs[5 ].end ), " update" );
67
67
}
68
+
69
+ // Verify copy constructor correctly duplicates the trie
70
+ TEST_F (PathTrieTest, CopyConstructor)
71
+ {
72
+ trie_.Insert (" /api/data/{id}" );
73
+ PathTrie copied (trie_);
74
+ std::string oas_path;
75
+ std::unordered_map<size_t , ParamRange> param_idxs;
76
+ std::string search_path = " /api/data/456" ;
77
+ EXPECT_TRUE (copied.Search (search_path.data (), search_path.data () + search_path.size (), oas_path, param_idxs));
78
+ EXPECT_EQ (oas_path, " /api/data/{id}" );
79
+ ASSERT_TRUE (param_idxs.find (3 ) != param_idxs.end ());
80
+ EXPECT_EQ (std::string (param_idxs[3 ].beg , param_idxs[3 ].end ), " 456" );
81
+ }
82
+
83
+ // Verify copy assignment correctly duplicates the trie
84
+ TEST_F (PathTrieTest, CopyAssignment)
85
+ {
86
+ PathTrie other;
87
+ other.Insert (" /api/info/{name}" );
88
+ trie_ = other;
89
+ std::string oas_path;
90
+ std::unordered_map<size_t , ParamRange> param_idxs;
91
+ std::string search_path = " /api/info/john" ;
92
+ EXPECT_TRUE (trie_.Search (search_path.data (), search_path.data () + search_path.size (), oas_path, param_idxs));
93
+ EXPECT_EQ (oas_path, " /api/info/{name}" );
94
+ ASSERT_TRUE (param_idxs.find (2 ) != param_idxs.end ());
95
+ EXPECT_EQ (std::string (param_idxs[2 ].beg , param_idxs[2 ].end ), " john" );
96
+ }
0 commit comments