mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
test pass
This commit is contained in:
parent
5c4f8e5d87
commit
7f2355b782
5 changed files with 78 additions and 11 deletions
|
@ -59,6 +59,7 @@ import "./tests/Jump.mjs";
|
|||
import "./tests/JSONBeautify.mjs";
|
||||
import "./tests/JSONMinify.mjs";
|
||||
import "./tests/JSONtoCSV.mjs";
|
||||
import "./tests/JSONToGoStruct.mjs";
|
||||
import "./tests/JWTDecode.mjs";
|
||||
import "./tests/JWTSign.mjs";
|
||||
import "./tests/JWTVerify.mjs";
|
||||
|
|
62
tests/operations/tests/JSONToGoStruct.mjs
Normal file
62
tests/operations/tests/JSONToGoStruct.mjs
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* JSON to Go Struct tests.
|
||||
*
|
||||
* @author wangkechun [hi@hi-hi.cn]
|
||||
*
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "JSON to Go Struct: simple",
|
||||
input: JSON.stringify({ a: "1", b: "2", c: "3" }),
|
||||
expectedOutput: `type AutoGenerated struct {
|
||||
A string \`json:"a"\`
|
||||
B string \`json:"b"\`
|
||||
C string \`json:"c"\`
|
||||
}`.replaceAll(" ", "\t"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to Go Struct",
|
||||
args: ["AutoGenerated", true, false],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to Go Struct: flatten",
|
||||
input: JSON.stringify({ a: "1", b: "2", c: { d: "e" } }),
|
||||
expectedOutput: `type AutoGenerated struct {
|
||||
A string \`json:"a"\`
|
||||
B string \`json:"b"\`
|
||||
C C \`json:"c"\`
|
||||
}
|
||||
type C struct {
|
||||
D string \`json:"d"\`
|
||||
}`.replaceAll(" ", "\t"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to Go Struct",
|
||||
args: ["AutoGenerated", true, false],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to Go Struct: nest",
|
||||
input: JSON.stringify({ a: "1", b: "2", c: { d: "e" } }),
|
||||
expectedOutput: `type AutoGenerated struct {
|
||||
A string \`json:"a"\`
|
||||
B string \`json:"b"\`
|
||||
C struct {
|
||||
D string \`json:"d"\`
|
||||
} \`json:"c"\`
|
||||
}`.replaceAll(" ", "\t"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to Go Struct",
|
||||
args: ["AutoGenerated", false, false],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue