|
| 1 | +/* |
| 2 | + * Copyright 2022 Robert Bosch GmbH |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + */ |
| 18 | +/** |
| 19 | + * \file fable/schema/ignore_test.cpp |
| 20 | + * \see fable/schema/ignore.hpp |
| 21 | + */ |
| 22 | + |
| 23 | +#include <gtest/gtest.h> // for TEST |
| 24 | + |
| 25 | +#include <fable/confable.hpp> // for Confable |
| 26 | +#include <fable/schema.hpp> // for Ignore |
| 27 | +#include <fable/utility/gtest.hpp> // for assert_validate |
| 28 | + |
| 29 | +namespace { |
| 30 | + |
| 31 | +struct MyIgnoreStruct : public fable::Confable { |
| 32 | + CONFABLE_SCHEMA(MyIgnoreStruct) { |
| 33 | + using namespace fable::schema; // NOLINT(build/namespaces) |
| 34 | + return Struct{ |
| 35 | + {"args", Ignore("validates with anything")}, |
| 36 | + {"default", Ignore()}, |
| 37 | + {"silent", Ignore("")}, |
| 38 | + }; |
| 39 | + } |
| 40 | +}; |
| 41 | + |
| 42 | +} // anonymous namespace |
| 43 | + |
| 44 | +TEST(fable_schema_ignore, schema) { |
| 45 | + MyIgnoreStruct tmp; |
| 46 | + fable::assert_schema_eq(tmp, R"({ |
| 47 | + "type": "object", |
| 48 | + "properties": { |
| 49 | + "args": { |
| 50 | + "description": "validates with anything" |
| 51 | + }, |
| 52 | + "default": { |
| 53 | + "description": "ignored" |
| 54 | + }, |
| 55 | + "silent": {} |
| 56 | + }, |
| 57 | + "additionalProperties": false |
| 58 | + })"); |
| 59 | +} |
0 commit comments