/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.codahale.shamir;

import org.quicktheories.quicktheories.core.Source;

import java.util.ArrayList;
import java.util.List;

import static org.quicktheories.quicktheories.generators.SourceDSL.integers;
import static org.quicktheories.quicktheories.generators.SourceDSL.lists;

public interface Generators {
    static Source<Byte> bytes() {
        return integers().between(0, 255).as(Integer::byteValue, Byte::intValue);
    }

    static Source<Byte> nonZeroBytes() {
        return integers().between(1, 255).as(Integer::byteValue, Byte::intValue);
    }

    static Source<byte[]> byteArrays() {
        return lists().arrayListsOf(bytes()).ofSizeBetween(1, 1000).as(
                l -> {
                    final byte[] bytes = new byte[l.size()];
                    for (int i = 0; i < l.size(); i++) {
                        bytes[i] = l.get(i);
                    }
                    return bytes;
                },
                a -> {
                    final List<Byte> bytes = new ArrayList<>(a.length);
                    for (int i = 0; i < a.length; i++) {
                        bytes.set(i, a[i]);
                    }
                    return bytes;
                }
        );
    }
}

@@ -668,16 +668,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -716,16 +716,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -1237,16 +1237,39 @@
 bytes())
+%0A                      
 .ofSizeB
@@ -1308,15 +1308,31 @@
     
-l -%3E %7B%0A
+        l -%3E %7B%0A        
     
@@ -1400,32 +1400,40 @@
                 
+      
+  
 for (int i = 0; 
@@ -1445,32 +1445,40 @@
 .size(); i++) %7B%0A
+        
                 
@@ -1518,34 +1518,47 @@
                 
-%7D%0A
+        %7D%0A     
                 
@@ -1553,32 +1553,35 @@
                 
+   
 return bytes;%0A  
@@ -1570,32 +1570,40 @@
   return bytes;%0A
+        
                 
@@ -1621,16 +1621,24 @@
         
+        
 a -%3E %7B%0A 
@@ -1652,24 +1652,32 @@
             
+   
+     
 final List%3CB
@@ -1728,32 +1728,40 @@
                 
+       
+ 
 for (int i = 0; 
@@ -1801,24 +1801,32 @@
             
+        
 bytes.set(i,
@@ -1845,34 +1845,50 @@
                 
+  
-%7D%0A
+      %7D%0A        
                 
@@ -1897,32 +1897,40 @@
   return bytes;%0A
+        
                 
@@ -1922,32 +1922,33 @@
                %7D
+)
 %0A        );%0A    
@@ -1940,16 +1940,59 @@
         
+              .describedAs(Arrays::toString
 );%0A    %7D

Fix string representations of generated byte arrays.