# Copyright (C) 2018-present MongoDB, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the Server Side Public License, version 1, # as published by MongoDB, Inc. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # Server Side Public License for more details. # # You should have received a copy of the Server Side Public License # along with this program. If not, see # . # # As a special exception, the copyright holders give permission to link the # code of portions of this program with the OpenSSL library under certain # conditions as described in each individual source file and distribute # linked combinations including the program with the OpenSSL library. You # must comply with the Server Side Public License in all respects for # all of the code used other than as permitted herein. If you modify file(s) # with this exception, you may extend this exception to your version of the # file(s), but you are not obligated to do so. If you do not wish to do so, # delete this exception statement from your version. If you delete this # exception statement from all source files in the program, then also delete # it in the license file. # # IDL Unit Tests IDL file global: # Use a nested namespace simply to exercise nested namespace support for the code generator. cpp_namespace: "mongo::idl::test" cpp_includes: - "mongo/idl/idl_test_types.h" - "mongo/idl/idl_test.h" imports: - "mongo/idl/basic_types.idl" - "mongo/idl/unittest_import.idl" types: ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for a bindata type # ################################################################################################## bindata_custom: bson_serialization_type: bindata bindata_subtype: generic description: "A MongoDB BinDataCustomType" cpp_type: "mongo::BinDataCustomType" serializer: mongo::BinDataCustomType::serializeToBSON deserializer: mongo::BinDataCustomType::parseFromBSON ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for an any type # ################################################################################################## any_basic_type: bson_serialization_type: any description: "An Any Type" cpp_type: "mongo::AnyBasicType" serializer: mongo::AnyBasicType::serializeToBSON deserializer: mongo::AnyBasicType::parseFromBSON ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for an object type # ################################################################################################## object_basic_type: bson_serialization_type: object description: "An object Type" cpp_type: "mongo::ObjectBasicType" serializer: mongo::ObjectBasicType::serializeToBSON deserializer: mongo::ObjectBasicType::parseFromBSON ################################################################################################## # # Test types used in parser chaining testing # ################################################################################################## ChainedType: bson_serialization_type: chain description: "An Chain Type to test chaining" cpp_type: "mongo::ChainedType" serializer: mongo::ChainedType::serializeToBSON deserializer: mongo::ChainedType::parseFromBSON AnotherChainedType: bson_serialization_type: chain description: "Another Chain Type to test chaining" cpp_type: "mongo::AnotherChainedType" serializer: mongo::AnotherChainedType::serializeToBSON deserializer: mongo::AnotherChainedType::parseFromBSON ################################################################################################## # # Unit test structs for a single value to ensure type validation works correctly # ################################################################################################## enums: StringEnum: description: "An example string enum" type: string values: s0: "zero" s1: "one" s2: "two" structs: one_plain_object: description: UnitTest for a single BSONObj generate_comparison_operators: true fields: value: object one_plain_optional_object: description: UnitTest for optional BSONObj generate_comparison_operators: true fields: value: object value2: object opt_value: type: object optional: true opt_value2: type: object optional: true ################################################################################################## # # Structs to test derived parsers # ################################################################################################## DerivedBaseStruct: description: UnitTest for parser that will derive from a type fields: field1: int field2: int ################################################################################################## # # Structs to test various options for structs/fields # ################################################################################################## RequiredStrictField3: description: UnitTest for a strict struct with 3 required fields fields: field1: int field2: int field3: int RequiredNonStrictField3: description: UnitTest for a non-strict struct with 3 required fields strict: false fields: 1: type: int cpp_name: cppField1 2: type: int cpp_name: cppField2 3: type: int cpp_name: cppField3 ################################################################################################## # # Structs to test comparison options # ################################################################################################## CompareAllField3: description: UnitTest for a struct with 3 int fields to test comparison generate_comparison_operators: true fields: field1: int field2: int field3: int CompareSomeField3: description: | UnitTest for a struct with 3 int fields to test comparison, but only 2 are compared. generate_comparison_operators: true fields: field3: type: int comparison_order: 3 field2: int field1: type: int comparison_order: 1 ################################################################################################## # # Nested Structs with duplicate types # ################################################################################################## NestedWithDuplicateTypes: description: UnitTest for a non-strict struct with 3 required fields strict: false fields: field1: RequiredStrictField3 field2: type: RequiredNonStrictField3 optional: true field3: RequiredStrictField3 ################################################################################################## # # Structs to test various options for fields # ################################################################################################## ignoredField: description: UnitTest for a struct with an ignored_field fields: required_field: int ignored_field: type: int ignore: true ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for a string type # ################################################################################################## one_namespacestring: description: UnitTest for a single namespacestring fields: value: namespacestring ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for a bindata type # ################################################################################################## one_bindata_custom: description: UnitTest for a custom bindata fields: value: bindata_custom ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for an any type # ################################################################################################## one_any_basic_type: description: UnitTest for a single any type fields: value: any_basic_type ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for an object type # ################################################################################################## one_object_basic_type: description: UnitTest for a single object type fields: value: object_basic_type ################################################################################################## # # Test types that accept multiple serialization types # ################################################################################################## one_safeint64: description: UnitTest for a single safeInt64 fields: value: safeInt64 ################################################################################################## # # Test fields with default values # ################################################################################################## default_values: description: UnitTest for default values fields: V_string: type: string default: '"a default"' V_int: type: int default: 42 V_long: type: long default: 423 V_double: type: double default: 3.14159 V_bool: type: bool default: true ################################################################################################## # # Test fields with optional values # ################################################################################################## optional_field: description: UnitTest for a optional field fields: field1: type: string optional: true field2: type: int optional: true field3: type: object optional: true field4: type: bindata_generic optional: true field5: type: bindata_uuid optional: true ################################################################################################## # # Test array of simple types # ################################################################################################## simple_int_array: description: UnitTest for arrays of ints fields: field1: type: array simple_array_fields: description: UnitTest for arrays of simple types fields: field1: type: array field2: type: array field3: type: array field4: type: array field5: type: array optional_array_fields: description: UnitTest for arrays of optional simple types fields: field1: type: array optional: true field2: type: array optional: true field3: type: array optional: true field4: type: array optional: true field5: type: array optional: true ################################################################################################## # # Test array of complex types # ################################################################################################## complex_array_fields: description: UnitTest for arrays of complex optional and non-optional simple types fields: field1: type: array field2: type: array field3: type: array field4: type: array field5: type: array field6: type: array field1o: type: array optional: true field2o: type: array optional: true field3o: type: array optional: true field4o: type: array optional: true field5o: type: array optional: true field6o: type: array optional: true ################################################################################################## # # Test Chained Types # ################################################################################################## chained_string_basic_type: description: Base struct type for a chained string strict: false fields: stringField: string chained_any_basic_type: description: Base struct type for a chained any strict: false fields: anyField: any_basic_type chained_object_basic_type: description: Base struct type for a chained object strict: false fields: objectField: object_basic_type chained_struct_only: description: UnitTest for chained struct with only chained types strict: false chained_types: ChainedType : ChainedType AnotherChainedType : AnotherChainedType chained_struct_mixed: description: Chained struct with chained structs and fields strict: true inline_chained_structs: false chained_structs: chained_any_basic_type : chained_any_basic_type chained_object_basic_type : ChainedObjectBasicType fields: field3: string chained_struct_type_mixed: description: Chained struct with chained types, structs, and fields strict: false chained_types: ChainedType : chained_type AnotherChainedType: cpp_name: AnotherChainedType chained_structs: chained_string_basic_type: cpp_name: ChainedStringBasicType fields: field3: type: int chained_string_inline_basic_type: description: Base struct type for a chained string strict: true fields: stringField: string chained_struct_inline: description: Chained struct with chained structs and fields strict: true inline_chained_structs: true chained_structs: chained_string_inline_basic_type : chained_string_inline_basic_type fields: field3: string ################################################################################################## # # Test struct with enum # ################################################################################################## one_int_enum: description: mock fields: value: IntEnum one_string_enum: description: mock fields: value: StringEnum StructWithEnum: description: mock fields: field1: IntEnum field2: StringEnum field1o: type: IntEnum optional: true field2o: type: StringEnum optional: true fieldDefault: type: StringEnum default: s1 ################################################################################################## # # Using Validators # ################################################################################################## int_basic_ranges: description: Struct using basic range validators on ints fields: positive_int: type: int validator: { gt: 0 } negative_int: type: int validator: { lt: 0 } non_negative_int: type: int validator: { gte: 0 } non_positive_int: type: int validator: { lte: 0 } byte_range_int: type: int validator: { gte: 0, lt: 256 } range_int: type: int # Use INT32_MIN+1 for min since MSVC does not like -2147483647 as a constant. validator: { gte: -2147483647, lte: 2147483647 } double_basic_ranges: description: Struct using basic range validators on doubles fields: positive_double: type: double validator: { gt: 0.0 } negative_double: type: double validator: { lt: 0.0 } non_negative_double: type: double validator: { gte: 0.0 } non_positive_double: type: double validator: { lte: 0.0 } range_double: type: double validator: { gte: -12345678901234500000, lte: 12345678901234500000 } callback_validators: description: Struct using fields with callback validators fields: int_even: type: int validator: { callback: 'validateEvenNumber' } double_nearly_int: type: double validator: { callback: 'validateNearlyInt' } string_starts_with_x: type: string validator: { callback: "validateStartsWith<'x'>" } string_starts_with_x2: type: string optional: true validator: { callback: "validateStartsWith<'x'>" } unusual_callback_validators: description: Struct using fields with unusual callback validators fields: int_even: type: int optional: true validator: { callback: 'validateEvenNumber' } string_starts_with_x: type: string optional: true validator: { callback: "validateStartsWith<'x'>" } array_of_int: type: array validator: { callback: "validateEvenNumber" } array_of_int_optional: type: array optional: true validator: { callback: "validateEvenNumber" } one_int: type: one_int validator: { callback: 'validateOneInt' } one_int_optional: type: one_int optional: true validator: { callback: 'validateOneInt' } one_int_array: type: array validator: { callback: 'validateOneInt' } ################################################################################################## # # Test commands # ################################################################################################## commands: BasicIgnoredCommand: description: UnitTest for a basic ignored command namespace: ignored fields: field1: int field2: string BasicConcatenateWithDbCommand: description: UnitTest for a basic concatenate_with_db command namespace: concatenate_with_db fields: field1: int field2: string BasicConcatenateWithDbOrUUIDCommand: description: UnitTest for a basic concatenate_with_db_or_uuid command namespace: concatenate_with_db_or_uuid fields: field1: int field2: string KnownFieldCommand: description: UnitTest for a command that has a field that is special known generic command field namespace: concatenate_with_db fields: field1: int maxTimeMS: int DocSequenceCommand: description: UnitTest for a basic command with fields marked with supports_doc_sequence namespace: concatenate_with_db fields: field1: int field2: string structs: type: array supports_doc_sequence: true objects: type: array supports_doc_sequence: true objects_custom: type: array supports_doc_sequence: true optional: true DocSequenceCommandNonStrict: description: UnitTest for a basic command with fields marked with supports_doc_sequence and non-strict parsing namespace: concatenate_with_db strict: false fields: field1: int field2: string structs: type: array supports_doc_sequence: true objects: type: array supports_doc_sequence: true objects_custom: type: array supports_doc_sequence: true optional: true chained_command_type_mixed: description: Chained command with chained types, structs, and fields namespace: concatenate_with_db strict: false chained_types: ChainedType : chained_type AnotherChainedType: cpp_name: AnotherChainedType chained_structs: chained_string_basic_type: cpp_name: ChainedStringBasicType fields: field3: type: int CommandTypeStringCommand: description: Command with custom type string namespace: type type: string fields: field1: int CommandTypeArrayObjectCommand: description: Command with just an array of object parameter namespace: type type: array CommandTypeStructCommand: description: Command with just a struct parameter namespace: type type: one_string CommandTypeArrayStructCommand: description: Command with just an array of struct parameter namespace: type type: array _underscore_command: description: Command with custom type string namespace: type type: string cpp_name: WellNamedCommand fields: field1: int int_type_command: description: Command with custom type int namespace: type type: int fields: field1: int int_array_type_command: description: Command with custom type for array of int namespace: type type: array fields: field1: int