/*
 * MIT License
 *
 * Copyright (c) 2022 Alexey Edelev <semlanik@gmail.com>
 *
 * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this
 * software and associated documentation files (the "Software"), to deal in the Software
 * without restriction, including without limitation the rights to use, copy, modify,
 * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies
 * or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

import QtQuick
import QtTest
// TODO Qt6: check if QtProtobuf import is still relevant
//import QtProtobuf

import qtprotobufnamespace.tests

TestCase {
    MessageUpperCase {
        id: caseSenseMsg
    }

    MessageReserved {
        id: reservedMsg
    }

    PriorMessageUnderscoreField {
        id: underScoreMsg
    }

    LowerCaseMessageName {
        id: lowerCaseMsg
    }

    function test_reservedNames() {
        reservedMsg.id_proto = 34;
        reservedMsg.import_proto = 35;
        reservedMsg.property_proto = 36;
        compare(reservedMsg.id_proto, 34, "reservedMsg.id_proto == 34")
        compare(reservedMsg.import_proto, 35, "reservedMsg.import_proto == 35")
        compare(reservedMsg.property_proto, 36, "reservedMsg.property_proto == 36")
    }

    function test_reservedEnums() {
        compare(MessageEnumReserved.Import, 0, "MessageEnumReserved.Import == 0")
        compare(MessageEnumReserved.Property, 1, "MessageEnumReserved.Property == 1")
        compare(MessageEnumReserved.Id, 2, "MessageEnumReserved.Id == 2")
    }

    function test_caseSense() {
        caseSenseMsg.testField = 34;
        compare(caseSenseMsg.testField, 34, "MessageUpperCase == 34")

        compare(MessageEnumReserved.EnumValue0 == 0, true, "MessageEnumReserved.EnumValue0 == 0")
        compare(MessageEnumReserved.EnumValue1 == 1, true, "MessageEnumReserved.EnumValue1 == 1")
        compare(MessageEnumReserved.EnumValue2 == 2, true, "MessageEnumReserved.EnumValue2 == 2")
    }

    function test_underScoreField() {
        underScoreMsg.underScoreMessageField = 123
        compare(underScoreMsg.underScoreMessageField, 123, "underScoreMsg.underScoreMessageField == 123")
    }

    function test_lowerCaseMessage() {
        lowerCaseMsg.testField = 34
        compare(lowerCaseMsg.testField, 34, "LowerCaseMessageName == 34")
    }
}
