gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/cmds/core/cmp/cmp_test.go (about)

     1  // Copyright 2015-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"bytes"
     9  	"io"
    10  	"os"
    11  	"testing"
    12  )
    13  
    14  func TestEmit(t *testing.T) {
    15  
    16  	var buf = []byte("hello\nthis is a test\n")
    17  	var buf2 = []byte("hello\nthiz is a text")
    18  
    19  	c1 := make(chan byte, 8192)
    20  	c2 := make(chan byte, 8192)
    21  	c3 := make(chan byte, 8192)
    22  
    23  	r := bytes.NewReader(buf)
    24  	err := emit(r, c1, 0)
    25  	if err != io.EOF {
    26  		t.Errorf("%v\n", err)
    27  	}
    28  
    29  	r = bytes.NewReader(buf2)
    30  	err = emit(r, c2, 0)
    31  	if err != io.EOF {
    32  		t.Errorf("%v", err)
    33  	}
    34  
    35  	err = emit(os.Stdin, c3, 0)
    36  	if err != io.EOF {
    37  		t.Errorf("%v", err)
    38  	}
    39  
    40  }