@velox0/cerver 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/run.js CHANGED
@@ -190,6 +190,17 @@ test("generateRouteTable emits forward declarations, entries, and count", () =>
190
190
  assert.match(code, /static const int cerver_route_count = 2;/);
191
191
  });
192
192
 
193
+ test("generateDispatch generates correct parameter extraction and termination", () => {
194
+ const { generateDispatch } = require("../lib/codegen/dispatch_gen");
195
+ const routes = [
196
+ IR.IRRoute("GET", "/users/:id/profile", ["id"], IR.IRHandler([], [])),
197
+ ];
198
+ const code = generateDispatch(routes);
199
+ assert.match(code, /req->params\[req->params_count\]\.key = "id";/);
200
+ assert.match(code, /req->params\[req->params_count\]\.value = seg1_start;/);
201
+ assert.match(code, /\(\(char\*\)seg1_start\)\[seg1_len\] = '\\0';/);
202
+ });
203
+
193
204
  test("loadConfig merges defaults and supports export default configs", () => {
194
205
  const dir = tempDir();
195
206
  try {