From 60928f33afffb00c3fadd52f1a7c72c5db90341e Mon Sep 17 00:00:00 2001 From: Malena Ebert Date: Thu, 17 Aug 2017 18:14:28 +0200 Subject: [PATCH 1/3] Generate equals, hashCode, toString Methods --- .../biginteger/ModifiableBigInteger.java | 24 +++++++++++++++++++ .../bool/ModifiableBoolean.java | 24 +++++++++++++++++++ .../bytearray/ModifiableByteArray.java | 18 ++++++++++++++ .../integer/ModifiableInteger.java | 24 +++++++++++++++++++ .../length/ModifiableLengthField.java | 24 +++++++++++++++++++ .../mlong/ModifiableLong.java | 24 +++++++++++++++++++ .../singlebyte/ModifiableByte.java | 24 +++++++++++++++++++ 7 files changed, 162 insertions(+) diff --git a/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java b/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java index e353bec3..278183a4 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java +++ b/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java @@ -75,4 +75,28 @@ public BigInteger getOriginalValue() { public void setOriginalValue(BigInteger originalValue) { this.originalValue = originalValue; } + + @Override + public String toString() { + return "ModifiableBigInteger{" + "originalValue=" + originalValue + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableBigInteger)) + return false; + + ModifiableBigInteger that = (ModifiableBigInteger) o; + + return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java b/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java index 598e6f90..6115ad2d 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java +++ b/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java @@ -64,4 +64,28 @@ public boolean validateAssertions() { } return true; } + + @Override + public String toString() { + return "ModifiableBoolean{" + "originalValue=" + originalValue + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableBoolean)) + return false; + + ModifiableBoolean that = (ModifiableBoolean) o; + + return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java b/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java index 98a517ee..ccf93307 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java +++ b/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java @@ -90,4 +90,22 @@ public String toString() { } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableByteArray)) + return false; + + ModifiableByteArray that = (ModifiableByteArray) o; + + return Arrays.equals(getValue(), that.getValue()); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Arrays.hashCode(originalValue); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java b/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java index 3eab05c8..61c62515 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java +++ b/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java @@ -71,4 +71,28 @@ public Integer getOriginalValue() { public void setOriginalValue(Integer originalValue) { this.originalValue = originalValue; } + + @Override + public String toString() { + return "ModifiableInteger{" + "originalValue=" + originalValue + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableInteger)) + return false; + + ModifiableInteger that = (ModifiableInteger) o; + + return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java index 0b856664..bd154d46 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java +++ b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java @@ -43,4 +43,28 @@ public Integer getOriginalValue() { public void setOriginalValue(Integer originalValue) { throw new UnsupportedOperationException("Cannot set original Value of ModifiableLengthField"); } + + @Override + public String toString() { + return "ModifiableLengthField{" + "ref=" + ref + "} " + super.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableLengthField)) + return false; + + ModifiableLengthField that = (ModifiableLengthField) o; + + return ref != null ? ref.equals(that.ref) : that.ref == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (ref != null ? ref.hashCode() : 0); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java b/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java index 919f72a4..9bf2a2b2 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java +++ b/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java @@ -71,4 +71,28 @@ public Long getOriginalValue() { public void setOriginalValue(Long originalValue) { this.originalValue = originalValue; } + + @Override + public String toString() { + return "ModifiableLong{" + "originalValue=" + originalValue + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableLong)) + return false; + + ModifiableLong that = (ModifiableLong) o; + + return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + return result; + } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java b/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java index 6265e062..561fdd7a 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java +++ b/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java @@ -66,4 +66,28 @@ public Byte getOriginalValue() { public void setOriginalValue(Byte originalValue) { this.originalValue = originalValue; } + + @Override + public String toString() { + return "ModifiableByte{" + "originalValue=" + originalValue + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ModifiableByte)) + return false; + + ModifiableByte that = (ModifiableByte) o; + + return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + return result; + } } From fcf6eb14b676b04a6274b608cfe5be4d13dfc260 Mon Sep 17 00:00:00 2001 From: ic0ns Date: Tue, 29 Aug 2017 09:54:48 +0200 Subject: [PATCH 2/3] Switched Original value with getValue in hashCode() --- .../modifiablevariable/biginteger/ModifiableBigInteger.java | 2 +- .../de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java | 2 +- .../nds/modifiablevariable/bytearray/ModifiableByteArray.java | 2 +- .../rub/nds/modifiablevariable/integer/ModifiableInteger.java | 2 +- .../nds/modifiablevariable/length/ModifiableLengthField.java | 4 ++-- .../de/rub/nds/modifiablevariable/mlong/ModifiableLong.java | 2 +- .../rub/nds/modifiablevariable/singlebyte/ModifiableByte.java | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java b/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java index 278183a4..3ca48911 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java +++ b/src/main/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigInteger.java @@ -96,7 +96,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java b/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java index 6115ad2d..66541b4c 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java +++ b/src/main/java/de/rub/nds/modifiablevariable/bool/ModifiableBoolean.java @@ -85,7 +85,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java b/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java index ccf93307..b6ed4134 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java +++ b/src/main/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArray.java @@ -105,7 +105,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + Arrays.hashCode(originalValue); + result = 31 * result + Arrays.hashCode(getValue()); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java b/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java index 61c62515..a8c2c2a4 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java +++ b/src/main/java/de/rub/nds/modifiablevariable/integer/ModifiableInteger.java @@ -92,7 +92,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java index bd154d46..f0b59681 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java +++ b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java @@ -58,13 +58,13 @@ public boolean equals(Object o) { ModifiableLengthField that = (ModifiableLengthField) o; - return ref != null ? ref.equals(that.ref) : that.ref == null; + return ref != null ? getValue().equals(that.ref) : that.getValue() == null; } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (ref != null ? ref.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java b/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java index 9bf2a2b2..f4482b9f 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java +++ b/src/main/java/de/rub/nds/modifiablevariable/mlong/ModifiableLong.java @@ -92,7 +92,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } diff --git a/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java b/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java index 561fdd7a..f4a4a572 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java +++ b/src/main/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByte.java @@ -87,7 +87,7 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (originalValue != null ? originalValue.hashCode() : 0); + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); return result; } } From f1a03f9db012ba519f5e4b3f4b13987d1e1d015a Mon Sep 17 00:00:00 2001 From: ic0ns Date: Tue, 29 Aug 2017 10:44:20 +0200 Subject: [PATCH 3/3] Added UnitTests for Equals methods --- .gitignore | 1 + .../length/ModifiableLengthField.java | 2 +- .../biginteger/ModifiableBigIntegerTest.java | 128 ++++++++++++++++++ .../bool/ModifiableBooleanTest.java | 100 ++++++++++++++ .../bytearray/ModifiableByteArrayTest.java | 12 ++ .../integer/ModifiableIntegerTest.java | 120 ++++++++++++++++ .../length/ModifiableLengthFieldTest.java | 85 ++++++++++++ .../mlong/ModifiableLongTest.java | 120 ++++++++++++++++ .../singlebyte/ModifiableByteTest.java | 112 +++++++++++++++ 9 files changed, 679 insertions(+), 1 deletion(-) create mode 100644 src/test/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigIntegerTest.java create mode 100644 src/test/java/de/rub/nds/modifiablevariable/bool/ModifiableBooleanTest.java create mode 100644 src/test/java/de/rub/nds/modifiablevariable/integer/ModifiableIntegerTest.java create mode 100644 src/test/java/de/rub/nds/modifiablevariable/length/ModifiableLengthFieldTest.java create mode 100644 src/test/java/de/rub/nds/modifiablevariable/mlong/ModifiableLongTest.java create mode 100644 src/test/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByteTest.java diff --git a/.gitignore b/.gitignore index 1cdc9f7f..44c61a7d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ release.properties dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +/nbproject/ \ No newline at end of file diff --git a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java index f0b59681..11a99116 100644 --- a/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java +++ b/src/main/java/de/rub/nds/modifiablevariable/length/ModifiableLengthField.java @@ -58,7 +58,7 @@ public boolean equals(Object o) { ModifiableLengthField that = (ModifiableLengthField) o; - return ref != null ? getValue().equals(that.ref) : that.getValue() == null; + return ref != null ? getValue().equals(that.getValue()) : that.getValue() == null; } @Override diff --git a/src/test/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigIntegerTest.java b/src/test/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigIntegerTest.java new file mode 100644 index 00000000..ef387d0c --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/biginteger/ModifiableBigIntegerTest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.biginteger; + +import java.math.BigInteger; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableBigIntegerTest { + + private ModifiableBigInteger integer1; + + private ModifiableBigInteger integer2; + + @Before + public void setUp() { + integer1 = new ModifiableBigInteger(); + integer1.setOriginalValue(BigInteger.ONE); + integer2 = new ModifiableBigInteger(); + integer2.setOriginalValue(BigInteger.TEN); + } + + /** + * Test of createRandomModification method, of class ModifiableBigInteger. + */ + @Test + public void testCreateRandomModification() { + } + + /** + * Test of getAssertEquals method, of class ModifiableBigInteger. + */ + @Test + public void testGetAssertEquals() { + } + + /** + * Test of setAssertEquals method, of class ModifiableBigInteger. + */ + @Test + public void testSetAssertEquals() { + } + + /** + * Test of isOriginalValueModified method, of class ModifiableBigInteger. + */ + @Test + public void testIsOriginalValueModified() { + } + + /** + * Test of getByteArray method, of class ModifiableBigInteger. + */ + @Test + public void testGetByteArray_0args() { + } + + /** + * Test of getByteArray method, of class ModifiableBigInteger. + */ + @Test + public void testGetByteArray_int() { + } + + /** + * Test of validateAssertions method, of class ModifiableBigInteger. + */ + @Test + public void testValidateAssertions() { + } + + /** + * Test of getOriginalValue method, of class ModifiableBigInteger. + */ + @Test + public void testGetOriginalValue() { + } + + /** + * Test of setOriginalValue method, of class ModifiableBigInteger. + */ + @Test + public void testSetOriginalValue() { + } + + /** + * Test of toString method, of class ModifiableBigInteger. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableBigInteger. + */ + @Test + public void testEquals() { + assertFalse(integer1.equals(integer2)); + integer2.setOriginalValue(BigInteger.ONE); + assertTrue(integer1.equals(integer2)); + } + + /** + * Test of hashCode method, of class ModifiableBigInteger. + */ + @Test + public void testHashCode() { + } + +} diff --git a/src/test/java/de/rub/nds/modifiablevariable/bool/ModifiableBooleanTest.java b/src/test/java/de/rub/nds/modifiablevariable/bool/ModifiableBooleanTest.java new file mode 100644 index 00000000..d433d881 --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/bool/ModifiableBooleanTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.bool; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableBooleanTest { + + private ModifiableBoolean boolean1; + + private ModifiableBoolean boolean2; + + @Before + public void setUp() { + boolean1 = new ModifiableBoolean(); + boolean1.setOriginalValue(Boolean.TRUE); + boolean2 = new ModifiableBoolean(); + boolean2.setOriginalValue(Boolean.TRUE); + + } + + /** + * Test of getOriginalValue method, of class ModifiableBoolean. + */ + @Test + public void testGetOriginalValue() { + } + + /** + * Test of setOriginalValue method, of class ModifiableBoolean. + */ + @Test + public void testSetOriginalValue() { + } + + /** + * Test of createRandomModification method, of class ModifiableBoolean. + */ + @Test + public void testCreateRandomModification() { + } + + /** + * Test of isOriginalValueModified method, of class ModifiableBoolean. + */ + @Test + public void testIsOriginalValueModified() { + } + + /** + * Test of validateAssertions method, of class ModifiableBoolean. + */ + @Test + public void testValidateAssertions() { + } + + /** + * Test of toString method, of class ModifiableBoolean. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableBoolean. + */ + @Test + public void testEquals() { + assertEquals(boolean1, boolean2); + boolean2.setOriginalValue(Boolean.FALSE); + assertNotEquals(boolean1, boolean2); + } + + /** + * Test of hashCode method, of class ModifiableBoolean. + */ + @Test + public void testHashCode() { + } + +} diff --git a/src/test/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArrayTest.java b/src/test/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArrayTest.java index 6a62513f..9f7e61ee 100644 --- a/src/test/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArrayTest.java +++ b/src/test/java/de/rub/nds/modifiablevariable/bytearray/ModifiableByteArrayTest.java @@ -13,6 +13,7 @@ import de.rub.nds.modifiablevariable.util.ArrayConverter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.Assert; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -444,4 +445,15 @@ public void toStringTest() { assertEquals("Actual byte value is: 00 01 02 03 04 05 06 07 08\nOriginal value was: 00 11 22 33 44", toTest.toString()); } + + @Test + public void testEquals() { + ModifiableByteArray array1 = new ModifiableByteArray(); + array1.setOriginalValue(new byte[] { 1, 2, 3, }); + ModifiableByteArray array2 = new ModifiableByteArray(); + array2.setOriginalValue(new byte[] { 1, 2, 3, }); + assertEquals(array1, array2); + array2.setOriginalValue(new byte[] { 3, 4, 5 }); + Assert.assertNotEquals(array1, array2); + } } diff --git a/src/test/java/de/rub/nds/modifiablevariable/integer/ModifiableIntegerTest.java b/src/test/java/de/rub/nds/modifiablevariable/integer/ModifiableIntegerTest.java new file mode 100644 index 00000000..686abe7b --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/integer/ModifiableIntegerTest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.integer; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableIntegerTest { + + private ModifiableInteger integer1; + + private ModifiableInteger integer2; + + @Before + public void setUp() { + integer1 = new ModifiableInteger(); + integer1.setOriginalValue(2); + integer2 = new ModifiableInteger(); + integer2.setOriginalValue(2); + } + + /** + * Test of createRandomModification method, of class ModifiableInteger. + */ + @Test + public void testCreateRandomModification() { + } + + /** + * Test of getAssertEquals method, of class ModifiableInteger. + */ + @Test + public void testGetAssertEquals() { + } + + /** + * Test of setAssertEquals method, of class ModifiableInteger. + */ + @Test + public void testSetAssertEquals() { + } + + /** + * Test of isOriginalValueModified method, of class ModifiableInteger. + */ + @Test + public void testIsOriginalValueModified() { + } + + /** + * Test of getByteArray method, of class ModifiableInteger. + */ + @Test + public void testGetByteArray() { + } + + /** + * Test of validateAssertions method, of class ModifiableInteger. + */ + @Test + public void testValidateAssertions() { + } + + /** + * Test of getOriginalValue method, of class ModifiableInteger. + */ + @Test + public void testGetOriginalValue() { + } + + /** + * Test of setOriginalValue method, of class ModifiableInteger. + */ + @Test + public void testSetOriginalValue() { + } + + /** + * Test of toString method, of class ModifiableInteger. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableInteger. + */ + @Test + public void testEquals() { + assertEquals(integer1, integer2); + integer2.setOriginalValue(3); + assertNotEquals(integer1, integer2); + } + + /** + * Test of hashCode method, of class ModifiableInteger. + */ + @Test + public void testHashCode() { + } + +} diff --git a/src/test/java/de/rub/nds/modifiablevariable/length/ModifiableLengthFieldTest.java b/src/test/java/de/rub/nds/modifiablevariable/length/ModifiableLengthFieldTest.java new file mode 100644 index 00000000..a0d7c550 --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/length/ModifiableLengthFieldTest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.length; + +import de.rub.nds.modifiablevariable.bytearray.ModifiableByteArray; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableLengthFieldTest { + + private ModifiableLengthField lengthField1; + + private ModifiableLengthField lengthField2; + + private ModifiableByteArray array; + + @Before + public void setUp() { + array = new ModifiableByteArray(); + array.setOriginalValue(new byte[] { 0, 1, 2, 3 }); + lengthField1 = new ModifiableLengthField(array); + lengthField2 = new ModifiableLengthField(array); + } + + /** + * Test of getOriginalValue method, of class ModifiableLengthField. + */ + @Test + public void testGetOriginalValue() { + assertTrue(lengthField1.getValue() == 4); + } + + /** + * Test of setOriginalValue method, of class ModifiableLengthField. + */ + @Test + public void testSetOriginalValue() { + + } + + /** + * Test of toString method, of class ModifiableLengthField. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableLengthField. + */ + @Test + public void testEquals() { + assertEquals(lengthField1, lengthField2); + array = new ModifiableByteArray(); + array.setOriginalValue(new byte[] { 1, 4 }); + lengthField2 = new ModifiableLengthField(array); + assertNotEquals(lengthField1, lengthField2); + } + + /** + * Test of hashCode method, of class ModifiableLengthField. + */ + @Test + public void testHashCode() { + } + +} diff --git a/src/test/java/de/rub/nds/modifiablevariable/mlong/ModifiableLongTest.java b/src/test/java/de/rub/nds/modifiablevariable/mlong/ModifiableLongTest.java new file mode 100644 index 00000000..7235c303 --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/mlong/ModifiableLongTest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.mlong; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableLongTest { + + private ModifiableLong long1; + + private ModifiableLong long2; + + @Before + public void setUp() { + long1 = new ModifiableLong(); + long1.setOriginalValue(2l); + long2 = new ModifiableLong(); + long2.setOriginalValue(2l); + } + + /** + * Test of createRandomModification method, of class ModifiableLong. + */ + @Test + public void testCreateRandomModification() { + } + + /** + * Test of getAssertEquals method, of class ModifiableLong. + */ + @Test + public void testGetAssertEquals() { + } + + /** + * Test of setAssertEquals method, of class ModifiableLong. + */ + @Test + public void testSetAssertEquals() { + } + + /** + * Test of isOriginalValueModified method, of class ModifiableLong. + */ + @Test + public void testIsOriginalValueModified() { + } + + /** + * Test of getByteArray method, of class ModifiableLong. + */ + @Test + public void testGetByteArray() { + } + + /** + * Test of validateAssertions method, of class ModifiableLong. + */ + @Test + public void testValidateAssertions() { + } + + /** + * Test of getOriginalValue method, of class ModifiableLong. + */ + @Test + public void testGetOriginalValue() { + } + + /** + * Test of setOriginalValue method, of class ModifiableLong. + */ + @Test + public void testSetOriginalValue() { + } + + /** + * Test of toString method, of class ModifiableLong. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableLong. + */ + @Test + public void testEquals() { + assertEquals(long1, long2); + long2.setOriginalValue(3l); + assertNotEquals(long1, long2); + } + + /** + * Test of hashCode method, of class ModifiableLong. + */ + @Test + public void testHashCode() { + } + +} diff --git a/src/test/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByteTest.java b/src/test/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByteTest.java new file mode 100644 index 00000000..5169adb3 --- /dev/null +++ b/src/test/java/de/rub/nds/modifiablevariable/singlebyte/ModifiableByteTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2017 Robert Merget . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.rub.nds.modifiablevariable.singlebyte; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Robert Merget + */ +public class ModifiableByteTest { + + private ModifiableByte byte1; + private ModifiableByte byte2; + + @Before + public void setUp() { + byte1 = new ModifiableByte(); + byte1.setOriginalValue((byte) 3); + byte2 = new ModifiableByte(); + byte2.setOriginalValue((byte) 3); + } + + /** + * Test of createRandomModification method, of class ModifiableByte. + */ + @Test + public void testCreateRandomModification() { + } + + /** + * Test of getAssertEquals method, of class ModifiableByte. + */ + @Test + public void testGetAssertEquals() { + } + + /** + * Test of setAssertEquals method, of class ModifiableByte. + */ + @Test + public void testSetAssertEquals() { + } + + /** + * Test of isOriginalValueModified method, of class ModifiableByte. + */ + @Test + public void testIsOriginalValueModified() { + } + + /** + * Test of validateAssertions method, of class ModifiableByte. + */ + @Test + public void testValidateAssertions() { + } + + /** + * Test of getOriginalValue method, of class ModifiableByte. + */ + @Test + public void testGetOriginalValue() { + } + + /** + * Test of setOriginalValue method, of class ModifiableByte. + */ + @Test + public void testSetOriginalValue() { + } + + /** + * Test of toString method, of class ModifiableByte. + */ + @Test + public void testToString() { + } + + /** + * Test of equals method, of class ModifiableByte. + */ + @Test + public void testEquals() { + assertEquals(byte1, byte2); + byte2.setOriginalValue((byte) 4); + assertNotEquals(byte1, byte2); + } + + /** + * Test of hashCode method, of class ModifiableByte. + */ + @Test + public void testHashCode() { + } + +}