lkuchars commented on code in PR #10105:
URL: https://github.com/apache/nifi/pull/10105#discussion_r2254114186


##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-protobuf-message-name-resolver/src/test/java/org/apache/nifi/confluent/schemaregistry/VarintUtilsTest.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.confluent.schemaregistry;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static 
org.apache.nifi.confluent.schemaregistry.VarintUtils.decodeZigZag;
+import static 
org.apache.nifi.confluent.schemaregistry.VarintUtils.readVarintFromStream;
+import static 
org.apache.nifi.confluent.schemaregistry.VarintUtils.readVarintFromStreamAfterFirstByteConsumed;
+import static 
org.apache.nifi.confluent.schemaregistry.VarintUtils.writeZigZagVarint;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VarintUtilsTest {
+
+    @Test
+    public void testReadVarintFromStream_SingleByte() throws IOException {
+        byte[] data = {0x08}; // 8 in varint format (0x08 = 00001000)
+        InputStream inputStream = new ByteArrayInputStream(data);
+
+        int result = readVarintFromStream(inputStream);
+        assertEquals(8, result);
+    }
+
+    @Test
+    public void testReadVarintFromStream_MultiByte() throws IOException {
+        byte[] data = {(byte) 0x96, 0x01}; // 150 in varint format (10010110 
00000001)
+        InputStream inputStream = new ByteArrayInputStream(data);
+
+        int result = readVarintFromStream(inputStream);
+        assertEquals(150, result);
+    }
+
+    @Test
+    public void testReadVarintFromStream_MaxValue() throws IOException {
+        // Maximum 32-bit value in varint format (11111111 11111111 11111111 
11111111 00001111)
+        byte[] data = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 
0x0F};
+        InputStream inputStream = new ByteArrayInputStream(data);
+
+        int result = readVarintFromStream(inputStream);
+        assertEquals(0xFFFFFFFF, result);
+    }
+
+    @Test
+    public void testReadVarintFromStream_WithFirstByte() throws IOException {

Review Comment:
   I don't understand, in this test suite there are many cases with larger 
values where we have continuation bits set for bytes



-- 
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