github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/go/pointer/pointer_go117_test.go (about)

     1  // Copyright 2021 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  // No testdata on Android.
     6  
     7  //go:build !android && go1.17
     8  // +build !android,go1.17
     9  
    10  package pointer_test
    11  
    12  import (
    13  	"fmt"
    14  	"io/ioutil"
    15  	"os"
    16  	"path/filepath"
    17  	"testing"
    18  )
    19  
    20  func TestSliceToArrayPointer(t *testing.T) {
    21  	// Based on TestInput. Keep this up to date with that.
    22  	filename := "testdata/arrays_go117.go"
    23  
    24  	if testing.Short() {
    25  		t.Skip("skipping in short mode; this test requires tons of memory; https://golang.org/issue/14113")
    26  	}
    27  
    28  	wd, err := os.Getwd()
    29  	if err != nil {
    30  		t.Fatalf("os.Getwd: %s", err)
    31  	}
    32  	fmt.Fprintf(os.Stderr, "Entering directory `%s'\n", wd)
    33  
    34  	content, err := ioutil.ReadFile(filename)
    35  	if err != nil {
    36  		t.Fatalf("couldn't read file '%s': %s", filename, err)
    37  	}
    38  	fpath, err := filepath.Abs(filename)
    39  	if err != nil {
    40  		t.Errorf("couldn't get absolute path for '%s': %s", filename, err)
    41  	}
    42  
    43  	if !doOneInput(t, string(content), fpath) {
    44  		t.Fail()
    45  	}
    46  }