| 1220 | |
| 1221 | #[test] |
| 1222 | fn test_realistic_cpp_header() { |
| 1223 | let mut parser = CppParser::new(); |
| 1224 | let source = r#" |
| 1225 | #include <string> |
| 1226 | #include <vector> |
| 1227 | #include <memory> |
| 1228 | |
| 1229 | #define MAX_CONNECTIONS 100 |
| 1230 | #define API_VERSION "2.0" |
| 1231 | |
| 1232 | namespace net { |
| 1233 | |
| 1234 | enum class Protocol { |
| 1235 | TCP, |
| 1236 | UDP, |
| 1237 | HTTP |
| 1238 | }; |
| 1239 | |
| 1240 | using Callback = std::function<void(int)>; |
| 1241 | |
| 1242 | class Connection { |
| 1243 | public: |
| 1244 | Connection(const std::string& host, int port); |
| 1245 | ~Connection(); |
| 1246 | |
| 1247 | void connect(); |
| 1248 | void disconnect(); |
| 1249 | bool is_connected() const; |
| 1250 | |
| 1251 | private: |
| 1252 | std::string host_; |
| 1253 | int port_; |
| 1254 | }; |
| 1255 | |
| 1256 | class Server { |
| 1257 | public: |
| 1258 | void listen(int port) { |
| 1259 | port_ = port; |
| 1260 | } |
| 1261 | |
| 1262 | void stop() { |
| 1263 | running_ = false; |
| 1264 | } |
| 1265 | |
| 1266 | private: |
| 1267 | int port_; |
| 1268 | bool running_; |
| 1269 | std::vector<std::unique_ptr<Connection>> connections_; |
| 1270 | }; |
| 1271 | |
| 1272 | struct Config { |
| 1273 | std::string host; |
| 1274 | int port; |
| 1275 | int max_connections; |
| 1276 | }; |
| 1277 | |
| 1278 | } // namespace net |
| 1279 | "#; |