mike-jumper commented on code in PR #462:
URL: https://github.com/apache/guacamole-server/pull/462#discussion_r1372102851


##########
src/libguac/tests/mem/ckd_sub.c:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <CUnit/CUnit.h>
+#include <guacamole/mem.h>
+#include <stdint.h>
+
+/**
+ * Test which verifies that guac_mem_ckd_sub() calculates zero values for all
+ * inputs involving at least one zero value.
+ */
+void test_mem__ckd_sub_zero() {
+
+    size_t result = SIZE_MAX;
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 0, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 0, 0, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 0, 0, 0, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 0, 0, 0, 0, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 1, 0));
+    CU_ASSERT_EQUAL(result, 1);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 3, 2, 0));
+    CU_ASSERT_EQUAL(result, 3 - 2);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 8, 5, 0, 1));
+    CU_ASSERT_EQUAL(result, 8 - 5 - 1);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 99, 99, 0));
+    CU_ASSERT_EQUAL(result, 0);
+
+}
+
+/**
+ * Test which verifies that guac_mem_ckd_sub() successfully calculates expected
+ * values for relatively small integer inputs, including inputs that cause
+ * overflow beyond zero.
+ */
+void test_mem__ckd_sub_small() {
+
+    size_t result = SIZE_MAX;
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 123));
+    CU_ASSERT_EQUAL(result, 123);
+
+    CU_ASSERT_FALSE_FATAL(guac_mem_ckd_sub(&result, 456 - 123));

Review Comment:
   Fixed via rebase.



##########
src/libguac/tests/mem/ckd_add.c:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <CUnit/CUnit.h>
+#include <guacamole/mem.h>
+#include <stdint.h>
+
+/**
+ * Test which verifies that guac_mem_ckd_add() calculates zero values for all

Review Comment:
   Fixed via rebase.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to