// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
//   requireNonNull(test);
//   return (flags & test.getMask()) == test.getMask();
// }
// 
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
//   if (flags == null || flags.length == 0) {
//     return 0;
//   }
// 
//   int result = 0;
//   for (final MaskedFlag flag : flags) {
//     if (flag == null) {
//       continue;
//     }
//     result |= flag.getMask();
//   }
//   return result;
// }


import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.lmdbjava.EnvFlags.MDB_FIXEDMAP;
import static org.lmdbjava.EnvFlags.MDB_NOSYNC;
import static org.lmdbjava.EnvFlags.MDB_RDONLY_ENV;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import org.junit.Test;
/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed 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.
 * #L%
 */

package org.lmdbjava;



/**
 * Test {@link MaskedFlag}.
 */
public final class MaskedFlagTest {

  @Test
  public void isSetOperates() {
    assertThat(isSet(0, MDB_NOSYNC), is(false));
    assertThat(isSet(0, MDB_FIXEDMAP), is(false));
    assertThat(isSet(0, MDB_RDONLY_ENV), is(false));

    assertThat(isSet(MDB_FIXEDMAP.getMask(), MDB_NOSYNC), is(false));
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
//   requireNonNull(test);
//   return (flags & test.getMask()) == test.getMask();
// }
// 
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
//   if (flags == null || flags.length == 0) {
//     return 0;
//   }
// 
//   int result = 0;
//   for (final MaskedFlag flag : flags) {
//     if (flag == null) {
//       continue;
//     }
//     result |= flag.getMask();
//   }
//   return result;
// }


// Path: src/test/java/org/lmdbjava/MaskedFlagTest.java
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.lmdbjava.EnvFlags.MDB_FIXEDMAP;
import static org.lmdbjava.EnvFlags.MDB_NOSYNC;
import static org.lmdbjava.EnvFlags.MDB_RDONLY_ENV;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import org.junit.Test;

/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed 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.
 * #L%
 */

package org.lmdbjava;



/**
 * Test {@link MaskedFlag}.
 */
public final class MaskedFlagTest {

  @Test
  public void isSetOperates() {
    assertThat(isSet(0, MDB_NOSYNC), is(false));
    assertThat(isSet(0, MDB_FIXEDMAP), is(false));
    assertThat(isSet(0, MDB_RDONLY_ENV), is(false));

    assertThat(isSet(MDB_FIXEDMAP.getMask(), MDB_NOSYNC), is(false));
    assertThat(isSet(MDB_FIXEDMAP.getMask(), MDB_FIXEDMAP), is(true));