Skip to content

Commit

Permalink
GL→TPのテストを追加(実装は未実装)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ibaraki committed Dec 20, 2022
1 parent dc71860 commit ac0a926
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
31 changes: 29 additions & 2 deletions sample/libraryTest/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
//import { trim } from "./node_modules/helloworldnpm/dist/hellolib.js";
import { ElevationLevel } from "elevationlevel";

// GL=TP+5.5
const config = { GL: { standard: "TP" as const, level: 5.5 } }

const el = new ElevationLevel(
{
level: 10,
level: 3.1,
standard: 'TP' as const,
}
)

console.log(
el.to("GL", { GL: { standard: "TP" as const, level: 6 } }) // = Decimal(4.0)
el.to("GL", config) // = Decimal(-2.4)
)

// 機能未実装

// const el2 = new ElevationLevel(
// {
// level: 1.0,
// standard: 'GL' as const,
// }
// )

// console.log(
// el.to("TP", config) // = Decimal(6.5)
// )

/*
--- GL+1.0 = TP+6.5
--- GL+0.0 = TP+5.5
--- GL-2.4 = TP+3.1
--- GL-5.5 = TP+0.0
*/
1 change: 1 addition & 0 deletions sample/libraryTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "ISC",
"dependencies": {
"@types/node": "^18.11.17",
"decimal.js": "^10.4.3",
"elevationlevel": "^0.1.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
Expand Down
12 changes: 11 additions & 1 deletion test/ElevationLevel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ describe("to", () => {
expect(el.to("GL", { GL: { standard: "TP" as const, level: 6 } })).toEqual(new Decimal(4))
})

it("GLからTPを計算できる", () => {
const init = {
level: 10,
standard: 'GL' as const,
}
const el = new ElevationLevel(
init,
)
expect(el.to("TP", { GL: { standard: "TP" as const, level: 6 } })).toEqual(new Decimal(16))
})

it("TP→TPだと変換しない", () => {
const init = {
level: 10,
Expand All @@ -54,6 +65,5 @@ describe("to", () => {
init,
)
expect(el.to("TP", { GL: { standard: "TP" as const, level: 6 } })).toEqual(new Decimal(10))

})
})

0 comments on commit ac0a926

Please sign in to comment.