cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

guac_protocol_version.c (2814B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#include <CUnit/CUnit.h>
     21#include <guacamole/protocol.h>
     22#include <guacamole/protocol-types.h>
     23
     24/**
     25 * Test which verifies that conversion of the guac_protocol_version enum to
     26 * string values succeeds and produces the expected results.
     27 */
     28void test_guac_protocol__version_to_string() {
     29    
     30    guac_protocol_version version_a = GUAC_PROTOCOL_VERSION_1_5_0;
     31    guac_protocol_version version_b = GUAC_PROTOCOL_VERSION_1_0_0;
     32    guac_protocol_version version_c = GUAC_PROTOCOL_VERSION_UNKNOWN;
     33    
     34    CU_ASSERT_STRING_EQUAL(guac_protocol_version_to_string(version_a), "VERSION_1_5_0");
     35    CU_ASSERT_STRING_EQUAL(guac_protocol_version_to_string(version_b), "VERSION_1_0_0");
     36    CU_ASSERT_PTR_NULL(guac_protocol_version_to_string(version_c));
     37    
     38}
     39
     40/**
     41 * Test which verifies that the version of String representations of Guacamole
     42 * protocol versions are successfully converted into their matching
     43 * guac_protocol_version enum values, and that versions that do not match
     44 * any version get the correct unknown value.
     45 */
     46void test_guac_protocol__string_to_version() {
     47    
     48    char* str_version_a = "VERSION_1_3_0";
     49    char* str_version_b = "VERSION_1_1_0";
     50    char* str_version_c = "AVACADO";
     51    char* str_version_d = "VERSION_31_4_1";
     52    
     53    CU_ASSERT_EQUAL(guac_protocol_string_to_version(str_version_a), GUAC_PROTOCOL_VERSION_1_3_0);
     54    CU_ASSERT_EQUAL(guac_protocol_string_to_version(str_version_b), GUAC_PROTOCOL_VERSION_1_1_0);
     55    CU_ASSERT_EQUAL(guac_protocol_string_to_version(str_version_c), GUAC_PROTOCOL_VERSION_UNKNOWN);
     56    CU_ASSERT_EQUAL(guac_protocol_string_to_version(str_version_d), GUAC_PROTOCOL_VERSION_UNKNOWN);
     57    
     58}
     59
     60/**
     61 * Test which verifies that the comparisons between guac_protocol_version enum
     62 * values produces the expected results.
     63 */
     64void test_gauc_protocol__version_comparison() {
     65    
     66    CU_ASSERT_TRUE(GUAC_PROTOCOL_VERSION_1_3_0 > GUAC_PROTOCOL_VERSION_1_0_0);
     67    CU_ASSERT_TRUE(GUAC_PROTOCOL_VERSION_UNKNOWN < GUAC_PROTOCOL_VERSION_1_1_0);
     68    
     69}