Functional Weave
Code in Rust

construction.brick-count@1.0.0

vectors.json

4,191 bytes · view raw

[
  {
    "name": "one square metre of half-brick wall is the trade's 60 bricks",
    "args": [
      1,
      1,
      [],
      1,
      0
    ],
    "expect": {
      "netAreaSquareMetres": 1,
      "bricks": 60,
      "mortarCubicMetres": 0.018
    }
  },
  {
    "name": "a wall with a door and a window, 5 percent wastage",
    "args": [
      10,
      2.4,
      [
        {
          "width": 0.9,
          "height": 2.1
        },
        {
          "width": 1.2,
          "height": 1.05
        }
      ],
      1,
      500
    ],
    "expect": {
      "netAreaSquareMetres": 20.85,
      "bricks": 1298,
      "mortarCubicMetres": 0.387
    }
  },
  {
    "name": "a one-brick wall is 119 bricks a square metre, not 120, and adds a collar joint",
    "args": [
      1,
      1,
      [],
      2,
      0
    ],
    "expect": {
      "netAreaSquareMetres": 1,
      "bricks": 119,
      "mortarCubicMetres": 0.046
    }
  },
  {
    "name": "exactly 100 bricks plus 10 percent is exactly 110",
    "args": [
      2.25,
      0.75,
      [],
      1,
      1000
    ],
    "expect": {
      "netAreaSquareMetres": 1.6875,
      "bricks": 110,
      "mortarCubicMetres": 0.033
    }
  },
  {
    "name": "a garden wall that comes out to exactly 336 bricks with wastage",
    "args": [
      6,
      0.9,
      [],
      1,
      500
    ],
    "expect": {
      "netAreaSquareMetres": 5.4,
      "bricks": 336,
      "mortarCubicMetres": 0.101
    }
  },
  {
    "name": "three skins",
    "args": [
      1,
      1,
      [],
      3,
      0
    ],
    "expect": {
      "netAreaSquareMetres": 1,
      "bricks": 178,
      "mortarCubicMetres": 0.073
    }
  },
  {
    "name": "dimensions are taken to the nearest millimetre",
    "args": [
      3.0004,
      1,
      [],
      1,
      0
    ],
    "expect": {
      "netAreaSquareMetres": 3,
      "bricks": 178,
      "mortarCubicMetres": 0.053
    }
  },
  {
    "name": "an opening the size of the wall leaves nothing to build",
    "args": [
      2,
      1,
      [
        {
          "width": 2,
          "height": 1
        }
      ],
      1,
      500
    ],
    "expect": {
      "netAreaSquareMetres": 0,
      "bricks": 0,
      "mortarCubicMetres": 0
    }
  },
  {
    "name": "openings larger than the wall are an error",
    "args": [
      2,
      1,
      [
        {
          "width": 1.5,
          "height": 1.5
        }
      ],
      1,
      0
    ],
    "expectError": "openings are larger than the wall"
  },
  {
    "name": "no skins is an error",
    "args": [
      1,
      1,
      [],
      0,
      0
    ],
    "expectError": "skins must be a whole number from 1 to 4"
  },
  {
    "name": "five skins is an error",
    "args": [
      1,
      1,
      [],
      5,
      0
    ],
    "expectError": "skins must be a whole number from 1 to 4"
  },
  {
    "name": "a fractional skin count is an error",
    "args": [
      1,
      1,
      [],
      1.5,
      0
    ],
    "expectError": "skins must be a whole number from 1 to 4"
  },
  {
    "name": "a zero-length wall is an error",
    "args": [
      0,
      1,
      [],
      1,
      0
    ],
    "expectError": "wallLength must be a finite number greater than 0 and at most 1000 metres"
  },
  {
    "name": "a wall over 100 metres high is an error",
    "args": [
      5,
      101,
      [],
      1,
      0
    ],
    "expectError": "wallHeight must be a finite number greater than 0 and at most 100 metres"
  },
  {
    "name": "a negative opening is an error",
    "args": [
      5,
      2,
      [
        {
          "width": -1,
          "height": 1
        }
      ],
      1,
      0
    ],
    "expectError": "opening 1: width must be a finite number greater than 0 and at most 1000 metres"
  },
  {
    "name": "negative wastage is an error",
    "args": [
      1,
      1,
      [],
      1,
      -1
    ],
    "expectError": "wastageBasisPoints must be a whole number from 0 to 10000"
  },
  {
    "name": "fractional wastage is an error",
    "args": [
      1,
      1,
      [],
      1,
      2.5
    ],
    "expectError": "wastageBasisPoints must be a whole number from 0 to 10000"
  }
]