-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib-dynamodb): large number handling (#5427)
* feat(lib-dynamodb): large number handling * feat(lib-dynamodb): large number handling docs and set test case * feat(lib-dynamodb): set release tag * feat(lib-dynamodb): remove unsafe conversion feature * feat(lib-dynamodb): add 1e100 number test case * feat(lib-dynamodb): large number handling, remove extra unmarshall option
- Loading branch information
Showing
10 changed files
with
314 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { NumberValue } from "./NumberValue"; | ||
|
||
const BIG_DECIMAL = | ||
"123456789012345678901234567890123456789012345678901234567890.123456789012345678901234567890123456789012345678901234567890"; | ||
const BIG_INT = "123456789012345678901234567890123456789012345678901234567890"; | ||
|
||
describe(NumberValue.name, () => { | ||
it("can be statically constructed from numbers", () => { | ||
expect(NumberValue.from(123.123).toString()).toEqual("123.123"); | ||
|
||
expect(() => NumberValue.from(1.23e100)).toThrow(); | ||
expect(() => NumberValue.from(Infinity)).toThrow(); | ||
expect(() => NumberValue.from(-Infinity)).toThrow(); | ||
expect(() => NumberValue.from(NaN)).toThrow(); | ||
}); | ||
|
||
it("can be statically constructed from strings", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toString()).toEqual(BIG_DECIMAL); | ||
}); | ||
|
||
it("can be statically constructed from BigInts", () => { | ||
expect(NumberValue.from(BigInt(BIG_INT)).toString()).toEqual(BIG_INT); | ||
}); | ||
|
||
it("can convert to AttributeValue", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toAttributeValue()).toEqual({ | ||
N: BIG_DECIMAL, | ||
}); | ||
}); | ||
|
||
it("can convert to string", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toString()).toEqual(BIG_DECIMAL); | ||
}); | ||
|
||
it("can convert to BigInt", () => { | ||
expect(NumberValue.from(BIG_INT).toBigInt()).toEqual(BigInt(BIG_INT)); | ||
}); | ||
}); |
Oops, something went wrong.