damansingh1313 commented on code in PR #17890: URL: https://github.com/apache/iceberg/pull/17890#discussion_r3891680297
########## api/src/test/java/org/apache/iceberg/util/TestCharSequenceUtil.java: ########## @@ -0,0 +1,70 @@ +/* + * 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.iceberg.util; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class TestCharSequenceUtil { + + @Test + void unequalPathsReturnsFalseForSameReference() { + CharSequence path = "s3://bucket/table/data/file.parquet"; + assertThat(CharSequenceUtil.unequalPaths(path, path)).isFalse(); + } + + @Test + void unequalPathsReturnsFalseForEqualContentInDifferentInstances() { + String path = "s3://bucket/table/data/file.parquet"; + // a distinct String instance and a different CharSequence implementation with equal content + assertThat(CharSequenceUtil.unequalPaths(path, new String(path.toCharArray()))).isFalse(); + assertThat(CharSequenceUtil.unequalPaths(path, new StringBuilder(path))).isFalse(); + } + + @Test + void unequalPathsReturnsTrueForDifferentLengths() { + assertThat(CharSequenceUtil.unequalPaths("data/file.parquet", "data/file.parquet.crc")) + .isTrue(); + } + + @Test + void unequalPathsReturnsTrueWhenLastCharacterDiffers() { + // paths are compared from the end, so a trailing difference is found immediately + assertThat(CharSequenceUtil.unequalPaths("data/file-1.parquet", "data/file-2.parquet")) + .isTrue(); Review Comment: Thanks @ebyhr — you're right that it's a middle-of-string difference. I've renamed that case to ...WhenAMiddleCharacterDiffers, fixed the comments, and added a real last-character case (data/part-00001 vs data/part-00002), so first/middle/last are all covered now. Pushed as a follow-up. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
