@@ -98,3 +98,56 @@ test "RFC example 1" {
9898 const vm = qm .get ("name" ).? ;
9999 try testing .expectEqualStrings ("ferret" , vm .items [0 ]);
100100}
101+
102+ test "edge case - empty path" {
103+ const text = "" ;
104+ var url = URL .init (.{ .allocator = std .testing .allocator });
105+ defer url .deinit ();
106+ const result = try url .parseUrl (text );
107+ try testing .expectEqualStrings ("" , result .path );
108+ }
109+
110+ test "edge case - path only" {
111+ const text = "/path" ;
112+ var url = URL .init (.{ .allocator = std .testing .allocator });
113+ defer url .deinit ();
114+ const result = try url .parseUrl (text );
115+ try testing .expectEqualStrings ("/path" , result .path );
116+ }
117+
118+ test "edge case - path at end of string" {
119+ const text = "/very/long/path/that/ends/without/query/or/fragment" ;
120+ var url = URL .init (.{ .allocator = std .testing .allocator });
121+ defer url .deinit ();
122+ const result = try url .parseUrl (text );
123+ try testing .expectEqualStrings ("/very/long/path/that/ends/without/query/or/fragment" , result .path );
124+ }
125+
126+ test "edge case - single character" {
127+ const text = "a" ;
128+ var url = URL .init (.{ .allocator = std .testing .allocator });
129+ defer url .deinit ();
130+ const result = try url .parseUrl (text );
131+ try testing .expectEqualStrings ("a" , result .path );
132+ }
133+
134+ test "boundary condition - path at string end" {
135+ // This test specifically targets the boundary condition that was causing segfault
136+ const text = "/api/users" ;
137+ var url = URL .init (.{ .allocator = std .testing .allocator });
138+ defer url .deinit ();
139+ const result = try url .parseUrl (text );
140+ try testing .expectEqualStrings ("/api/users" , result .path );
141+ // Note: query and fragment are undefined by default, not null
142+ // We just need to ensure the path is parsed correctly
143+ }
144+
145+ test "boundary condition - path with query at end" {
146+ const text = "/api/users?name=john" ;
147+ var url = URL .init (.{ .allocator = std .testing .allocator });
148+ defer url .deinit ();
149+ const result = try url .parseUrl (text );
150+ try testing .expectEqualStrings ("/api/users" , result .path );
151+ try testing .expectEqualStrings ("name=john" , result .query .? );
152+ // Note: fragment is undefined by default, not null
153+ }
0 commit comments