This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for Long handling in int64
- Loading branch information
Showing
7 changed files
with
52 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ message Car { | |
int32 year = 3; | ||
Tire front_tires = 4; | ||
Tire rear_tires = 5; | ||
int64 mileage = 6; | ||
} |
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 |
---|---|---|
@@ -1,16 +1,35 @@ | ||
import {Car} from './car'; | ||
import Long = require('long'); | ||
|
||
describe('protocol buffers', () => { | ||
|
||
it('allows creation of an object described by proto', () => { | ||
const pontiac = Car.create({"make": "pontiac"}); | ||
pontiac.frontTires = { | ||
width: 225, | ||
aspectRatio: 65, | ||
construction: 'R', | ||
diameter: 17, | ||
}; | ||
const pontiac = Car.create({ | ||
make: "pontiac", | ||
frontTires: { | ||
width: 225, | ||
aspectRatio: 65, | ||
construction: 'R', | ||
diameter: 17, | ||
}, | ||
}); | ||
expect(pontiac.make).toEqual('pontiac'); | ||
expect(pontiac.frontTires.width).toEqual(225); | ||
if (!pontiac.frontTires) { | ||
fail('Should have frontTires set'); | ||
} else { | ||
expect(pontiac.frontTires.width).toEqual(225); | ||
} | ||
}); | ||
}); | ||
|
||
// Asserts that longs are handled correctly. | ||
// This value comes from https://github.com/dcodeIO/long.js#background | ||
it('handles long values correctly', () => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
const pontiac = Car.create({ | ||
make: "pontiac", | ||
// Long.MAX_VALUE | ||
mileage: new Long(0xFFFFFFFF, 0x7FFFFFFF), | ||
}); | ||
const object = Car.toObject(pontiac, {longs: String}); | ||
expect(object["mileage"]).toEqual("9223372036854775807"); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -10,6 +10,10 @@ | |
version "2.8.2" | ||
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.2.tgz#6ae4d8740c0da5d5a627df725b4eed71b8e36668" | ||
|
||
"@types/long@^4.0.0": | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef" | ||
|
||
"@types/[email protected]": | ||
version "7.0.18" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.18.tgz#cd67f27d3dc0cfb746f0bdd5e086c4c5d55be173" | ||
|
@@ -925,15 +929,15 @@ [email protected]: | |
source-map "^0.5.6" | ||
source-map-support "^0.4.2" | ||
|
||
tslib@^1.7.1: | ||
version "1.8.0" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.0.tgz#dc604ebad64bcbf696d613da6c954aa0e7ea1eb6" | ||
tslib@^1.8.1: | ||
version "1.9.0" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" | ||
|
||
tsutils@2.12.1: | ||
version "2.12.1" | ||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.12.1.tgz#f4d95ce3391c8971e46e54c4cf0edb0a21dd5b24" | ||
tsutils@2.20.0: | ||
version "2.20.0" | ||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.20.0.tgz#303394064bc80be8ee04e10b8609ae852e9312d3" | ||
dependencies: | ||
tslib "^1.7.1" | ||
tslib "^1.8.1" | ||
|
||
tunnel-agent@^0.6.0: | ||
version "0.6.0" | ||
|
@@ -945,9 +949,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: | |
version "0.14.5" | ||
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" | ||
|
||
typescript@2.5.x: | ||
version "2.5.3" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.3.tgz#df3dcdc38f3beb800d4bc322646b04a3f6ca7f0d" | ||
typescript@2.6.x: | ||
version "2.6.2" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" | ||
|
||
[email protected]: | ||
version "1.0.2" | ||
|
Awesome