Class BasesConverter
- java.lang.Object
-
- org.junit.jupiter.params.converter.SimpleArgumentConverter
-
- edu.gatech.cs2110.circuitsim.extension.BasesConverter
-
- All Implemented Interfaces:
org.junit.jupiter.params.converter.ArgumentConverter
public class BasesConverter extends org.junit.jupiter.params.converter.SimpleArgumentConverter
Converts String arguments into integers using the base corresponding to their prefix. Uses:0b
for binary (like0b010010
)0x
for hex (like0xDEADBEEF
)- none for decimal (like
420
)
Looks prettier than cluttering your tests with parseInt calls everywhere.
Example:
@ParameterizedTest(name="a:{0}, b:{1}, sel:00 (a xor b) → out:{2}") @CsvSource({ /* a b | out */ "0b1111, 0b0000, 0b1111", "0b0000, 0b1111, 0b1111", "0b1111, 0b1111, 0b0000", "0b1011, 0b0010, 0b1001", }) public void xor(@ConvertWith(BasesConverter.class) int aIn, @ConvertWith(BasesConverter.class) int bIn, @ConvertWith(BasesConverter.class) int outOut) { a.set(aIn); b.set(bIn); sel.set(0b00); assertEquals(outOut, out.get(), "out"); }
- See Also:
- The README with examples
-
-
Constructor Summary
Constructors Constructor Description BasesConverter()
-