ayushtkn commented on code in PR #6408:
URL: https://github.com/apache/hadoop/pull/6408#discussion_r1606103696


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestPureJavaCrc32C.java:
##########
@@ -0,0 +1,36 @@
+/**
+ * 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.hadoop.util;
+
+import static org.junit.Assert.*;
+
+import java.util.zip.Checksum;
+
+import org.junit.Test;
+
+public class TestPureJavaCrc32C {
+
+  @Test
+  public void testChecksumInit() {
+    Checksum csum = new PureJavaCrc32C();
+    long crc1 = csum.getValue();
+    csum.reset();
+    long crc2 = csum.getValue();
+    assertEquals("reset should give same as initial value", crc1, crc2);
+  }
+}

Review Comment:
   A test like this does demonstrates the issue what I believe you intend to fix
   
   ```suggestion
   /**
    * 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.hadoop.util;
   
   import java.util.zip.Checksum;
   
   import org.junit.Test;
   
   import static org.junit.Assert.assertEquals;
   
   public class TestPureJavaCrc32C {
   
     @Test
     public void testChecksumInit() {
       Checksum csum = new DummyPureJavaCrc32C();
       long crc1 = csum.getValue();
       csum.reset();
       long crc2 = csum.getValue();
       assertEquals("reset should give same as initial value", crc1, crc2);
     }
   
     static class DummyPureJavaCrc32C extends PureJavaCrc32C {
       private final String dummVariable;
   
       DummyPureJavaCrc32C() {
         dummVariable = "abc";
       }
   
       @Override
       public void reset() {
         dummVariable.toString();
       }
     }
   }
   
   ```



-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to