BinaryLoggingDecorator implements PerformanceLogger, Binary { @Override public void reset() { this.andCount = 0; this.xorCount = 0; } BinaryLoggingDecorator(Binary delegate); @Override DRes<SBool> known(boolean known); @Override DRes<SBool> input(boolean in, int inputter); @Override DRes<SBool> randomBit(); @Override DRes<Boolean> open(DRes<SBool> toOpen); @Override DRes<Boolean> open(DRes<SBool> toOpen, int towardsPartyId); @Override DRes<SBool> and(DRes<SBool> left, DRes<SBool> right); @Override DRes<SBool> xor(DRes<SBool> left, DRes<SBool> right); @Override DRes<SBool> not(DRes<SBool> in); @Override void reset(); @Override Map<String, Long> getLoggedValues(); static final String BINARY_BASIC_XOR; static final String BINARY_BASIC_AND; static final String BINARY_BASIC_RANDOM; }
@Test public void reset() { Binary binary = mock(Binary.class); when(binary.xor(any(DRes.class), any(DRes.class))).thenReturn(mock(DRes.class)); when(binary.and(any(DRes.class), any(DRes.class))).thenReturn(mock(DRes.class)); BinaryLoggingDecorator decorator = new BinaryLoggingDecorator(binary); decorator.xor(mock(DRes.class), mock(DRes.class)); decorator.and(mock(DRes.class), mock(DRes.class)); Assert.assertEquals(decorator.getLoggedValues().get("XOR_COUNT").intValue(), 1); Assert.assertEquals(decorator.getLoggedValues().get("AND_COUNT").intValue(), 1); decorator.reset(); Assert.assertEquals(decorator.getLoggedValues().get("XOR_COUNT").intValue(), 0); Assert.assertEquals(decorator.getLoggedValues().get("AND_COUNT").intValue(), 0); }