@Test public void testIsValidMaskNo() { int max = 0; for (AccountAccessMask next : AccountAccessMask.values()) { max = Math.max(max, next.getMaskValue()); } max = max + 1; byte[] testMask = new byte[((max + 1) / 8) + ((max + 1) % 8 > 0 ? 1 : 0)]; int offset = max / 8; int bit = max % 8; testMask[offset] |= 1L << bit; Assert.assertFalse(AccountAccessMask.isValidMask(testMask)); }
@Test public void testUnsetMask() { byte[] value = AccountAccessMask.setMask(new byte[0], AccountAccessMask.ACCESS_SKILL_QUEUE); value = AccountAccessMask.setMask(value, AccountAccessMask.ACCESS_ACCOUNT_BALANCE); Assert.assertTrue(AccountAccessMask.isValidMask(value)); for (AccountAccessMask next : AccountAccessMask.values()) { switch (next) { case ACCESS_SKILL_QUEUE: case ACCESS_ACCOUNT_BALANCE: Assert.assertTrue(AccountAccessMask.isAccessAllowed(value, next)); break; default: Assert.assertFalse(AccountAccessMask.isAccessAllowed(value, next)); } } }