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 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 363