From c5536f19efd3662717e387ace09612fdf80acd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Overg=C3=A5rd=20Nielsen?= Date: Mon, 29 Aug 2022 11:09:15 +0200 Subject: [PATCH] Add good test for all indexable types --- .../test/good_test_data/indexable_types.dart | 29 +++ .../good_test_data/indexable_types.expected | 185 ++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 generator/test/good_test_data/indexable_types.dart create mode 100644 generator/test/good_test_data/indexable_types.expected diff --git a/generator/test/good_test_data/indexable_types.dart b/generator/test/good_test_data/indexable_types.dart new file mode 100644 index 0000000000..ab4eca0dc9 --- /dev/null +++ b/generator/test/good_test_data/indexable_types.dart @@ -0,0 +1,29 @@ +import 'package:realm_common/realm_common.dart'; + +@RealmModel() +class _Indexable { + @Indexed() + late bool aBool; + @Indexed() + bool? aNullableBool; + @Indexed() + late int anInt; + @Indexed() + int? aNullableInt; + @Indexed() + late String aString; + @Indexed() + String? aNullableString; + @Indexed() + late ObjectId anObjectId; + @Indexed() + ObjectId? aNullableObjectId; + @Indexed() + late Uuid anUuid; + @Indexed() + Uuid? aNullableUuid; + @Indexed() + late DateTime aDateTime; + @Indexed() + DateTime? aNullableDateTime; +} diff --git a/generator/test/good_test_data/indexable_types.expected b/generator/test/good_test_data/indexable_types.expected new file mode 100644 index 0000000000..d2a8f655e8 --- /dev/null +++ b/generator/test/good_test_data/indexable_types.expected @@ -0,0 +1,185 @@ +// ************************************************************************** +// RealmObjectGenerator +// ************************************************************************** + +class Indexable extends _Indexable with RealmEntityMixin, RealmObjectMixin { + Indexable( + bool aBool, + int anInt, + String aString, + ObjectId anObjectId, + Uuid anUuid, + DateTime aDateTime, { + bool? aNullableBool, + int? aNullableInt, + String? aNullableString, + ObjectId? aNullableObjectId, + Uuid? aNullableUuid, + DateTime? aNullableDateTime, + }) { + _aBoolProperty.setValue(this, aBool); + _aNullableBoolProperty.setValue(this, aNullableBool); + _anIntProperty.setValue(this, anInt); + _aNullableIntProperty.setValue(this, aNullableInt); + _aStringProperty.setValue(this, aString); + _aNullableStringProperty.setValue(this, aNullableString); + _anObjectIdProperty.setValue(this, anObjectId); + _aNullableObjectIdProperty.setValue(this, aNullableObjectId); + _anUuidProperty.setValue(this, anUuid); + _aNullableUuidProperty.setValue(this, aNullableUuid); + _aDateTimeProperty.setValue(this, aDateTime); + _aNullableDateTimeProperty.setValue(this, aNullableDateTime); + } + + Indexable._(); + + static const _aBoolProperty = ValueProperty( + 'aBool', + RealmPropertyType.bool, + indexed: true, + ); + @override + bool get aBool => _aBoolProperty.getValue(this); + @override + set aBool(bool value) => _aBoolProperty.setValue(this, value); + + static const _aNullableBoolProperty = ValueProperty( + 'aNullableBool', + RealmPropertyType.bool, + indexed: true, + ); + @override + bool? get aNullableBool => _aNullableBoolProperty.getValue(this); + @override + set aNullableBool(bool? value) => + _aNullableBoolProperty.setValue(this, value); + + static const _anIntProperty = ValueProperty( + 'anInt', + RealmPropertyType.int, + indexed: true, + ); + @override + int get anInt => _anIntProperty.getValue(this); + @override + set anInt(int value) => _anIntProperty.setValue(this, value); + + static const _aNullableIntProperty = ValueProperty( + 'aNullableInt', + RealmPropertyType.int, + indexed: true, + ); + @override + int? get aNullableInt => _aNullableIntProperty.getValue(this); + @override + set aNullableInt(int? value) => _aNullableIntProperty.setValue(this, value); + + static const _aStringProperty = ValueProperty( + 'aString', + RealmPropertyType.string, + indexed: true, + ); + @override + String get aString => _aStringProperty.getValue(this); + @override + set aString(String value) => _aStringProperty.setValue(this, value); + + static const _aNullableStringProperty = ValueProperty( + 'aNullableString', + RealmPropertyType.string, + indexed: true, + ); + @override + String? get aNullableString => _aNullableStringProperty.getValue(this); + @override + set aNullableString(String? value) => + _aNullableStringProperty.setValue(this, value); + + static const _anObjectIdProperty = ValueProperty( + 'anObjectId', + RealmPropertyType.objectid, + indexed: true, + ); + @override + ObjectId get anObjectId => _anObjectIdProperty.getValue(this); + @override + set anObjectId(ObjectId value) => _anObjectIdProperty.setValue(this, value); + + static const _aNullableObjectIdProperty = ValueProperty( + 'aNullableObjectId', + RealmPropertyType.objectid, + indexed: true, + ); + @override + ObjectId? get aNullableObjectId => _aNullableObjectIdProperty.getValue(this); + @override + set aNullableObjectId(ObjectId? value) => + _aNullableObjectIdProperty.setValue(this, value); + + static const _anUuidProperty = ValueProperty( + 'anUuid', + RealmPropertyType.uuid, + indexed: true, + ); + @override + Uuid get anUuid => _anUuidProperty.getValue(this); + @override + set anUuid(Uuid value) => _anUuidProperty.setValue(this, value); + + static const _aNullableUuidProperty = ValueProperty( + 'aNullableUuid', + RealmPropertyType.uuid, + indexed: true, + ); + @override + Uuid? get aNullableUuid => _aNullableUuidProperty.getValue(this); + @override + set aNullableUuid(Uuid? value) => + _aNullableUuidProperty.setValue(this, value); + + static const _aDateTimeProperty = ValueProperty( + 'aDateTime', + RealmPropertyType.timestamp, + indexed: true, + ); + @override + DateTime get aDateTime => _aDateTimeProperty.getValue(this); + @override + set aDateTime(DateTime value) => _aDateTimeProperty.setValue(this, value); + + static const _aNullableDateTimeProperty = ValueProperty( + 'aNullableDateTime', + RealmPropertyType.timestamp, + indexed: true, + ); + @override + DateTime? get aNullableDateTime => _aNullableDateTimeProperty.getValue(this); + @override + set aNullableDateTime(DateTime? value) => + _aNullableDateTimeProperty.setValue(this, value); + + @override + Stream> get changes => + RealmObjectMixin.getChanges(this); + + static const schema = SchemaObject( + Indexable._, + 'Indexable', + { + 'aBool': _aBoolProperty, + 'aNullableBool': _aNullableBoolProperty, + 'anInt': _anIntProperty, + 'aNullableInt': _aNullableIntProperty, + 'aString': _aStringProperty, + 'aNullableString': _aNullableStringProperty, + 'anObjectId': _anObjectIdProperty, + 'aNullableObjectId': _aNullableObjectIdProperty, + 'anUuid': _anUuidProperty, + 'aNullableUuid': _aNullableUuidProperty, + 'aDateTime': _aDateTimeProperty, + 'aNullableDateTime': _aNullableDateTimeProperty, + }, + ); + @override + SchemaObject get instanceSchema => schema; +}