repo
stringclasses
1 value
licence_name
stringclasses
1 value
sha
stringclasses
1 value
language
stringclasses
1 value
context
stringlengths
1.31k
10.9k
CLASS_NAME
stringlengths
3
21
METHOD_NAME
stringlengths
3
33
TEST_FILE
stringlengths
12
30
LIBRARIES
stringclasses
1 value
SUGGESTED_FRAMEWORK
stringclasses
1 value
SOURCES
stringlengths
727
10.3k
CREATE_NEW_FILE
stringclasses
1 value
CUSTOM_INSTRUCTIONS
stringclasses
1 value
testCode
stringlengths
110
1.92k
testOffset
int64
129
6.72k
testPath
stringlengths
50
68
codeUnderTest
stringlengths
50
2.04k
codeUnderTestOffset
int64
285
9.81k
codeUnderTestPath
stringlengths
46
64
codeUnderTestType
stringclasses
1 value
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `ByteString` class. Put new test methods inside the file `ByteStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a s...
ByteString
equals
ByteStringTest.java
JUnit4
File: ByteString.java ``` package co.nstant.in.cbor.model; import java.util.Arrays; public class ByteString extends ChunkableDataItem { private final byte[] bytes; public ByteString(byte[] bytes) { super(MajorType.BYTE_STRING); if (bytes == null) { this.bytes = null; } else {...
false
@Test public void shouldNotEquals() { byte[] bytes = "string".getBytes(); ByteString byteString = new ByteString(bytes); assertFalse(byteString.equals(new Object())); }
837
src/test/java/co/nstant/in/cbor/model/ByteStringTest.java
@Override public boolean equals(Object object) { if (object instanceof ByteString) { ByteString other = (ByteString) object; return super.equals(object) && Arrays.equals(bytes, other.bytes); } return false; }
497
src/main/java/co/nstant/in/cbor/model/ByteString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `ByteString` class. Put new test methods inside the file `ByteStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
ByteString
hashCode
ByteStringTest.java
JUnit4
File: ByteString.java ``` package co.nstant.in.cbor.model; import java.util.Arrays; public class ByteString extends ChunkableDataItem { private final byte[] bytes; public ByteString(byte[] bytes) { super(MajorType.BYTE_STRING); if (bytes == null) { this.bytes = null; } else {...
false
@Test public void shouldHashcode() { ChunkableDataItem superClass = new ChunkableDataItem(MajorType.BYTE_STRING); byte[] bytes = "string".getBytes(); ByteString byteString = new ByteString(bytes); assertEquals(byteString.hashCode(), superClass.hashCode() ^ Arrays.hashCode(bytes)); ...
1,043
src/test/java/co/nstant/in/cbor/model/ByteStringTest.java
@Override public int hashCode() { return super.hashCode() ^ Arrays.hashCode(bytes); }
767
src/main/java/co/nstant/in/cbor/model/ByteString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getBytes` method in the `ByteString` class. Put new test methods inside the file `ByteStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
ByteString
getBytes
ByteStringTest.java
JUnit4
File: ByteString.java ``` package co.nstant.in.cbor.model; import java.util.Arrays; public class ByteString extends ChunkableDataItem { private final byte[] bytes; public ByteString(byte[] bytes) { super(MajorType.BYTE_STRING); if (bytes == null) { this.bytes = null; } else {...
false
@Test public void shouldNotClone() { byte[] bytes = "see issue #18".getBytes(); ByteString byteString = new ByteString(bytes); assertEquals(byteString.getBytes(), bytes); }
1,372
src/test/java/co/nstant/in/cbor/model/ByteStringTest.java
public byte[] getBytes() { if (bytes == null) { return null; } else { return bytes; } }
352
src/main/java/co/nstant/in/cbor/model/ByteString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `setTag` method in the `DataItem` class. Put new test methods inside the file `DataItemTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a singl...
DataItem
setTag
DataItemTest.java
JUnit4
File: DataItem.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class DataItem { private final MajorType majorType; private Tag tag; protected DataItem(MajorType majorType) { this.majorType = majorType; Objects.requireNonNull(majorType, "majorType is null"); } ...
false
@Test(expected = NullPointerException.class) public void testSetTag_Tag_null() { DataItem di = new DataItem(MajorType.UNSIGNED_INTEGER); di.setTag(null); }
1,141
src/test/java/co/nstant/in/cbor/model/DataItemTest.java
public void setTag(Tag tag) { Objects.requireNonNull(tag, "tag is null"); this.tag = tag; }
567
src/main/java/co/nstant/in/cbor/model/DataItem.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `setTag` method in the `DataItem` class. Put new test methods inside the file `DataItemTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a singl...
DataItem
setTag
DataItemTest.java
JUnit4
File: DataItem.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class DataItem { private final MajorType majorType; private Tag tag; protected DataItem(MajorType majorType) { this.majorType = majorType; Objects.requireNonNull(majorType, "majorType is null"); } ...
false
@Test public void testGetTag() { DataItem di = new DataItem(MajorType.UNSIGNED_INTEGER); di.setTag(new Tag(1)); Tag t = di.getTag(); assertEquals(1L, t.getValue()); }
1,326
src/test/java/co/nstant/in/cbor/model/DataItemTest.java
public void setTag(Tag tag) { Objects.requireNonNull(tag, "tag is null"); this.tag = tag; }
567
src/main/java/co/nstant/in/cbor/model/DataItem.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `setTag` method in the `DataItem` class. Put new test methods inside the file `DataItemTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a singl...
DataItem
setTag
DataItemTest.java
JUnit4
File: DataItem.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class DataItem { private final MajorType majorType; private Tag tag; protected DataItem(MajorType majorType) { this.majorType = majorType; Objects.requireNonNull(majorType, "majorType is null"); } ...
false
@Test public void testRemoveTag() { DataItem di = new DataItem(MajorType.UNSIGNED_INTEGER); di.setTag(new Tag(1)); assertNotNull(di.getTag()); di.removeTag(); assertNull(di.getTag()); }
1,750
src/test/java/co/nstant/in/cbor/model/DataItemTest.java
public void setTag(Tag tag) { Objects.requireNonNull(tag, "tag is null"); this.tag = tag; }
567
src/main/java/co/nstant/in/cbor/model/DataItem.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getLanguage` method in the `LanguageTaggedString` class. Put new test methods inside the file `LanguageTaggedStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that...
LanguageTaggedString
getLanguage
LanguageTaggedStringTest.java
JUnit4
File: LanguageTaggedString.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class LanguageTaggedString extends Array { public LanguageTaggedString(String language, String string) { this(new UnicodeString(language), new UnicodeString(string)); } public LanguageTaggedString(U...
false
@Test public void shouldInitializeWithStrings() { LanguageTaggedString lts = new LanguageTaggedString("en", "Hello"); assertEquals(38, lts.getTag().getValue()); assertEquals("en", lts.getLanguage().getString()); assertEquals("Hello", lts.getString().getString()); }
149
src/test/java/co/nstant/in/cbor/model/LanguageTaggedStringTest.java
public UnicodeString getLanguage() { return (UnicodeString) getDataItems().get(0); }
520
src/main/java/co/nstant/in/cbor/model/LanguageTaggedString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `encode` method in the `CborEncoder` class. Put new test methods inside the file `CborEncoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
CborEncoder
encode
CborEncoderTest.java
JUnit4
File: CborEncoder.java ``` package co.nstant.in.cbor; import java.io.OutputStream; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.encoder.ArrayEncoder; import co.nstant.in.cbor.encoder.ByteStringEncoder; import co.nstant.in.cbor.encoder.MapEncoder; import co.nstant.in.cbor.encoder.NegativeInt...
false
@Test(expected = ClassCastException.class) public void shouldExpectSpecialImplementation() throws CborException { encoder.encode(new Mock(MajorType.SPECIAL)); }
1,996
src/test/java/co/nstant/in/cbor/CborEncoderTest.java
/** * Encode a single {@link DataItem}. * * @param dataItem the {@link DataItem} to encode. If null, encoder encodes a * {@link SimpleValue} NULL value. * @throws CborException if {@link DataItem} could not be encoded or there was * an problem with the...
2,804
src/main/java/co/nstant/in/cbor/CborEncoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `DoublePrecisionFloat` class. Put new test methods inside the file `DoublePrecisionFloatTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that ea...
DoublePrecisionFloat
hashCode
DoublePrecisionFloatTest.java
JUnit4
File: DoublePrecisionFloat.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class DoublePrecisionFloat extends Special { private final double value; public DoublePrecisionFloat(double value) { super(SpecialType.IEEE_754_DOUBLE_PRECISION_FLOAT); this.value = value; }...
false
@Test public void testHashcode() { Special superClass = new Special(SpecialType.IEEE_754_DOUBLE_PRECISION_FLOAT); double value = 1.234; DoublePrecisionFloat doublePrecisionFloat = new DoublePrecisionFloat(value); assertEquals(superClass.hashCode() ^ Objects.hashCode(value), doublePre...
732
src/test/java/co/nstant/in/cbor/model/DoublePrecisionFloatTest.java
@Override public int hashCode() { return super.hashCode() ^ Objects.hashCode(value); }
641
src/main/java/co/nstant/in/cbor/model/DoublePrecisionFloat.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `toString` method in the `DoublePrecisionFloat` class. Put new test methods inside the file `DoublePrecisionFloatTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that ea...
DoublePrecisionFloat
toString
DoublePrecisionFloatTest.java
JUnit4
File: DoublePrecisionFloat.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class DoublePrecisionFloat extends Special { private final double value; public DoublePrecisionFloat(double value) { super(SpecialType.IEEE_754_DOUBLE_PRECISION_FLOAT); this.value = value; }...
false
@Test public void testToString() { DoublePrecisionFloat doublePrecisionFloat = new DoublePrecisionFloat(1.234); assertEquals("1.234", doublePrecisionFloat.toString()); }
1,088
src/test/java/co/nstant/in/cbor/model/DoublePrecisionFloatTest.java
@Override public String toString() { return String.valueOf(value); }
749
src/main/java/co/nstant/in/cbor/model/DoublePrecisionFloat.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getSimpleValueType` method in the `SimpleValue` class. Put new test methods inside the file `SimpleValueTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test ...
SimpleValue
getSimpleValueType
SimpleValueTest.java
JUnit4
File: SimpleValue.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class SimpleValue extends Special { private final SimpleValueType simpleValueType; public static final SimpleValue FALSE = new SimpleValue(SimpleValueType.FALSE); public static final SimpleValue TRUE = new SimpleVal...
false
@Test public void shouldDecodeBoolean() throws CborException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); CborEncoder encoder = new CborEncoder(byteArrayOutputStream); encoder.encode(SimpleValue.TRUE); encoder.encode(SimpleValue.FALSE); byte[] ...
490
src/test/java/co/nstant/in/cbor/decoder/SimpleValueDecoderTest.java
public SimpleValueType getSimpleValueType() { return simpleValueType; }
960
src/main/java/co/nstant/in/cbor/model/SimpleValue.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `Tag` class. Put new test methods inside the file `TagTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use ca...
Tag
hashCode
TagTest.java
JUnit4
File: Tag.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class Tag extends DataItem { private final long value; public Tag(long value) { super(MajorType.TAG); this.value = value; } public long getValue() { return value; } @Override public b...
false
@Test public void testHashcode() { DataItem superClass = new DataItem(MajorType.TAG); for (long i = 0; i < 256; i++) { Tag tag = new Tag(i); assertEquals(tag.hashCode(), superClass.hashCode() ^ Objects.hashCode(i)); } }
246
src/test/java/co/nstant/in/cbor/model/TagTest.java
@Override public int hashCode() { return super.hashCode() ^ Objects.hashCode(value); }
521
src/main/java/co/nstant/in/cbor/model/Tag.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `Tag` class. Put new test methods inside the file `TagTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use case...
Tag
equals
TagTest.java
JUnit4
File: Tag.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class Tag extends DataItem { private final long value; public Tag(long value) { super(MajorType.TAG); this.value = value; } public long getValue() { return value; } @Override public b...
false
@Test public void testEquals1() { for (int i = 0; i < 256; i++) { Tag tag1 = new Tag(i); Tag tag2 = new Tag(i); assertTrue(tag1.equals(tag2)); } }
527
src/test/java/co/nstant/in/cbor/model/TagTest.java
@Override public boolean equals(Object object) { if (object instanceof Tag) { Tag other = (Tag) object; return super.equals(object) && value == other.value; } return false; }
285
src/main/java/co/nstant/in/cbor/model/Tag.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `Tag` class. Put new test methods inside the file `TagTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use case...
Tag
equals
TagTest.java
JUnit4
File: Tag.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class Tag extends DataItem { private final long value; public Tag(long value) { super(MajorType.TAG); this.value = value; } public long getValue() { return value; } @Override public b...
false
@Test public void testEquals2() { Tag tag = new Tag(0); assertTrue(tag.equals(tag)); }
739
src/test/java/co/nstant/in/cbor/model/TagTest.java
@Override public boolean equals(Object object) { if (object instanceof Tag) { Tag other = (Tag) object; return super.equals(object) && value == other.value; } return false; }
285
src/main/java/co/nstant/in/cbor/model/Tag.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `ofByte` method in the `AdditionalInformation` class. Put new test methods inside the file `AdditionalInformationTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that ea...
AdditionalInformation
ofByte
AdditionalInformationTest.java
JUnit4
File: AdditionalInformation.java ``` package co.nstant.in.cbor.model; public enum AdditionalInformation { DIRECT(0), ONE_BYTE(24), TWO_BYTES(25), FOUR_BYTES(26), EIGHT_BYTES(27), RESERVED(28), INDEFINITE(31); private final int value; private AdditionalInformation(int value) { ...
false
@Test public void shouldHandleReserved28() { Assert.assertEquals(AdditionalInformation.RESERVED, AdditionalInformation.ofByte(28)); Assert.assertEquals(AdditionalInformation.RESERVED, AdditionalInformation.ofByte(29)); Assert.assertEquals(AdditionalInformation.RESERVED, AdditionalInform...
129
src/test/java/co/nstant/in/cbor/model/AdditionalInformationTest.java
public static AdditionalInformation ofByte(int b) { switch (b & 31) { case 24: return ONE_BYTE; case 25: return TWO_BYTES; case 26: return FOUR_BYTES; case 27: return EIGHT_BYTES; case 28: case 29: case 30: ...
1,119
src/main/java/co/nstant/in/cbor/model/AdditionalInformation.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `add` method in the `CborBuilder` class. Put new test methods inside the file `CborBuilderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a si...
CborBuilder
add
CborBuilderTest.java
JUnit4
File: CborBuilder.java ``` package co.nstant.in.cbor; import java.math.BigInteger; import java.util.LinkedList; import java.util.List; import co.nstant.in.cbor.builder.AbstractBuilder; import co.nstant.in.cbor.builder.ArrayBuilder; import co.nstant.in.cbor.builder.ByteStringBuilder; import co.nstant.in.cbor.builder.Map...
false
@Test public void shouldResetDataItems() { CborBuilder builder = new CborBuilder(); builder.add(true); builder.add(1.0f); assertEquals(2, builder.build().size()); builder.reset(); assertEquals(0, builder.build().size()); }
279
src/test/java/co/nstant/in/cbor/CborBuilderTest.java
public CborBuilder add(boolean value) { add(convert(value)); return this; }
1,228
src/main/java/co/nstant/in/cbor/CborBuilder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `build` method in the `CborBuilder` class. Put new test methods inside the file `CborBuilderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a ...
CborBuilder
build
CborBuilderTest.java
JUnit4
File: CborBuilder.java ``` package co.nstant.in.cbor; import java.math.BigInteger; import java.util.LinkedList; import java.util.List; import co.nstant.in.cbor.builder.AbstractBuilder; import co.nstant.in.cbor.builder.ArrayBuilder; import co.nstant.in.cbor.builder.ByteStringBuilder; import co.nstant.in.cbor.builder.Map...
false
@Test public void shouldAddTag() { CborBuilder builder = new CborBuilder(); List<DataItem> dataItems = builder.addTag(1234).build(); assertEquals(1, dataItems.size()); assertTrue(dataItems.get(0) instanceof Tag); assertEquals(1234, ((Tag) dataItems.get(0)).getValue()); }
563
src/test/java/co/nstant/in/cbor/CborBuilderTest.java
public List<DataItem> build() { return dataItems; }
848
src/main/java/co/nstant/in/cbor/CborBuilder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `toString` method in the `Special` class. Put new test methods inside the file `SpecialTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a singl...
Special
toString
SpecialTest.java
JUnit4
File: Special.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class Special extends DataItem { public static final Special BREAK = new Special(SpecialType.BREAK); private final SpecialType specialType; protected Special(SpecialType specialType) { super(MajorType.SPECIAL); ...
false
@Test public void testToString() { Special special = Special.BREAK; assertEquals("BREAK", special.toString()); }
136
src/test/java/co/nstant/in/cbor/model/SpecialTest.java
@Override public String toString() { return specialType.name(); }
828
src/main/java/co/nstant/in/cbor/model/Special.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `add` method in the `Array` class. Put new test methods inside the file `ArrayTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use cas...
Array
add
ArrayTest.java
JUnit4
File: Array.java ``` package co.nstant.in.cbor.model; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Array extends ChunkableDataItem { private final ArrayList<DataItem> objects; public Array() { super(MajorType.ARRAY); objects = new ArrayList<>(); } ...
false
@Test public void testHashcode() { Array array1 = new Array().add(new UnicodeString("string")); Array array2 = new Array().add(new UnicodeString("string")); assertEquals(array1.hashCode(), array2.hashCode()); }
339
src/test/java/co/nstant/in/cbor/model/ArrayTest.java
public Array add(DataItem object) { objects.add(object); return this; }
439
src/main/java/co/nstant/in/cbor/model/Array.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `add` method in the `Array` class. Put new test methods inside the file `ArrayTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use cas...
Array
add
ArrayTest.java
JUnit4
File: Array.java ``` package co.nstant.in.cbor.model; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Array extends ChunkableDataItem { private final ArrayList<DataItem> objects; public Array() { super(MajorType.ARRAY); objects = new ArrayList<>(); } ...
false
@Test public void testToString() { Array array = new Array().add(new UnicodeString("a")); assertEquals("[a]", array.toString()); array.setChunked(true); assertEquals("[_ a]", array.toString()); array.add(new UnicodeString("b")); assertEquals("[_ a, b]", array.toString...
587
src/test/java/co/nstant/in/cbor/model/ArrayTest.java
public Array add(DataItem object) { objects.add(object); return this; }
439
src/main/java/co/nstant/in/cbor/model/Array.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `decodeNext` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
CborDecoder
decodeNext
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test(expected = CborException.class) public void shouldThrowCborException2() throws CborException { CborDecoder cborDecoder = new CborDecoder(new InputStream() { @Override public int read() throws IOException { return (8 << 5); } }); cbo...
1,307
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
/** * Decodes exactly one DataItem from the input stream. * * @return a {@link DataItem} or null if end of stream has reached. * @throws CborException if decoding failed */ public DataItem decodeNext() throws CborException { int symbol; try { symbol = inputStream...
4,185
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `isAutoDecodeInfinitiveMaps` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that ea...
CborDecoder
isAutoDecodeInfinitiveMaps
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldSetAutoDecodeInfinitiveMaps() { InputStream inputStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); CborDecoder cborDecoder = new CborDecoder(inputStream); assertTrue(cborDecoder.isAutoDecodeInfinitiveMaps()); cborDecoder.setAutoDecodeInfinitiveMaps(fa...
1,683
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
public boolean isAutoDecodeInfinitiveMaps() { return autoDecodeInfinitiveMaps; }
8,698
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `isAutoDecodeRationalNumbers` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that e...
CborDecoder
isAutoDecodeRationalNumbers
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldSetAutoDecodeRationalNumbers() { InputStream inputStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); CborDecoder cborDecoder = new CborDecoder(inputStream); assertTrue(cborDecoder.isAutoDecodeRationalNumbers()); cborDecoder.setAutoDecodeRationalNumbers...
2,083
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
public boolean isAutoDecodeRationalNumbers() { return autoDecodeRationalNumbers; }
9,553
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `isAutoDecodeLanguageTaggedStrings` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure ...
CborDecoder
isAutoDecodeLanguageTaggedStrings
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldSetAutoDecodeLanguageTaggedStrings() { InputStream inputStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); CborDecoder cborDecoder = new CborDecoder(inputStream); assertTrue(cborDecoder.isAutoDecodeLanguageTaggedStrings()); cborDecoder.setAutoDecodeLan...
2,487
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
public boolean isAutoDecodeLanguageTaggedStrings() { return autoDecodeLanguageTaggedStrings; }
9,810
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `decode` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
CborDecoder
decode
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldDecodeTaggedTags() throws CborException { DataItem decoded = CborDecoder.decode(new byte[] { (byte) 0xC1, (byte) 0xC2, 0x02 }).get(0); Tag outer = new Tag(1); Tag inner = new Tag(2); UnsignedInteger expected = new UnsignedInteger(2); inner.setTag(oute...
5,625
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
/** * Convenience method to decode a byte array directly. * * @param bytes the CBOR encoded data * @return a list of {@link DataItem}s * @throws CborException if decoding failed */ public static List<DataItem> decode(byte[] bytes) throws CborException { return new CborDecoder(n...
2,804
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `decodeNext` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
CborDecoder
decodeNext
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldDecodeTaggedRationalNumber() throws CborException { List<DataItem> items = new CborBuilder().addTag(1).addTag(30).addArray().add(1).add(2).end().build(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); CborEncoder encoder = new CborEncoder(baos); enc...
6,034
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
/** * Decodes exactly one DataItem from the input stream. * * @return a {@link DataItem} or null if end of stream has reached. * @throws CborException if decoding failed */ public DataItem decodeNext() throws CborException { int symbol; try { symbol = inputStream...
4,185
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `decode` method in the `CborDecoder` class. Put new test methods inside the file `CborDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
CborDecoder
decode
CborDecoderTest.java
JUnit4
File: CborDecoder.java ``` package co.nstant.in.cbor; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.Objects; import co.nstant.in.cbor.decoder.ArrayDecoder; import co.nstant.in...
false
@Test public void shouldThrowOnItemWithForgedLength() throws CborException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); AbstractEncoder<Long> maliciousEncoder = new AbstractEncoder<Long>(null, buffer) { @Override public void encode(Long length) throws CborExc...
6,723
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java
/** * Convenience method to decode a byte array directly. * * @param bytes the CBOR encoded data * @return a list of {@link DataItem}s * @throws CborException if decoding failed */ public static List<DataItem> decode(byte[] bytes) throws CborException { return new CborDecoder(n...
2,804
src/main/java/co/nstant/in/cbor/CborDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `UnicodeString` class. Put new test methods inside the file `UnicodeStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
UnicodeString
equals
UnicodeStringTest.java
JUnit4
File: UnicodeString.java ``` package co.nstant.in.cbor.model; public class UnicodeString extends ChunkableDataItem { private final String string; public UnicodeString(String string) { super(MajorType.UNICODE_STRING); this.string = string; } @Override public String toString() { ...
false
@Test public void shouldEqualsSameValue() { UnicodeString unicodeString1 = new UnicodeString("string"); UnicodeString unicodeString2 = new UnicodeString("string"); Assert.assertTrue(unicodeString1.equals(unicodeString2)); Assert.assertTrue(unicodeString2.equals(unicodeString1)); ...
764
src/test/java/co/nstant/in/cbor/model/UnicodeStringTest.java
@Override public boolean equals(Object object) { if (object instanceof UnicodeString && super.equals(object)) { UnicodeString other = (UnicodeString) object; if (string == null) { return other.string == null; } else { return string.equals(o...
473
src/main/java/co/nstant/in/cbor/model/UnicodeString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `UnicodeString` class. Put new test methods inside the file `UnicodeStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuse...
UnicodeString
hashCode
UnicodeStringTest.java
JUnit4
File: UnicodeString.java ``` package co.nstant.in.cbor.model; public class UnicodeString extends ChunkableDataItem { private final String string; public UnicodeString(String string) { super(MajorType.UNICODE_STRING); this.string = string; } @Override public String toString() { ...
false
@Test public void shouldHashNull() { Assert.assertEquals(0, new UnicodeString(null).hashCode()); }
1,091
src/test/java/co/nstant/in/cbor/model/UnicodeStringTest.java
@Override public int hashCode() { int hash = 0; if (string != null) { hash = super.hashCode(); hash += string.hashCode(); } return hash; }
864
src/main/java/co/nstant/in/cbor/model/UnicodeString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `UnicodeString` class. Put new test methods inside the file `UnicodeStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
UnicodeString
equals
UnicodeStringTest.java
JUnit4
File: UnicodeString.java ``` package co.nstant.in.cbor.model; public class UnicodeString extends ChunkableDataItem { private final String string; public UnicodeString(String string) { super(MajorType.UNICODE_STRING); this.string = string; } @Override public String toString() { ...
false
@Test public void shouldNotEqualOtherObjects() { UnicodeString unicodeString = new UnicodeString("string"); Assert.assertFalse(unicodeString.equals(null)); Assert.assertFalse(unicodeString.equals(1)); Assert.assertFalse(unicodeString.equals("string")); }
1,211
src/test/java/co/nstant/in/cbor/model/UnicodeStringTest.java
@Override public boolean equals(Object object) { if (object instanceof UnicodeString && super.equals(object)) { UnicodeString other = (UnicodeString) object; if (string == null) { return other.string == null; } else { return string.equals(o...
473
src/main/java/co/nstant/in/cbor/model/UnicodeString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `UnicodeString` class. Put new test methods inside the file `UnicodeStringTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
UnicodeString
equals
UnicodeStringTest.java
JUnit4
File: UnicodeString.java ``` package co.nstant.in.cbor.model; public class UnicodeString extends ChunkableDataItem { private final String string; public UnicodeString(String string) { super(MajorType.UNICODE_STRING); this.string = string; } @Override public String toString() { ...
false
@Test public void shouldNotEquals() { UnicodeString unicodeString1 = new UnicodeString(null); UnicodeString unicodeString2 = new UnicodeString(""); Assert.assertFalse(unicodeString1.equals(unicodeString2)); }
1,511
src/test/java/co/nstant/in/cbor/model/UnicodeStringTest.java
@Override public boolean equals(Object object) { if (object instanceof UnicodeString && super.equals(object)) { UnicodeString other = (UnicodeString) object; if (string == null) { return other.string == null; } else { return string.equals(o...
473
src/main/java/co/nstant/in/cbor/model/UnicodeString.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getKeys` method in the `Map` class. Put new test methods inside the file `MapTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use cas...
Map
getKeys
MapTest.java
JUnit4
File: Map.java ``` package co.nstant.in.cbor.model; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; public class Map extends ChunkableDataItem { private final LinkedHashMap<DataItem, DataItem> map; private final List<DataItem> keys = new LinkedLis...
false
@Test public void shouldUseLastOfDuplicateKeysByDefault() throws CborException { byte[] bytes = new byte[] { (byte) 0xa2, 0x01, 0x01, 0x01, 0x02 }; List<DataItem> decoded = CborDecoder.decode(bytes); Map map = (Map) decoded.get(0); assertEquals(map.getKeys().size(), 1); asser...
1,078
src/test/java/co/nstant/in/cbor/decoder/MapDecoderTest.java
public Collection<DataItem> getKeys() { return keys; }
879
src/main/java/co/nstant/in/cbor/model/Map.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `setChunked` method in the `ChunkableDataItem` class. Put new test methods inside the file `ChunkableDataItemTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each t...
ChunkableDataItem
setChunked
ChunkableDataItemTest.java
JUnit4
File: ChunkableDataItem.java ``` package co.nstant.in.cbor.model; import java.util.Objects; class ChunkableDataItem extends DataItem { private boolean chunked = false; protected ChunkableDataItem(MajorType majorType) { super(majorType); } public boolean isChunked() { return chunked; ...
false
@Test public void testEquals() { TestDataItem item1 = new TestDataItem(); TestDataItem item2 = new TestDataItem(); assertEquals(item1, item2); item1.setChunked(true); item2.setChunked(false); assertFalse(item1.equals(item2)); assertFalse(item1.equals(null)); ...
341
src/test/java/co/nstant/in/cbor/model/ChunkableDataItemTest.java
public ChunkableDataItem setChunked(boolean chunked) { this.chunked = chunked; return this; }
299
src/main/java/co/nstant/in/cbor/model/ChunkableDataItem.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `AbstractFloat` class. Put new test methods inside the file `AbstractFloatTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses ...
AbstractFloat
equals
AbstractFloatTest.java
JUnit4
File: AbstractFloat.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class AbstractFloat extends Special { private final float value; public AbstractFloat(SpecialType specialType, float value) { super(specialType); this.value = value; } public float getValue() {...
false
@Test public void testEquals() { AbstractFloat a = new AbstractFloat(SpecialType.IEEE_754_SINGLE_PRECISION_FLOAT, 0.0f); AbstractFloat b = new AbstractFloat(SpecialType.IEEE_754_SINGLE_PRECISION_FLOAT, 0.3f); assertEquals(a, a); assertEquals(b, b); assertFalse(a.equals(b)); ...
213
src/test/java/co/nstant/in/cbor/model/AbstractFloatTest.java
@Override public boolean equals(Object object) { if (object instanceof AbstractFloat) { AbstractFloat other = (AbstractFloat) object; return super.equals(object) && value == other.value; } return false; }
330
src/main/java/co/nstant/in/cbor/model/AbstractFloat.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `AbstractFloat` class. Put new test methods inside the file `AbstractFloatTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuse...
AbstractFloat
hashCode
AbstractFloatTest.java
JUnit4
File: AbstractFloat.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class AbstractFloat extends Special { private final float value; public AbstractFloat(SpecialType specialType, float value) { super(specialType); this.value = value; } public float getValue() {...
false
@Test public void testHashcode() { Special superClass = new Special(SpecialType.IEEE_754_SINGLE_PRECISION_FLOAT); AbstractFloat f = new AbstractFloat(SpecialType.IEEE_754_SINGLE_PRECISION_FLOAT, 0.0f); assertEquals(superClass.hashCode() ^ Objects.hashCode(0.0f), f.hashCode()); }
619
src/test/java/co/nstant/in/cbor/model/AbstractFloatTest.java
@Override public int hashCode() { return super.hashCode() ^ Objects.hashCode(value); }
596
src/main/java/co/nstant/in/cbor/model/AbstractFloat.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getNumerator` method in the `RationalNumber` class. Put new test methods inside the file `RationalNumberTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test ...
RationalNumber
getNumerator
RationalNumberTest.java
JUnit4
File: RationalNumber.java ``` package co.nstant.in.cbor.model; import java.math.BigInteger; import co.nstant.in.cbor.CborException; public class RationalNumber extends Array { public RationalNumber(Number numerator, Number denominator) throws CborException { setTag(30); if (numerator == null) { ...
false
@Test public void shouldSetNumeratorAndDenominator() throws CborException { UnsignedInteger one = new UnsignedInteger(1); UnsignedInteger two = new UnsignedInteger(2); RationalNumber rationalNumber = new RationalNumber(one, two); assertEquals(one, rationalNumber.getNumerator()); ...
737
src/test/java/co/nstant/in/cbor/model/RationalNumberTest.java
public Number getNumerator() { return (Number) getDataItems().get(0); }
732
src/main/java/co/nstant/in/cbor/model/RationalNumber.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `decode` method in the `SpecialDecoder` class. Put new test methods inside the file `SpecialDecoderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuse...
SpecialDecoder
decode
SpecialDecoderTest.java
JUnit4
File: SpecialDecoder.java ``` package co.nstant.in.cbor.decoder; import java.io.InputStream; import co.nstant.in.cbor.CborDecoder; import co.nstant.in.cbor.CborException; import co.nstant.in.cbor.model.SimpleValue; import co.nstant.in.cbor.model.SimpleValueType; import co.nstant.in.cbor.model.Special; import co.nstant....
false
@Test(expected = CborException.class) public void shouldThrowExceptionOnUnallocated() throws CborException { SpecialDecoder decoder = new SpecialDecoder(null, null); decoder.decode(28); }
140
src/test/java/co/nstant/in/cbor/decoder/SpecialDecoderTest.java
@Override public Special decode(int initialByte) throws CborException { switch (SpecialType.ofByte(initialByte)) { case BREAK: return Special.BREAK; case SIMPLE_VALUE: switch (SimpleValueType.ofByte(initialByte)) { case FALSE: return Simple...
1,018
src/main/java/co/nstant/in/cbor/decoder/SpecialDecoder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `put` method in the `Map` class. Put new test methods inside the file `MapTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use case to...
Map
put
MapTest.java
JUnit4
File: Map.java ``` package co.nstant.in.cbor.model; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; public class Map extends ChunkableDataItem { private final LinkedHashMap<DataItem, DataItem> map; private final List<DataItem> keys = new LinkedLis...
false
@Test public void testRemove() { UnicodeString key = new UnicodeString("key"); UnicodeString value = new UnicodeString("value"); Map map = new Map(); map.put(key, value); assertEquals(1, map.getValues().size()); map.remove(key); assertEquals(0, map.getValues()...
490
src/test/java/co/nstant/in/cbor/model/MapTest.java
public Map put(DataItem key, DataItem value) { if (map.put(key, value) == null) { keys.add(key); } return this; }
536
src/main/java/co/nstant/in/cbor/model/Map.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `Map` class. Put new test methods inside the file `MapTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use ca...
Map
hashCode
MapTest.java
JUnit4
File: Map.java ``` package co.nstant.in.cbor.model; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; public class Map extends ChunkableDataItem { private final LinkedHashMap<DataItem, DataItem> map; private final List<DataItem> keys = new LinkedLis...
false
@Test public void testHashcode() { Map map1 = new Map(); Map map2 = new Map(); assertEquals(map1.hashCode(), map2.hashCode()); map1.put(new UnicodeString("key"), new UnicodeString("value")); assertNotEquals(map1.hashCode(), map2.hashCode()); }
988
src/test/java/co/nstant/in/cbor/model/MapTest.java
@Override public int hashCode() { return super.hashCode() ^ map.hashCode(); }
1,270
src/main/java/co/nstant/in/cbor/model/Map.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `toString` method in the `Map` class. Put new test methods inside the file `MapTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use ca...
Map
toString
MapTest.java
JUnit4
File: Map.java ``` package co.nstant.in.cbor.model; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; public class Map extends ChunkableDataItem { private final LinkedHashMap<DataItem, DataItem> map; private final List<DataItem> keys = new LinkedLis...
false
@Test public void testToString() { Map map = new Map(); assertEquals("{ }", map.toString()); map.put(new UnicodeString("key1"), new UnicodeString("value1")); assertEquals("{ key1: value1 }", map.toString()); map.put(new UnicodeString("key2"), new UnicodeString("value2")); ...
1,285
src/test/java/co/nstant/in/cbor/model/MapTest.java
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); if (isChunked()) { stringBuilder.append("{_ "); } else { stringBuilder.append("{ "); } for (DataItem key : keys) { stringBuilder.append(key).append(": "...
1,369
src/main/java/co/nstant/in/cbor/model/Map.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `getValues` method in the `Map` class. Put new test methods inside the file `MapTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a single use c...
Map
getValues
MapTest.java
JUnit4
File: Map.java ``` package co.nstant.in.cbor.model; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; public class Map extends ChunkableDataItem { private final LinkedHashMap<DataItem, DataItem> map; private final List<DataItem> keys = new LinkedLis...
false
@Test public void testItemOrderIsPreserved() throws CborException { List<DataItem> input = new CborBuilder().addMap().put(1, "v1").put(0, "v2").end().build(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); CborEncoder encoder = new CborEncoder(byteArrayOutputStrea...
1,789
src/test/java/co/nstant/in/cbor/model/MapTest.java
public Collection<DataItem> getValues() { return map.values(); }
951
src/main/java/co/nstant/in/cbor/model/Map.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `ofByte` method in the `MajorType` class. Put new test methods inside the file `MajorTypeTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a sin...
MajorType
ofByte
MajorTypeTest.java
JUnit4
File: MajorType.java ``` package co.nstant.in.cbor.model; public enum MajorType { INVALID(-1), UNSIGNED_INTEGER(0), NEGATIVE_INTEGER(1), BYTE_STRING(2), UNICODE_STRING(3), ARRAY(4), MAP(5), TAG(6), SPECIAL(7); private final int value; private MajorType(int value) { th...
false
@Test public void shouldReturnInvalidOnInvalidByteValue() { Assert.assertEquals(MajorType.INVALID, MajorType.ofByte(0xffffffff)); }
1,231
src/test/java/co/nstant/in/cbor/model/MajorTypeTest.java
public static MajorType ofByte(int b) { switch (b >> 5) { case 0: return UNSIGNED_INTEGER; case 1: return NEGATIVE_INTEGER; case 2: return BYTE_STRING; case 3: return UNICODE_STRING; case 4: return ARRAY; ...
4,472
src/main/java/co/nstant/in/cbor/model/MajorType.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `hashCode` method in the `SimpleValue` class. Put new test methods inside the file `SimpleValueTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on...
SimpleValue
hashCode
SimpleValueTest.java
JUnit4
File: SimpleValue.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class SimpleValue extends Special { private final SimpleValueType simpleValueType; public static final SimpleValue FALSE = new SimpleValue(SimpleValueType.FALSE); public static final SimpleValue TRUE = new SimpleVal...
false
@Test public void testHashcode() { Special superClass1 = new Special(SpecialType.SIMPLE_VALUE); Special superClass2 = new Special(SpecialType.SIMPLE_VALUE_NEXT_BYTE); for (int i = 1; i < 256; i++) { SimpleValue simpleValue = new SimpleValue(i); if (i <= 23) { ...
254
src/test/java/co/nstant/in/cbor/model/SimpleValueTest.java
@Override public int hashCode() { return super.hashCode() ^ Objects.hashCode(value); }
1,366
src/main/java/co/nstant/in/cbor/model/SimpleValue.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `SimpleValue` class. Put new test methods inside the file `SimpleValueTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
SimpleValue
equals
SimpleValueTest.java
JUnit4
File: SimpleValue.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class SimpleValue extends Special { private final SimpleValueType simpleValueType; public static final SimpleValue FALSE = new SimpleValue(SimpleValueType.FALSE); public static final SimpleValue TRUE = new SimpleVal...
false
@Test public void testEquals1() { for (int i = 0; i < 256; i++) { SimpleValue simpleValue1 = new SimpleValue(i); SimpleValue simpleValue2 = new SimpleValue(i); assertTrue(simpleValue1.equals(simpleValue2)); } }
822
src/test/java/co/nstant/in/cbor/model/SimpleValueTest.java
@Override public boolean equals(Object object) { if (object instanceof SimpleValue) { SimpleValue other = (SimpleValue) object; return super.equals(object) && value == other.value; } return false; }
1,106
src/main/java/co/nstant/in/cbor/model/SimpleValue.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `equals` method in the `SimpleValue` class. Put new test methods inside the file `SimpleValueTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a...
SimpleValue
equals
SimpleValueTest.java
JUnit4
File: SimpleValue.java ``` package co.nstant.in.cbor.model; import java.util.Objects; public class SimpleValue extends Special { private final SimpleValueType simpleValueType; public static final SimpleValue FALSE = new SimpleValue(SimpleValueType.FALSE); public static final SimpleValue TRUE = new SimpleVal...
false
@Test public void testEquals2() { SimpleValue simpleValue = new SimpleValue(0); assertFalse(simpleValue.equals(new SimpleValue(1))); assertFalse(simpleValue.equals(null)); assertFalse(simpleValue.equals(false)); assertFalse(simpleValue.equals("")); assertFalse(simpleV...
1,098
src/test/java/co/nstant/in/cbor/model/SimpleValueTest.java
@Override public boolean equals(Object object) { if (object instanceof SimpleValue) { SimpleValue other = (SimpleValue) object; return super.equals(object) && value == other.value; } return false; }
1,106
src/main/java/co/nstant/in/cbor/model/SimpleValue.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `end` method in the `MapBuilder` class. Put new test methods inside the file `MapBuilderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a sing...
MapBuilder
end
MapBuilderTest.java
JUnit4
File: MapBuilder.java ``` package co.nstant.in.cbor.builder; import co.nstant.in.cbor.model.Array; import co.nstant.in.cbor.model.DataItem; import co.nstant.in.cbor.model.Map; public class MapBuilder<T extends AbstractBuilder<?>> extends AbstractBuilder<T> { private final Map map; private DataItem lastItem = nu...
false
@Test public void testMapBuilder() { List<DataItem> dataItems = new CborBuilder() .addMap() .put(new UnicodeString("key"), new UnicodeString("value")) .put(1, true) .put(2, "value".getBytes()) .put(3, 1.0d) ...
461
src/test/java/co/nstant/in/cbor/builder/MapBuilderTest.java
public T end() { return getParent(); }
4,882
src/main/java/co/nstant/in/cbor/builder/MapBuilder.java
method
https://github.com/c-rack/cbor-java.git
Apache License 2.0
cabd70d02e864354117d73d96d70ab021d748188
java
Write tests for the `end` method in the `MapBuilder` class. Put new test methods inside the file `MapBuilderTest.java`. *Guideline:* - Test file should be complete and compilable, without need for further actions. - Write a description of the class and the method being tested. - Ensure that each test focuses on a sing...
MapBuilder
end
MapBuilderTest.java
JUnit4
File: MapBuilder.java ``` package co.nstant.in.cbor.builder; import co.nstant.in.cbor.model.Array; import co.nstant.in.cbor.model.DataItem; import co.nstant.in.cbor.model.Map; public class MapBuilder<T extends AbstractBuilder<?>> extends AbstractBuilder<T> { private final Map map; private DataItem lastItem = nu...
false
@Test public void startMapInMap() { CborBuilder builder = new CborBuilder(); List<DataItem> dataItems = builder.addMap().startMap(new ByteString(new byte[] { 0x01 })).put(1, 2).end() .startMap(1).end().startMap("asdf").end().end().build(); Map rootMap = (Map) dataItems.get(0); ...
2,384
src/test/java/co/nstant/in/cbor/builder/MapBuilderTest.java
public T end() { return getParent(); }
4,882
src/main/java/co/nstant/in/cbor/builder/MapBuilder.java
method