-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runPipelineEmscripten): JsonObject input support
- Loading branch information
Showing
10 changed files
with
115 additions
and
8 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 |
---|---|---|
|
@@ -174,6 +174,11 @@ | |
"src/bindgen/typescript-resources/*" | ||
] | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"test/pipelines/input-output-json-pipeline/emscripten-build/*.js" | ||
] | ||
}, | ||
"release": { | ||
"repositoryUrl": "[email protected]:InsightSoftwareConsortium/itk-wasm.git", | ||
"branches": [ | ||
|
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
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,23 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(input-output-json-test) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
find_package(ITK REQUIRED | ||
COMPONENTS WebAssemblyInterface) | ||
include(${ITK_USE_FILE}) | ||
add_executable(input-output-json-test input-output-json-test.cxx) | ||
target_link_libraries(input-output-json-test PUBLIC WebAssemblyInterface) | ||
|
||
enable_testing() | ||
add_test(NAME InputOutputJsonObjectTest | ||
COMMAND input-output-json-test | ||
${CMAKE_CURRENT_SOURCE_DIR}/input-object.json | ||
${CMAKE_CURRENT_BINARY_DIR}/output-object.json | ||
) | ||
|
||
add_test(NAME InputOutputJsonArrayTest | ||
COMMAND input-output-json-test | ||
${CMAKE_CURRENT_SOURCE_DIR}/input-array.json | ||
${CMAKE_CURRENT_BINARY_DIR}/output-array.json | ||
) |
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 @@ | ||
[8, 0, 9] |
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,4 @@ | ||
{ | ||
"key1": "text", | ||
"key2": 5 | ||
} |
50 changes: 50 additions & 0 deletions
50
test/pipelines/input-output-json-pipeline/input-output-json-test.cxx
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,50 @@ | ||
/*========================================================================= | ||
* | ||
* Copyright NumFOCUS | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
#include "itkPipeline.h" | ||
#include "itkInputTextStream.h" | ||
#include "itkOutputTextStream.h" | ||
|
||
#include <sstream> | ||
|
||
int main( int argc, char * argv[] ) | ||
{ | ||
itk::wasm::Pipeline pipeline("input-output-json-test", "A pipeline to test JSON IO", argc, argv); | ||
|
||
itk::wasm::InputTextStream inputJson; | ||
pipeline.add_option("input-json", inputJson, "The input json")->type_name("INPUT_JSON"); | ||
|
||
itk::wasm::OutputTextStream outputJson; | ||
pipeline.add_option("output-json", outputJson, "The output json")->type_name("OUTPUT_JSON"); | ||
|
||
ITK_WASM_PARSE(pipeline); | ||
|
||
const size_t bufferLength = 2048; | ||
char * buffer = new char[bufferLength]; | ||
size_t readLength = 0; | ||
|
||
std::istream & inputTxt = inputJson.Get(); | ||
inputTxt.read( buffer, bufferLength ); | ||
readLength = inputTxt.gcount(); | ||
buffer[readLength] = '\0'; | ||
|
||
outputJson.Get().write( buffer, readLength ); | ||
|
||
delete[] buffer; | ||
|
||
return EXIT_SUCCESS; | ||
} |