json: fix missing paren min/max bug
This commit is contained in:
parent
af63f4fb27
commit
a381deb1b6
2 changed files with 41 additions and 1 deletions
|
@ -214,6 +214,7 @@ static void _generate_min_max_int(int min_value, int max_value, std::stringstrea
|
||||||
more_digits(sub_len, sub_len);
|
more_digits(sub_len, sub_len);
|
||||||
} else {
|
} else {
|
||||||
out << "[" << from[i] << "] ";
|
out << "[" << from[i] << "] ";
|
||||||
|
out << "(";
|
||||||
uniform_range(from_sub, sub_nines);
|
uniform_range(from_sub, sub_nines);
|
||||||
if (from[i] < to[i] - 1) {
|
if (from[i] < to[i] - 1) {
|
||||||
out << " | ";
|
out << " | ";
|
||||||
|
@ -226,6 +227,7 @@ static void _generate_min_max_int(int min_value, int max_value, std::stringstrea
|
||||||
out << " ";
|
out << " ";
|
||||||
more_digits(sub_len, sub_len);
|
more_digits(sub_len, sub_len);
|
||||||
}
|
}
|
||||||
|
out << ")";
|
||||||
}
|
}
|
||||||
if (!to_reached) {
|
if (!to_reached) {
|
||||||
out << " | ";
|
out << " | ";
|
||||||
|
|
|
@ -233,7 +233,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
||||||
"maximum": 300
|
"maximum": 300
|
||||||
})""",
|
})""",
|
||||||
R"""(
|
R"""(
|
||||||
root ::= ([1] [5-9] | [2-9] [0-9] | [1-2] [0-9]{2} | [3] "00") space
|
root ::= ([1] ([5-9] | [2-9] [0-9]) | [1-2] [0-9]{2} | [3] "00") space
|
||||||
space ::= " "?
|
space ::= " "?
|
||||||
)"""
|
)"""
|
||||||
});
|
});
|
||||||
|
@ -576,6 +576,44 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
||||||
)"""
|
)"""
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test({
|
||||||
|
SUCCESS,
|
||||||
|
"min + max items with min + max values across zero",
|
||||||
|
R"""({
|
||||||
|
"items": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": -122,
|
||||||
|
"maximum": 207
|
||||||
|
},
|
||||||
|
"minItems": 3,
|
||||||
|
"maxItems": 5
|
||||||
|
})""",
|
||||||
|
R"""(
|
||||||
|
item ::= ("-" ([0-9] | [1-8] [0-9] | [9] [0-9] | "1" [0-1] [0-9] | [2] [0-2]) | [0-9] | [1-8] [0-9] | [9] [0-9] | [1] [0-9]{2} | [2] "0" [0-7]) space
|
||||||
|
root ::= "[" space item ("," space item){2,4} "]" space
|
||||||
|
space ::= " "?
|
||||||
|
)"""
|
||||||
|
});
|
||||||
|
|
||||||
|
test({
|
||||||
|
SUCCESS,
|
||||||
|
"min + max items with min + max values",
|
||||||
|
R"""({
|
||||||
|
"items": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 122,
|
||||||
|
"maximum": 207
|
||||||
|
},
|
||||||
|
"minItems": 3,
|
||||||
|
"maxItems": 5
|
||||||
|
})""",
|
||||||
|
R"""(
|
||||||
|
item ::= ([1] ([2] ([2-9] | [3-9] [0-9])) | [2] "0" [0-7]) space
|
||||||
|
root ::= "[" space item ("," space item){2,4} "]" space
|
||||||
|
space ::= " "?
|
||||||
|
)"""
|
||||||
|
});
|
||||||
|
|
||||||
test({
|
test({
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
"simple regexp",
|
"simple regexp",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue