Skip to content

Commit

Permalink
Test big integers in constraints (#146)
Browse files Browse the repository at this point in the history
Intentionally use large numbers in tests cases to help catch
implementation errors like this:
#144
  • Loading branch information
nicksnyder authored Dec 27, 2023
1 parent 037d514 commit 44761c4
Show file tree
Hide file tree
Showing 3 changed files with 1,139 additions and 915 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,31 @@ message Int64Ignore {
(buf.validate.field).ignore_empty = true
];
}
message Int64BigConstraints {
// Intentionally choose limits that are outside the range of both signed and unsigned 32-bit integers.
int64 lt_pos = 1 [(buf.validate.field).int64.lt = 5444333222];
int64 lt_neg = 2 [(buf.validate.field).int64.lt = -5444333222];
int64 gt_pos = 3 [(buf.validate.field).int64.gt = 5444333222];
int64 gt_neg = 4 [(buf.validate.field).int64.gt = -5444333222];
int64 lte_pos = 5 [(buf.validate.field).int64.lte = 5444333222];
int64 lte_neg = 6 [(buf.validate.field).int64.lte = -5444333222];
int64 gte_pos = 7 [(buf.validate.field).int64.gte = 5444333222];
int64 gte_neg = 8 [(buf.validate.field).int64.gte = -5444333222];
int64 constant_pos = 9 [(buf.validate.field).int64.const = 5444333222];
int64 constant_neg = 10 [(buf.validate.field).int64.const = -5444333222];
int64 in = 11 [(buf.validate.field).int64 = {
in: [
5444333222,
-5444333222
]
}];
int64 notin = 12 [(buf.validate.field).int64 = {
not_in: [
5444333222,
-5444333222
]
}];
}

message Int64IncorrectType {
int64 val = 1 [(buf.validate.field).float.gt = 0];
Expand Down
Loading

0 comments on commit 44761c4

Please sign in to comment.