| ... | ... | @@ -1362,7 +1362,7 @@ test { |
| 1362 | 1362 | |
| 1363 | 1363 | const a = try mf.addFirstChildNode(gpa, .root, .{ .fixed = true, .alignment = .@"4" }); |
| 1364 | 1364 | const c = try mf.addLastChildNode(gpa, .root, .{ .fixed = true, .alignment = .@"4" }); |
| 1365 | | const b = try mf.addNodeAfter(gpa, a, .{ .fixed = true, .alignment = .@"4" }); |
| 1365 | const b = try mf.addNodeAfter(gpa, a, .{ .fixed = true, .alignment = .@"16" }); |
| 1366 | 1366 | const d = try mf.addNodeAfter(gpa, b, .{ .alignment = .@"4" }); |
| 1367 | 1367 | |
| 1368 | 1368 | const a_init_size = 8; |
| ... | ... | @@ -1426,26 +1426,14 @@ test { |
| 1426 | 1426 | try testVerifyContent(&mf, d, 0xdd, d_init_size); |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | | // Re-align nodes |
| 1430 | | { |
| 1431 | | try b.realign(&mf, gpa, .@"8", true); |
| 1432 | | try a.realign(&mf, gpa, .@"16", true); |
| 1433 | | mf.verify(); |
| 1434 | | |
| 1435 | | try testVerifyContent(&mf, a, 0xaa, a_init_size); |
| 1436 | | try testVerifyContent(&mf, b, 0xbb, b_init_size); |
| 1437 | | try testVerifyContent(&mf, c, 0xcc, c_init_size); |
| 1438 | | try testVerifyContent(&mf, d, 0xdd, d_init_size); |
| 1439 | | } |
| 1440 | | |
| 1441 | 1429 | const child_init: []const struct { std.mem.Alignment, usize } = &.{ |
| 1442 | | .{ .@"8", 16 }, |
| 1430 | .{ .@"16", 16 }, |
| 1443 | 1431 | .{ .@"1", 1 }, |
| 1444 | 1432 | .{ .@"1", 19 }, |
| 1445 | 1433 | .{ .@"1", 3 }, |
| 1446 | | .{ .@"4", 30 }, |
| 1434 | .{ .@"8", 30 }, |
| 1447 | 1435 | .{ .@"2", 5 }, |
| 1448 | | .{ .@"16", 60 }, |
| 1436 | .{ .@"1", 60 }, |
| 1449 | 1437 | .{ .@"2", 2 }, |
| 1450 | 1438 | .{ .@"16", 32 }, |
| 1451 | 1439 | }; |
| ... | ... | @@ -1463,7 +1451,7 @@ test { |
| 1463 | 1451 | |
| 1464 | 1452 | @memset(ni.slice(&mf)[0..opts.@"1"], @intCast(i + 1)); |
| 1465 | 1453 | } |
| 1466 | | // Shift differenntly-aligned nodes |
| 1454 | // Shift differently-aligned nodes by inserting a node |
| 1467 | 1455 | children[children.len - 1] = try mf.addNodeAfter(gpa, children[3], .{ |
| 1468 | 1456 | .alignment = child_init[children.len - 1].@"0", |
| 1469 | 1457 | .size = child_init[children.len - 1].@"1", |
| ... | ... | @@ -1490,6 +1478,29 @@ test { |
| 1490 | 1478 | } |
| 1491 | 1479 | } |
| 1492 | 1480 | |
| 1481 | // Re-align last node into trailing free space within parent |
| 1482 | { |
| 1483 | try b.resize(&mf, gpa, b.location(&mf).resolve(&mf)[1] + 64); |
| 1484 | |
| 1485 | const last = children[children.len - 2]; |
| 1486 | try last.realign(&mf, gpa, .@"4", true); |
| 1487 | mf.verify(); |
| 1488 | |
| 1489 | for (children, child_init, 0..) |ni, opts, i| |
| 1490 | try testVerifyContent(&mf, ni, @intCast(i + 1), opts.@"1"); |
| 1491 | try testVerifyContent(&mf, c, 0xcc, c_init_size); |
| 1492 | } |
| 1493 | |
| 1494 | // Re-align, shifting sibling nodes |
| 1495 | { |
| 1496 | try children[1].realign(&mf, gpa, .@"8", true); |
| 1497 | mf.verify(); |
| 1498 | |
| 1499 | for (children, child_init, 0..) |ni, opts, i| |
| 1500 | try testVerifyContent(&mf, ni, @intCast(i + 1), opts.@"1"); |
| 1501 | try testVerifyContent(&mf, c, 0xcc, c_init_size); |
| 1502 | } |
| 1503 | |
| 1493 | 1504 | // Shrink and shift start of trailing node into free space |
| 1494 | 1505 | { |
| 1495 | 1506 | try mf.shrinkNode(gpa, a, 16, true); |