Skip to content

Commit

Permalink
Merge pull request #187 from bhaskar-apple/BS-QRCodeInDocker
Browse files Browse the repository at this point in the history
Add QRCode tests to tasks.json and launch.json to run them in VSCode
  • Loading branch information
woody-apple authored Apr 1, 2020
2 parents 3e26f05 + 3e91639 commit 6ff9d22
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# VS Code Configs
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json

# Build System
.deps
Expand Down
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "QRCode Tests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/x86_64-unknown-linux-gnu/src/setup_payload/tests/TestQrCode",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "QRCode Tests",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
6 changes: 6 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
"type": "shell",
"command": "git clean -xdf",
"group": "none"
},
{
"label": "QRCode Tests",
"type": "shell",
"command": "make -C build/x86_64-unknown-linux-gnu/src/setup_payload/ check",
"group": "none"
}
]
}
1 change: 0 additions & 1 deletion src/setup_payload/Base45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ CHIP_ERROR base45Decode(string base45, vector<uint8_t> & result)
// base45 characters
if (base45.length() % kBase45ChunkLen == 1)
{
fprintf(stderr, "\nFailed decoding base45. Input was too short. %lu", base45.length());
return CHIP_ERROR_INVALID_MESSAGE_LENGTH;
}
result.clear();
Expand Down
1 change: 0 additions & 1 deletion src/setup_payload/QRCodeSetupPayloadParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CHIP_ERROR QRCodeSetupPayloadParser::populatePayload(SetupPayload & outPayload)

if (CHIP_NO_ERROR != result)
{
fprintf(stderr, "Decoding of base45 string failed");
return result;
}

Expand Down
11 changes: 10 additions & 1 deletion src/setup_payload/tests/tests_qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,16 @@ int testQRCodeToPayloadGeneration()

int main(int argc, char ** argv)
{
return testBitsetLen() + testPayloadByteArrayRep() + testPayloadBase45Rep() + testBase45() + testSetupPayloadVerify() +
int result = testBitsetLen() + testPayloadByteArrayRep() + testPayloadBase45Rep() + testBase45() + testSetupPayloadVerify() +
testPayloadEquality() + testPayloadInEquality() + testQRCodeToPayloadGeneration() +
testInvalidQRCodePayload_WrongCharacterSet() + testInvalidQRCodePayload_WrongLength();
if (result == 0)
{
printf("\n** All QRCode tests pass **\n");
}
else
{
printf("\n**== QRCode tests FAILED ==**\n");
}
return result;
}

0 comments on commit 6ff9d22

Please sign in to comment.