package org.byteworks.cbor.impl;

import static org.junit.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.junit.Test;

public class WhenEncodingPositiveIntegers {
  @Test
  public void encodesZero() throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    CBOROutputStream os = new CBOROutputStream(bos);
    int b = 0;
    os.write(b);
    os.close();
    byte[] bytes = bos.toByteArray();
    assertEquals(1, bytes.length);
    assertEquals(0, bytes[0]);
  }
}

@@ -143,24 +143,50 @@
 ception;%0D%0A%0D%0A
+import org.junit.Before;%0D%0A
 import org.j
@@ -250,90 +250,122 @@
 %0D%0A  
-@Test%0D%0A  public void encodesZero() throws IOException %7B%0D%0A    ByteArrayOutputStream
+private ByteArrayOutputStream bos;%0D%0A  private CBOROutputStream os;%0D%0A%0D%0A  @Before%0D%0A  public void beforeTest() %7B%0D%0A   
  bos
@@ -401,16 +401,25 @@
 );%0D%0A    
+os = new 
 CBOROutp
@@ -430,40 +430,207 @@
 ream
- os = new CBOROutputStream(bos);
+(bos);%0D%0A  %7D%0D%0A  %0D%0A  @Test%0D%0A  public void encodesZero() throws IOException %7B%0D%0A    int b = 0;%0D%0A    os.write(b);%0D%0A    assertWritten(1, 0);%0D%0A  %7D%0D%0A%0D%0A  @Test%0D%0A  public void encodesOne() throws IOException %7B
 %0D%0A  
@@ -631,33 +631,33 @@
  %7B%0D%0A    int b = 
-0
+1
 ;%0D%0A    os.write(
@@ -657,24 +657,141 @@
 .write(b);%0D%0A
+    assertWritten(1, 1);%0D%0A  %7D%0D%0A%0D%0A  private void assertWritten(int length, int...expectedBytes) throws IOException %7B%0D%0A
     os.close
@@ -851,17 +851,22 @@
 tEquals(
-1
+length
 , bytes.
@@ -883,30 +883,100 @@
     
-assertEquals(0
+for(int i = 0; i %3C expectedBytes.length; i++) %7B%0D%0A      assertEquals(expectedBytes%5Bi%5D
 , bytes%5B
 0%5D);
@@ -975,14 +975,21 @@
 tes%5B
-0
+i
 %5D);%0D%0A
+    %7D%0D%0A
   %7D%0D

encode 1