github.com/d4l3k/go@v0.0.0-20151015000803-65fc379daeda/src/internal/trace/parser_test.go (about)

     1  // Copyright 2015 The Go 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 trace
     6  
     7  import (
     8  	"strings"
     9  	"testing"
    10  )
    11  
    12  func TestCorruptedInputs(t *testing.T) {
    13  	// These inputs crashed parser previously.
    14  	tests := []string{
    15  		"gotrace\x00\x020",
    16  		"gotrace\x00Q00\x020",
    17  		"gotrace\x00T00\x020",
    18  		"gotrace\x00\xc3\x0200",
    19  		"go 1.5 trace\x00\x00\x00\x00\x020",
    20  		"go 1.5 trace\x00\x00\x00\x00Q00\x020",
    21  		"go 1.5 trace\x00\x00\x00\x00T00\x020",
    22  		"go 1.5 trace\x00\x00\x00\x00\xc3\x0200",
    23  	}
    24  	for _, data := range tests {
    25  		events, err := Parse(strings.NewReader(data))
    26  		if err == nil || events != nil {
    27  			t.Fatalf("no error on input: %q\n", data)
    28  		}
    29  	}
    30  }