Skip to content

Commit

Permalink
Add failure test cases for Sequence<N>
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Oct 19, 2024
1 parent 40dfb70 commit 67f4223
Show file tree
Hide file tree
Showing 76 changed files with 2,002 additions and 6 deletions.
27 changes: 27 additions & 0 deletions errors/src/protobuf/error_protobuf_sequence_property_duplicated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import typia, { tags } from "typia";

interface IPointer<T> {
value: T;
}
interface Something {
id: string & tags.Sequence<1>;
age: number & tags.Sequence<1>;
}

// MESSAGE
typia.protobuf.message<Something>();
typia.protobuf.message<IPointer<Something>>();
typia.protobuf.message<IPointer<Something[]>>();
typia.protobuf.message<IPointer<Map<string, Something>>>();

// DECODE
typia.protobuf.createDecode<Something>();
typia.protobuf.createDecode<IPointer<Something>>();
typia.protobuf.createDecode<IPointer<Something[]>>();
typia.protobuf.createDecode<IPointer<Map<string, Something>>>();

// ENCODE
typia.protobuf.createEncode<Something>();
typia.protobuf.createEncode<IPointer<Something>>();
typia.protobuf.createEncode<IPointer<Something[]>>();
typia.protobuf.createEncode<IPointer<Map<string, Something>>>();
32 changes: 32 additions & 0 deletions errors/src/protobuf/error_protobuf_sequence_union_duplicated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import typia, { tags } from "typia";

interface IPointer<T> {
value: T;
}
interface Something {
id:
| (number & tags.Type<"uint32"> & tags.Sequence<1>)
| (number & tags.Type<"double"> & tags.Sequence<2>)
| (string & tags.Sequence<3>);
sex:
| (number & tags.Type<"uint32"> & tags.Sequence<4>)
| (string & tags.Sequence<3>);
}

// MESSAGE
typia.protobuf.message<Something>();
typia.protobuf.message<IPointer<Something>>();
typia.protobuf.message<IPointer<Something[]>>();
typia.protobuf.message<IPointer<Map<string, Something>>>();

// DECODE
typia.protobuf.createDecode<Something>();
typia.protobuf.createDecode<IPointer<Something>>();
typia.protobuf.createDecode<IPointer<Something[]>>();
typia.protobuf.createDecode<IPointer<Map<string, Something>>>();

// ENCODE
typia.protobuf.createEncode<Something>();
typia.protobuf.createEncode<IPointer<Something>>();
typia.protobuf.createEncode<IPointer<Something[]>>();
typia.protobuf.createEncode<IPointer<Map<string, Something>>>();
29 changes: 29 additions & 0 deletions errors/src/protobuf/error_protobuf_sequence_union_omitted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import typia, { tags } from "typia";

interface IPointer<T> {
value: T;
}
interface Something {
id:
| (number & tags.Type<"uint32"> & tags.Sequence<1>)
| (number & tags.Type<"double"> & tags.Sequence<2>)
| string;
}

// MESSAGE
typia.protobuf.message<Something>();
typia.protobuf.message<IPointer<Something>>();
typia.protobuf.message<IPointer<Something[]>>();
typia.protobuf.message<IPointer<Map<string, Something>>>();

// DECODE
typia.protobuf.createDecode<Something>();
typia.protobuf.createDecode<IPointer<Something>>();
typia.protobuf.createDecode<IPointer<Something[]>>();
typia.protobuf.createDecode<IPointer<Map<string, Something>>>();

// ENCODE
typia.protobuf.createEncode<Something>();
typia.protobuf.createEncode<IPointer<Something>>();
typia.protobuf.createEncode<IPointer<Something[]>>();
typia.protobuf.createEncode<IPointer<Map<string, Something>>>();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"-------------------------------------------------": "",
"build": "rimraf lib && tsc && rollup -c",
"dev": "tsc --project tsconfig.test.json --watch",
"dev:errors": "tsc --project tsconfig.errors.json --watch",
"eslint": "eslint ./**/*.ts",
"eslint:fix": "eslint ./**/*.ts --fix",
"prettier": "prettier src --write",
Expand Down
27 changes: 27 additions & 0 deletions test/schemas/protobuf/ObjectSequenceProtobuf.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

message ObjectSequenceProtobuf {
repeated ObjectSequenceProtobuf.IMember value = 1;
message IMember {
oneof id {
bytes v13 = 13;
uint64 v12 = 12;
string v11 = 11;
}
optional string name = 20;
repeated ObjectSequenceProtobuf.IMember children = 30;
map<string, string> keywords = 40;
oneof thumbnail {
bytes v41 = 41;
string v42 = 42;
}
required string email = 43;
repeated ObjectSequenceProtobuf.IHobby hobbies = 44;
}

message IHobby {
required string id = 1;
required string name = 2;
required bool valid = 3;
}
}
6 changes: 3 additions & 3 deletions test/schemas/reflect/metadata/ObjectHttpNullable.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,15 @@
"type": "string",
"values": [
{
"value": "three",
"value": "one",
"tags": []
},
{
"value": "two",
"value": "three",
"tags": []
},
{
"value": "one",
"value": "two",
"tags": []
}
]
Expand Down
6 changes: 3 additions & 3 deletions test/schemas/reflect/metadata/ObjectHttpUndefindable.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@
"type": "string",
"values": [
{
"value": "three",
"value": "one",
"tags": []
},
{
"value": "two",
"value": "three",
"tags": []
},
{
"value": "one",
"value": "two",
"tags": []
}
]
Expand Down
Loading

0 comments on commit 67f4223

Please sign in to comment.