Skip to content

Commit b486b76

Browse files
committed
gh-279 Fix AbstractFlagSetTest
1 parent 7565c94 commit b486b76

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

‎src/main/java/org/lmdbjava/AbstractFlagSet.java‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016-2025 The LmdbJava Open Source Project
2+
* Copyright © 2016-2026 The LmdbJava Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,6 +85,18 @@ public String toString() {
8585
return FlagSet.asString(this);
8686
}
8787

88+
@Override
89+
public boolean equals(Object object) {
90+
if (object == null || getClass() != object.getClass()) return false;
91+
AbstractFlagSet<?> that = (AbstractFlagSet<?>) object;
92+
return mask == that.mask && Objects.equals(flags, that.flags);
93+
}
94+
95+
@Override
96+
public int hashCode() {
97+
return Objects.hash(flags, mask);
98+
}
99+
88100
static class AbstractEmptyFlagSet<T extends MaskedFlag> implements FlagSet<T> {
89101

90102
@Override

‎src/test/java/org/lmdbjava/AbstractFlagSetTest.java‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016-2025 The LmdbJava Open Source Project
2+
* Copyright © 2016-2026 The LmdbJava Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,8 +67,14 @@ void testSingleFlagSet() {
6767
final List<T> allFlags = getAllFlags();
6868
for (T flag : allFlags) {
6969
final F flagSet = getBuilder().addFlag(flag).build();
70+
71+
// Compare as a Set
72+
assertThat(flagSet.getFlags()).isEqualTo(flag.getFlags());
73+
// Compare as a FlagSet
74+
assertThat(flagSet).isEqualTo(flag);
75+
7076
assertThat(FlagSet.equals(flagSet, flag)).isTrue();
71-
assertThat(FlagSet.equals(flagSet, flag.getFlags())).isTrue();
77+
7278
assertThat(flagSet.getMask()).isEqualTo(flag.getMask());
7379
assertThat(flagSet.getMask()).isEqualTo(MaskedFlag.mask(flag));
7480
assertThat(flagSet.getFlags()).containsExactly(flag);

‎src/test/java/org/lmdbjava/KeyValTest.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright © 2016-2026 The LmdbJava Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.lmdbjava;
217

318
import static org.junit.jupiter.api.Assertions.*;

0 commit comments

Comments
 (0)