void () { PsiPrimitiveType[] types = {PsiTypes.byteType(), PsiTypes.shortType(), PsiTypes.charType(), PsiTypes.intType(), PsiTypes.longType()}; for (PsiPrimitiveType type : types) { assertTrue(JvmPsiRangeSetUtil.castTo(empty(), type).isEmpty()); assertEquals(point(0), JvmPsiRangeSetUtil.castTo(point(0), type)); } assertEquals(point(0x1234_5678_9ABC_DEF0L), JvmPsiRangeSetUtil.castTo(point(0x1234_5678_9ABC_DEF0L), PsiTypes.longType())); assertEquals(point(0xffff_ffff_9abc_def0L), JvmPsiRangeSetUtil.castTo(point(0x1234_5678_9ABC_DEF0L), PsiTypes.intType())); assertEquals(point(0xDEF0), JvmPsiRangeSetUtil.castTo(point(0x1234_5678_9ABC_DEF0L), PsiTypes.charType())); assertEquals(point(-8464), JvmPsiRangeSetUtil.castTo(point(0x1234_5678_9ABC_DEF0L), PsiTypes.shortType())); assertEquals(point(-16), JvmPsiRangeSetUtil.castTo(point(0x1234_5678_9ABC_DEF0L), PsiTypes.byteType())); LongRangeSet longSet = fromTypeStrict(PsiTypes.longType()); assertNotNull(longSet); LongRangeSet byteSet = fromTypeStrict(PsiTypes.byteType()); assertNotNull(byteSet); for (PsiPrimitiveType type : types) { LongRangeSet set = fromTypeStrict(type); assertNotNull(set); assertEquals(set, JvmPsiRangeSetUtil.castTo(set, type)); assertEquals(set, JvmPsiRangeSetUtil.castTo(longSet, type)); assertEquals(type.equals(PsiTypes.charType()) ? range(0, 127).join(range(0xFF80, 0xFFFF)) : byteSet, JvmPsiRangeSetUtil .castTo(byteSet, type)); } checkCast(range(-10, 1000), "{-128..127}", PsiTypes.byteType()); checkCast(range(-10, 200), "{-128..-56, -10..127}", PsiTypes.byteType()); checkCast(range(-1, 255), "{0..255, 65535}", PsiTypes.charType()); checkCast(range(0, 100000), "{-32768..32767}", PsiTypes.shortType()); checkCast(range(0, 50000), "{-32768..-15536, 0..32767}", PsiTypes.shortType()); assertEquals(fromTypeStrict(PsiTypes.intType()), JvmPsiRangeSetUtil.castTo(range(Long.MIN_VALUE, Integer.MAX_VALUE - 1), PsiTypes.intType())); }