Functional Weave
Code in Rust

logistics.container-fit@1.0.0

vectors.json

4,753 bytes · view raw

[
  {"name": "600 x 400 x 400 cartons in a 20ft box, space limited", "args": ["20gp", 600, 400, 400, 12000, false, null], "expect": {"container": "20gp", "cartons": 225, "spaceLimit": 225, "weightLimit": 2516, "limitedBy": "space", "alongLength": 9, "acrossWidth": 5, "layers": 5, "placedLengthMm": 600, "placedWidthMm": 400, "placedHeightMm": 400, "cargoGrams": 2700000, "volumeUsedBasisPoints": 6504}},
  {"name": "turned on the floor beats as given: 1116, not 1080", "args": ["40hc", 580, 380, 300, 8000, true, null], "expect": {"container": "40hc", "cartons": 1116, "spaceLimit": 1116, "weightLimit": 3581, "limitedBy": "space", "alongLength": 31, "acrossWidth": 4, "layers": 9, "placedLengthMm": 380, "placedWidthMm": 580, "placedHeightMm": 300, "cargoGrams": 8928000, "volumeUsedBasisPoints": 9657}},
  {"name": "allowed to tip, a tipped orientation gives 1120", "args": ["40hc", 580, 380, 300, 8000, false, null], "expect": {"container": "40hc", "cartons": 1120, "spaceLimit": 1120, "weightLimit": 3581, "limitedBy": "space", "alongLength": 40, "acrossWidth": 4, "layers": 7, "placedLengthMm": 300, "placedWidthMm": 580, "placedHeightMm": 380, "cargoGrams": 8960000, "volumeUsedBasisPoints": 9691}},
  {"name": "heavy cartons: the payload runs out first", "args": ["20gp", 600, 400, 400, 150000, false, null], "expect": {"container": "20gp", "cartons": 201, "spaceLimit": 225, "weightLimit": 201, "limitedBy": "weight", "alongLength": 9, "acrossWidth": 5, "layers": 5, "placedLengthMm": 600, "placedWidthMm": 400, "placedHeightMm": 400, "cargoGrams": 30150000, "volumeUsedBasisPoints": 5810}},
  {"name": "a lower road limit caps it further", "args": ["20gp", 600, 400, 400, 150000, false, 20000], "expect": {"container": "20gp", "cartons": 133, "spaceLimit": 225, "weightLimit": 133, "limitedBy": "weight", "alongLength": 9, "acrossWidth": 5, "layers": 5, "placedLengthMm": 600, "placedWidthMm": 400, "placedHeightMm": 400, "cargoGrams": 19950000, "volumeUsedBasisPoints": 3844}},
  {"name": "taller than the door: only a tipped orientation gets in", "args": ["20gp", 1000, 1000, 2300, 50000, false, null], "expect": {"container": "20gp", "cartons": 10, "spaceLimit": 10, "weightLimit": 604, "limitedBy": "space", "alongLength": 5, "acrossWidth": 1, "layers": 2, "placedLengthMm": 1000, "placedWidthMm": 2300, "placedHeightMm": 1000, "cargoGrams": 500000, "volumeUsedBasisPoints": 6926}},
  {"name": "pallet-sized loads in a trailer: 34 fit, the payload allows 24", "args": ["trailer-13.6", 1200, 800, 1500, 1000000, true, null], "expect": {"container": "trailer-13.6", "cartons": 24, "spaceLimit": 34, "weightLimit": 24, "limitedBy": "weight", "alongLength": 17, "acrossWidth": 2, "layers": 1, "placedLengthMm": 800, "placedWidthMm": 1200, "placedHeightMm": 1500, "cargoGrams": 24000000, "volumeUsedBasisPoints": 3930}},
  {"name": "lighter pallets: space limited at 34 (800 mm along the length, 17 x 800 = 13600)", "args": ["trailer-13.6", 1200, 800, 1500, 500000, true, null], "expect": {"container": "trailer-13.6", "cartons": 34, "spaceLimit": 34, "weightLimit": 48, "limitedBy": "space", "alongLength": 17, "acrossWidth": 2, "layers": 1, "placedLengthMm": 800, "placedWidthMm": 1200, "placedHeightMm": 1500, "cargoGrams": 17000000, "volumeUsedBasisPoints": 5567}},
  {"name": "equal limits count as space", "args": ["20gp", 600, 400, 400, 134222, false, null], "expect": {"container": "20gp", "cartons": 225, "spaceLimit": 225, "weightLimit": 225, "limitedBy": "space", "alongLength": 9, "acrossWidth": 5, "layers": 5, "placedLengthMm": 600, "placedWidthMm": 400, "placedHeightMm": 400, "cargoGrams": 30199950, "volumeUsedBasisPoints": 6504}},
  {"name": "taller than the door and kept upright", "args": ["20gp", 1000, 1000, 2300, 50000, true, null], "expectError": "carton does not fit in 20gp in any allowed orientation"},
  {"name": "a carton the size of the inside cannot pass the door", "args": ["20gp", 5900, 2352, 2393, 1000, false, null], "expectError": "carton does not fit in 20gp in any allowed orientation"},
  {"name": "an unknown container", "args": ["45hc", 600, 400, 400, 12000, false, null], "expectError": "unknown container \"45hc\""},
  {"name": "a road limit above the container's rating", "args": ["20gp", 600, 400, 400, 12000, false, 40000], "expectError": "maxPayloadKg must not exceed 30200 kg for 20gp"},
  {"name": "a zero payload limit", "args": ["20gp", 600, 400, 400, 12000, false, 0], "expectError": "maxPayloadKg must be 1 or more"},
  {"name": "a zero dimension", "args": ["20gp", 600, 0, 400, 12000, false, null], "expectError": "carton dimensions must be 1 mm or more"},
  {"name": "a weightless carton", "args": ["20gp", 600, 400, 400, 0, false, null], "expectError": "cartonGrams must be 1 or more"}
]