Skip to content

Commit

Permalink
updated to use v1.0.1 of infofile node-addon and added tests to check…
Browse files Browse the repository at this point in the history
… new functionality.
  • Loading branch information
jegasriskantha committed Sep 13, 2022
1 parent 3455368 commit cef28ab
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/__tests__/getDouble.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,15 @@ describe("getDouble tests", () => {
infofile.getDouble({ file: file, keys: [1, 2, "this"] });
}).toThrowError("keys must be a string or an array of strings");
});
// test case for getting a double value when the value is a nValue
test("can get a double value", () => {
// get the double value
const doubleValue = infofile.getDouble({
file: file,
keys: "SuspR.Stabi.Amplify",
});

// check that the double value is valid
expect(doubleValue).toEqual(10);
});
});
12 changes: 12 additions & 0 deletions src/__tests__/getLong.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,16 @@ describe("getLong tests", () => {
infofile.getLong({ file, keys: [1, 2, "this"] });
}).toThrowError("keys must be a string or an array of strings");
});

// test case for getting a long value when the value is a nValue
test("getLong returns only the value for a nValue parameter", () => {
// get the long value
const longValue = infofile.getLong({
file,
keys: "Steering.Rack2StWhl",
});

// check that the long value is valid
expect(longValue).toBe(100);
});
});
15 changes: 15 additions & 0 deletions src/__tests__/getString.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,19 @@ describe("getString tests", () => {
infofile.getString({ file, keys: [1, 2, "this"] });
}).toThrowError("keys must be a string or an array of strings");
});

// test case for getting a string where the value is an nValue
test("getString returns the parameter name and value for an nValue", () => {
// get the string value
const stringValue = infofile.getString({
file,
keys: "SuspR.Stabi.Amplify",
});

// expected string value
const expectedStringValue = "$stabiAmplify=10.0";

// check that the string value is valid
expect(stringValue).toEqual(expectedStringValue);
});
});
15 changes: 15 additions & 0 deletions src/__tests__/getValue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,19 @@ describe("getValue tests", () => {
// check that the keys value is valid
expect(keyValue[0].value).toEqual([470, 1500, 1600, 0, 0, 0]);
});

// test case for getting a value where the value is an nValue
test("getValue returns the parameter name and value for an nValue", () => {
// get the value
const keyValue = infofile.getValue({
file,
keys: "SuspR.Stabi.Amplify",
});

// expected value
const expectedStringValue = "$stabiAmplify=10.0";

// check that the string value is valid
expect(keyValue.value).toEqual(expectedStringValue);
});
});
4 changes: 2 additions & 2 deletions src/__tests__/infofiles/DemoCar
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ SuspR.Buf_Pull:
0.027 78083.0
0.030 108691.0
SuspR.Stabi.Kind = Hookean 1
SuspR.Stabi.Amplify = 1.0
SuspR.Stabi.Amplify = $stabiAmplify=10.0
SuspR.Stabi = 15000.0
SuspR.Kin.N = 1
SuspR.Com.N = 0
Expand All @@ -319,7 +319,7 @@ Susp.Comment:
## Steering ##############################################################
Steering.Kind = GenAngle 1
Steering.Comment:
Steering.Rack2StWhl = 100.0
Steering.Rack2StWhl = $rack2Whl=100


## Tires #################################################################
Expand Down
Binary file modified src/addons/infofile/linux64/infofile-linux64.node
Binary file not shown.
Binary file modified src/addons/infofile/win64/infofile-win64.node
Binary file not shown.

0 comments on commit cef28ab

Please sign in to comment.