mirror of
				https://github.com/gonum/gonum.git
				synced 2025-10-26 08:40:26 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			900 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			900 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by "go generate gonum.org/v1/gonum/unit; DO NOT EDIT.
 | |
| 
 | |
| // Copyright ©2019 The Gonum Authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| package unit
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestCurrentFormat(t *testing.T) {
 | |
| 	for _, test := range []struct {
 | |
| 		value  Current
 | |
| 		format string
 | |
| 		want   string
 | |
| 	}{
 | |
| 		{1.23456789, "%v", "1.23456789 A"},
 | |
| 		{1.23456789, "%.1v", "1 A"},
 | |
| 		{1.23456789, "%20.1v", "                 1 A"},
 | |
| 		{1.23456789, "%20v", "        1.23456789 A"},
 | |
| 		{1.23456789, "%1v", "1.23456789 A"},
 | |
| 		{1.23456789, "%#v", "unit.Current(1.23456789)"},
 | |
| 		{1.23456789, "%s", "%!s(unit.Current=1.23456789 A)"},
 | |
| 	} {
 | |
| 		got := fmt.Sprintf(test.format, test.value)
 | |
| 		if got != test.want {
 | |
| 			t.Errorf("Format %q %v: got: %q want: %q", test.format, float64(test.value), got, test.want)
 | |
| 		}
 | |
| 	}
 | |
| }
 | 
