2020-04-06 22:49:13 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
// Every test file (you can create as many as you want) should start like this
|
|
|
|
// Please, do NOT touch. They will be automatically removed for browser tests -->
|
|
|
|
const _pkg = require('../lib/index.node')
|
|
|
|
const chai = require('chai')
|
|
|
|
// <--
|
|
|
|
|
|
|
|
const inputs = [
|
2020-04-18 23:13:29 +00:00
|
|
|
{
|
|
|
|
a: BigInt(0),
|
|
|
|
b: BigInt(0),
|
|
|
|
lcm: BigInt(0)
|
|
|
|
},
|
2020-04-06 22:49:13 +00:00
|
|
|
{
|
|
|
|
a: BigInt(1),
|
|
|
|
b: BigInt(1),
|
|
|
|
lcm: BigInt(1)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
a: BigInt(1),
|
|
|
|
b: BigInt('14546149867129487614601346814'),
|
|
|
|
lcm: BigInt('14546149867129487614601346814')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
a: BigInt(27),
|
|
|
|
b: BigInt(18),
|
|
|
|
lcm: BigInt(27) * BigInt(2)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
a: BigInt(-27),
|
|
|
|
b: BigInt(18),
|
|
|
|
lcm: BigInt(27) * BigInt(2)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
a: BigInt('168694196579467171180863939518634764192343817610869919231900537093664715354591592262546800497540343203057121816378265655992490621138321114570420047522219942818258345349322155251835677199539229050711145144861404607171419723967136221126986330819362088262358855325306938646602003059377699727688477555163239222109'),
|
|
|
|
b: BigInt('168694196579467171180863939518634764192343817610869919231900537093664715354591592262546800497540343203057121816378265655992490621138321114570420047522219942818258345349322155251835677199539229050711145144861404607171419723967136221126986330819362088262358855325306938646602003059377699727688477555163239222109') * BigInt('144678545212641449725111562354371812236197961234111744040227045242578772124779004756249085154188369039159690638725821245974978963371615699005072473649705367893567309027634121825164880046600125480885803891136149601797439273507802533807541605261215613891134865916295914192271736572001975016089773532547481638243'),
|
|
|
|
lcm: BigInt('168694196579467171180863939518634764192343817610869919231900537093664715354591592262546800497540343203057121816378265655992490621138321114570420047522219942818258345349322155251835677199539229050711145144861404607171419723967136221126986330819362088262358855325306938646602003059377699727688477555163239222109') * BigInt('144678545212641449725111562354371812236197961234111744040227045242578772124779004756249085154188369039159690638725821245974978963371615699005072473649705367893567309027634121825164880046600125480885803891136149601797439273507802533807541605261215613891134865916295914192271736572001975016089773532547481638243')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
describe('lcm', function () {
|
|
|
|
for (const input of inputs) {
|
|
|
|
describe(`lcm(${input.a}, ${input.b})`, function () {
|
|
|
|
it(`should return ${input.lcm}`, function () {
|
|
|
|
const ret = _pkg.lcm(input.a, input.b)
|
|
|
|
chai.expect(ret).to.equal(input.lcm)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|