PNG  IHDR  8] PLTE S =tRNS   PNG  IHDR  8] PLTE S =tRNS   REDROOM
PHP 7.4.33
Preview: stringer_test.go Size: 2.11 KB
/proc/thread-self/root/opt/golang/1.22.0/src/fmt/stringer_test.go

// Copyright 2010 The Go 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 fmt_test

import (
	. "fmt"
	"testing"
)

type TI int
type TI8 int8
type TI16 int16
type TI32 int32
type TI64 int64
type TU uint
type TU8 uint8
type TU16 uint16
type TU32 uint32
type TU64 uint64
type TUI uintptr
type TF float64
type TF32 float32
type TF64 float64
type TB bool
type TS string

func (v TI) String() string   { return Sprintf("I: %d", int(v)) }
func (v TI8) String() string  { return Sprintf("I8: %d", int8(v)) }
func (v TI16) String() string { return Sprintf("I16: %d", int16(v)) }
func (v TI32) String() string { return Sprintf("I32: %d", int32(v)) }
func (v TI64) String() string { return Sprintf("I64: %d", int64(v)) }
func (v TU) String() string   { return Sprintf("U: %d", uint(v)) }
func (v TU8) String() string  { return Sprintf("U8: %d", uint8(v)) }
func (v TU16) String() string { return Sprintf("U16: %d", uint16(v)) }
func (v TU32) String() string { return Sprintf("U32: %d", uint32(v)) }
func (v TU64) String() string { return Sprintf("U64: %d", uint64(v)) }
func (v TUI) String() string  { return Sprintf("UI: %d", uintptr(v)) }
func (v TF) String() string   { return Sprintf("F: %f", float64(v)) }
func (v TF32) String() string { return Sprintf("F32: %f", float32(v)) }
func (v TF64) String() string { return Sprintf("F64: %f", float64(v)) }
func (v TB) String() string   { return Sprintf("B: %t", bool(v)) }
func (v TS) String() string   { return Sprintf("S: %q", string(v)) }

func check(t *testing.T, got, want string) {
	if got != want {
		t.Error(got, "!=", want)
	}
}

func TestStringer(t *testing.T) {
	s := Sprintf("%v %v %v %v %v", TI(0), TI8(1), TI16(2), TI32(3), TI64(4))
	check(t, s, "I: 0 I8: 1 I16: 2 I32: 3 I64: 4")
	s = Sprintf("%v %v %v %v %v %v", TU(5), TU8(6), TU16(7), TU32(8), TU64(9), TUI(10))
	check(t, s, "U: 5 U8: 6 U16: 7 U32: 8 U64: 9 UI: 10")
	s = Sprintf("%v %v %v", TF(1.0), TF32(2.0), TF64(3.0))
	check(t, s, "F: 1.000000 F32: 2.000000 F64: 3.000000")
	s = Sprintf("%v %v", TB(true), TS("x"))
	check(t, s, "B: true S: \"x\"")
}

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
14.54 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
1.68 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
3.62 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
11.82 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
219 B lrw-r--r-- 2024-02-02 18:09:55
Edit Download
58.36 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
13.59 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
1.55 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
31.86 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
31.89 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
39.28 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
1.44 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download
551 B lrw-r--r-- 2024-02-02 18:09:55
Edit Download
2.11 KB lrw-r--r-- 2024-02-02 18:09:55
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
 !"#$%&'(()*+,-./00123456789 t\ wIDATx ]ys  47Y ƒ -  "  Rv  < f{Ɛ $k l L > L  ~h^ 1  [  r G t& h  l F z3O Y ! p A(_g̷ E8 )S 8 c  Kb"z ~ 5 J xAL WU <  *  5 m;W a pB h ~P J 2 3 6 ҙ .Ƹ P i  4g F R L P ΪK/D  M v (a3 k J Œ4N5* SH ` SdJ z  O J Xՠ V>u ߱ BE&L b2 ?2` tX+  c CB A$ i b C ĀMB E : /  # Dx &l =q Ty  0 \p I ( L Ǎ { e 4k ;`u^ヲ eP!( d {  )T A 8 O;Ě n >;s6 !  :Nx `[S D HU ~ q›J F} a g*D 49 / pn k h (t 8NxƐF _!r չ7 ZR R׷ q/5") Ӎ NY 0 x sZ!   o  fu  ,  K"$ ? pg  㕣=  1» {h " fh7    y  } € +7  $ y " X —ą - G P u 4 m >J 5 L =V ' ^@I p ?MS xЌ XV P ! h "C NS9B8̢ ]!K  e   zA , ӏkbY  !< XQ ٿyS| *" f { w  4@[S <  # 0 ! js [m  =,~ o "ݎ DHf Wo $ g ! Vԅ t mB /y Wf V4񺍸 c+@x?  B ~u " xUN e 0 BĂ) ~J pz! 7y6]l Ԥ@ P a< O /DHC `≻  N m"$  0ObB }{ x AO FCG D R ^ "B  { WDH  UR l@ T #  +"d T ; 0 i  D}. 7 ` ' ] w rE &S i ƕiTD EL P _ u h $ Ա FG wVD G L R Zf ' .!] J /ZR oGЍs Mr Ĥ ʬ 3 Q [3 cL ` ^ p + ( F;# B 5 '  2Y f [  ϶R0e }  E 7 6M aۮ H <& n % L] E}Up x紉, Uw' Q  Ǯշo k ވۙ 0N94 VX5 xEDE l D #֤ } C o )W :  ^ s 9  bRf iX5u ཱི 4 :[  T 1. | [E 2ؽ Iy\ : o x K G 5 ylP ' uK E ftb/i[3 .g _  [3M n G, #NwQ5~  ؚ) | n =Ц"x qg gB ` 듘 ~ x w ? ? R~  _ u. &VQ K˻   H C ( TN˄+ `C dA nB׭ D 3"Z G ê ^k H_ /- ~ " R_  .8 Z_ 6@ o  xg  uP ? 3լ @7AM!  E7^ - =V L  x  g-D0  CtmW 7  O  G _ WD0 g C  w1 r d w : a | \  *" f nֳ ^ H# f L ` Z ۽hV  }S F r0Ù Bć5r] @! NL iQ]{s^=4 d  WD  "  "   M; t" 8 5 e dL| "-*st" ) SWD ?R[S e ooF  20.D ? bo =) A i o d ģ ZҰaO @E =) i D a &ܟa CϞ y6 ,<%{^x%{f8? `iw^ ?/ M * IEND B`