package zeptodns.protocol.wire;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static org.junit.Assert.assertEquals;

@RunWith(JUnit4.class)
public class FlagUtilsTest {
    @Test
    public void thatQueryResponseFlagIsSetCorrectly() {
        int flags = 0;

        flags = FlagUtils.setQueryResponse(flags, 1);

        assertEquals(flags, 1);

        flags = FlagUtils.setQueryResponse(flags, 0);

        assertEquals(flags, 0);
    }
}

@@ -484,11 +484,1037 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void thatFlagsSetAndOverlapCorrectly() %7B%0A        int flags = 0;%0A%0A        flags = FlagUtils.setQueryResponse(flags, 1);%0A        flags = FlagUtils.setOpcode(flags, 2);%0A        flags = FlagUtils.setAuthoritative(flags, 1);%0A        flags = FlagUtils.setTruncation(flags, 0);%0A        flags = FlagUtils.setRecursionDesired(flags, 0);%0A        flags = FlagUtils.setRecursionAvailable(flags, 1);%0A        flags = FlagUtils.setReserved(flags, 2);%0A        flags = FlagUtils.setResponseCode(flags, 1);%0A%0A        assertEquals(flags, 5413);%0A%0A        assertEquals(FlagUtils.getQueryResponse(flags), 1);%0A        assertEquals(FlagUtils.getOpcode(flags), 2);%0A        assertEquals(FlagUtils.getAuthoritative(flags), 1);%0A        assertEquals(FlagUtils.getTruncation(flags), 0);%0A        assertEquals(FlagUtils.getRecursionDesired(flags), 0);%0A        assertEquals(FlagUtils.getRecursionAvailable(flags), 1);%0A        assertEquals(FlagUtils.getReserved(flags), 2);%0A        assertEquals(FlagUtils.getResponseCode(flags), 1);%0A    %7D
 %0A%7D%0A

Add test case for overlapping flags