| 1197 | |
| 1198 | #[test] |
| 1199 | fn test_realistic_cpp_header() { |
| 1200 | let mut parser = CppParser::new(); |
| 1201 | let source = r#" |
| 1202 | #include <string> |
| 1203 | #include <vector> |
| 1204 | #include <memory> |
| 1205 | |
| 1206 | #define MAX_CONNECTIONS 100 |
| 1207 | #define API_VERSION "2.0" |
| 1208 | |
| 1209 | namespace net { |
| 1210 | |
| 1211 | enum class Protocol { |
| 1212 | TCP, |
| 1213 | UDP, |
| 1214 | HTTP |
| 1215 | }; |
| 1216 | |
| 1217 | using Callback = std::function<void(int)>; |
| 1218 | |
| 1219 | class Connection { |
| 1220 | public: |
| 1221 | Connection(const std::string& host, int port); |
| 1222 | ~Connection(); |
| 1223 | |
| 1224 | void connect(); |
| 1225 | void disconnect(); |
| 1226 | bool is_connected() const; |
| 1227 | |
| 1228 | private: |
| 1229 | std::string host_; |
| 1230 | int port_; |
| 1231 | }; |
| 1232 | |
| 1233 | class Server { |
| 1234 | public: |
| 1235 | void listen(int port) { |
| 1236 | port_ = port; |
| 1237 | } |
| 1238 | |
| 1239 | void stop() { |
| 1240 | running_ = false; |
| 1241 | } |
| 1242 | |
| 1243 | private: |
| 1244 | int port_; |
| 1245 | bool running_; |
| 1246 | std::vector<std::unique_ptr<Connection>> connections_; |
| 1247 | }; |
| 1248 | |
| 1249 | struct Config { |
| 1250 | std::string host; |
| 1251 | int port; |
| 1252 | int max_connections; |
| 1253 | }; |
| 1254 | |
| 1255 | } // namespace net |
| 1256 | "#; |