|
6 | 6 |
|
7 | 7 | public class API_00007_UtilShimmerTest { |
8 | 8 |
|
| 9 | + @Test |
| 10 | + public void testValidMacWithColons() { |
| 11 | + // Upper case |
| 12 | + assertTrue("Should be valid: Uppercase with colons", |
| 13 | + UtilShimmer.isValidMacAddress("00:1A:2B:3C:4D:5E")); |
| 14 | + // Lower case |
| 15 | + assertTrue("Should be valid: Lowercase with colons", |
| 16 | + UtilShimmer.isValidMacAddress("00:1a:2b:3c:4d:5e")); |
| 17 | + } |
| 18 | + |
| 19 | + @Test |
| 20 | + public void testValidMacWithoutColons() { |
| 21 | + // Pure Hex string |
| 22 | + assertTrue("Should be valid: Plain hex string", |
| 23 | + UtilShimmer.isValidMacAddress("001A2B3C4D5E")); |
| 24 | + assertTrue("Should be valid: Lowercase plain hex", |
| 25 | + UtilShimmer.isValidMacAddress("001a2b3c4d5e")); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testInvalidCharacters() { |
| 30 | + // Contains 'G' (non-hex) |
| 31 | + assertFalse("Should be invalid: Contains non-hex character G", |
| 32 | + UtilShimmer.isValidMacAddress("00:1A:2B:3C:4D:5G")); |
| 33 | + // Contains special characters |
| 34 | + assertFalse("Should be invalid: Contains symbols", |
| 35 | + UtilShimmer.isValidMacAddress("00:1A:2B:3C:4D:5#")); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void testInvalidLength() { |
| 40 | + // Too short |
| 41 | + assertFalse("Should be invalid: Too short", |
| 42 | + UtilShimmer.isValidMacAddress("00:1A:2B")); |
| 43 | + // Too long |
| 44 | + assertFalse("Should be invalid: Too long", |
| 45 | + UtilShimmer.isValidMacAddress("00:1A:2B:3C:4D:5E:6F")); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + public void testMixedFormats() { |
| 50 | + // Cannot mix "no-colon" with "colons" halfway through |
| 51 | + assertFalse("Should be invalid: Inconsistent colon usage", |
| 52 | + UtilShimmer.isValidMacAddress("001A2B:3C:4D:5E")); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void testEdgeCases() { |
| 57 | + assertFalse("Should be invalid: Null input", |
| 58 | + UtilShimmer.isValidMacAddress(null)); |
| 59 | + assertFalse("Should be invalid: Empty string", |
| 60 | + UtilShimmer.isValidMacAddress("")); |
| 61 | + assertFalse("Should be invalid: Spaces included", |
| 62 | + UtilShimmer.isValidMacAddress("00 1A 2B 3C 4D 5E")); |
| 63 | + } |
| 64 | + |
9 | 65 | @Test |
10 | 66 | public void testRoundZeroDecimalPoints() { |
11 | 67 | assertTrue(UtilShimmer.round(5.567, 0) == 6.0); |
|
0 commit comments