...

Source file src/github.com/aws/smithy-go/ptr/to_ptr_test.go

Documentation: github.com/aws/smithy-go/ptr

     1  package ptr
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func TestBool(t *testing.T) {
     9  	var v *bool
    10  	v = Bool(true)
    11  	if !*v {
    12  		t.Errorf("expected %t, but received %t", true, *v)
    13  	}
    14  	v = Bool(false)
    15  	if *v {
    16  		t.Errorf("expected %t, but received %t", false, *v)
    17  	}
    18  }
    19  
    20  func TestBoolSlice(t *testing.T) {
    21  	s := []bool{true, false}
    22  	ps := BoolSlice(s)
    23  	if len(ps) != 2 {
    24  		t.Errorf("expected %d, but received %d", 2, len(ps))
    25  	}
    26  	if !*ps[0] {
    27  		t.Errorf("expected %t, but received %t", true, *ps[0])
    28  	}
    29  	if *ps[1] {
    30  		t.Errorf("expected %t, but received %t", false, *ps[1])
    31  	}
    32  }
    33  
    34  func TestBoolMap(t *testing.T) {
    35  	s := map[string]bool{
    36  		"true":  true,
    37  		"false": false,
    38  	}
    39  	ps := BoolMap(s)
    40  	if len(ps) != 2 {
    41  		t.Errorf("expected %d, but received %d", 2, len(ps))
    42  	}
    43  	if !*ps["true"] {
    44  		t.Errorf("expected %t, but received %t", true, *ps["true"])
    45  	}
    46  	if *ps["false"] {
    47  		t.Errorf("expected %t, but received %t", false, *ps["false"])
    48  	}
    49  }
    50  
    51  func TestByte(t *testing.T) {
    52  	v := Byte(42)
    53  	if *v != 42 {
    54  		t.Errorf("expected %d, but received %d", 42, *v)
    55  	}
    56  }
    57  
    58  func TestByteSlice(t *testing.T) {
    59  	s := []byte{1, 1, 2, 3, 5, 8, 13, 21}
    60  	ps := ByteSlice(s)
    61  	if len(ps) != 8 {
    62  		t.Errorf("expected %d, but received %d", 8, len(ps))
    63  	}
    64  	if *ps[0] != 1 {
    65  		t.Errorf("expected %d, but received %d", 1, *ps[0])
    66  	}
    67  	if *ps[7] != 21 {
    68  		t.Errorf("expected %d, but received %d", 21, *ps[7])
    69  	}
    70  }
    71  
    72  func TestByteMap(t *testing.T) {
    73  	s := map[string]byte{
    74  		"F0": 1,
    75  		"F1": 1,
    76  		"F2": 2,
    77  		"F3": 3,
    78  		"F4": 5,
    79  		"F5": 8,
    80  		"F6": 13,
    81  		"F7": 21,
    82  	}
    83  	ps := ByteMap(s)
    84  	if len(ps) != 8 {
    85  		t.Errorf("expected %d, but received %d", 2, len(ps))
    86  	}
    87  	if *ps["F0"] != 1 {
    88  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
    89  	}
    90  	if *ps["F7"] != 21 {
    91  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
    92  	}
    93  }
    94  
    95  func TestString(t *testing.T) {
    96  	v := String("foo")
    97  	if *v != "foo" {
    98  		t.Errorf("expected %q, but received %q", "foo", *v)
    99  	}
   100  }
   101  
   102  func TestStringSlice(t *testing.T) {
   103  	s := []string{"foo", "bar", "fizz", "buzz", "hoge", "fuga"}
   104  	ps := StringSlice(s)
   105  	if len(ps) != 6 {
   106  		t.Errorf("expected %d, but received %d", 6, len(ps))
   107  	}
   108  	if *ps[0] != "foo" {
   109  		t.Errorf("expected %q, but received %q", "foo", *ps[0])
   110  	}
   111  	if *ps[5] != "fuga" {
   112  		t.Errorf("expected %q, but received %q", "fuga", *ps[5])
   113  	}
   114  }
   115  
   116  func TestStringMap(t *testing.T) {
   117  	s := map[string]string{
   118  		"foo":  "bar",
   119  		"fizz": "buzz",
   120  		"hoge": "fuga",
   121  	}
   122  	ps := StringMap(s)
   123  	if len(ps) != 3 {
   124  		t.Errorf("expected %d, but received %d", 3, len(ps))
   125  	}
   126  	if *ps["foo"] != "bar" {
   127  		t.Errorf("expected %q, but received %q", "foo", *ps["foo"])
   128  	}
   129  	if *ps["hoge"] != "fuga" {
   130  		t.Errorf("expected %q, but received %q", "fuga", *ps["hoge"])
   131  	}
   132  }
   133  
   134  func TestInt(t *testing.T) {
   135  	v := Int(42)
   136  	if *v != 42 {
   137  		t.Errorf("expected %d, but received %d", 42, *v)
   138  	}
   139  }
   140  
   141  func TestIntSlice(t *testing.T) {
   142  	s := []int{1, 1, 2, 3, 5, 8, 13, 21}
   143  	ps := IntSlice(s)
   144  	if len(ps) != 8 {
   145  		t.Errorf("expected %d, but received %d", 8, len(ps))
   146  	}
   147  	if *ps[0] != 1 {
   148  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   149  	}
   150  	if *ps[7] != 21 {
   151  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   152  	}
   153  }
   154  
   155  func TestIntMap(t *testing.T) {
   156  	s := map[string]int{
   157  		"F0": 1,
   158  		"F1": 1,
   159  		"F2": 2,
   160  		"F3": 3,
   161  		"F4": 5,
   162  		"F5": 8,
   163  		"F6": 13,
   164  		"F7": 21,
   165  	}
   166  	ps := IntMap(s)
   167  	if len(ps) != 8 {
   168  		t.Errorf("expected %d, but received %d", 2, len(ps))
   169  	}
   170  	if *ps["F0"] != 1 {
   171  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   172  	}
   173  	if *ps["F7"] != 21 {
   174  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   175  	}
   176  }
   177  
   178  func TestInt8(t *testing.T) {
   179  	v := Int8(42)
   180  	if *v != 42 {
   181  		t.Errorf("expected %d, but received %d", 42, *v)
   182  	}
   183  }
   184  
   185  func TestInt8Slice(t *testing.T) {
   186  	s := []int8{1, 1, 2, 3, 5, 8, 13, 21}
   187  	ps := Int8Slice(s)
   188  	if len(ps) != 8 {
   189  		t.Errorf("expected %d, but received %d", 8, len(ps))
   190  	}
   191  	if *ps[0] != 1 {
   192  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   193  	}
   194  	if *ps[7] != 21 {
   195  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   196  	}
   197  }
   198  
   199  func TestInt8Map(t *testing.T) {
   200  	s := map[string]int8{
   201  		"F0": 1,
   202  		"F1": 1,
   203  		"F2": 2,
   204  		"F3": 3,
   205  		"F4": 5,
   206  		"F5": 8,
   207  		"F6": 13,
   208  		"F7": 21,
   209  	}
   210  	ps := Int8Map(s)
   211  	if len(ps) != 8 {
   212  		t.Errorf("expected %d, but received %d", 2, len(ps))
   213  	}
   214  	if *ps["F0"] != 1 {
   215  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   216  	}
   217  	if *ps["F7"] != 21 {
   218  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   219  	}
   220  }
   221  
   222  func TestInt16(t *testing.T) {
   223  	v := Int16(42)
   224  	if *v != 42 {
   225  		t.Errorf("expected %d, but received %d", 42, *v)
   226  	}
   227  }
   228  
   229  func TestIntSlice16(t *testing.T) {
   230  	s := []int16{1, 1, 2, 3, 5, 8, 13, 21}
   231  	ps := Int16Slice(s)
   232  	if len(ps) != 8 {
   233  		t.Errorf("expected %d, but received %d", 8, len(ps))
   234  	}
   235  	if *ps[0] != 1 {
   236  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   237  	}
   238  	if *ps[7] != 21 {
   239  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   240  	}
   241  }
   242  
   243  func TestInt16Map(t *testing.T) {
   244  	s := map[string]int16{
   245  		"F0": 1,
   246  		"F1": 1,
   247  		"F2": 2,
   248  		"F3": 3,
   249  		"F4": 5,
   250  		"F5": 8,
   251  		"F6": 13,
   252  		"F7": 21,
   253  	}
   254  	ps := Int16Map(s)
   255  	if len(ps) != 8 {
   256  		t.Errorf("expected %d, but received %d", 2, len(ps))
   257  	}
   258  	if *ps["F0"] != 1 {
   259  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   260  	}
   261  	if *ps["F7"] != 21 {
   262  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   263  	}
   264  }
   265  
   266  func TestInt32(t *testing.T) {
   267  	v := Int32(42)
   268  	if *v != 42 {
   269  		t.Errorf("expected %d, but received %d", 42, *v)
   270  	}
   271  }
   272  
   273  func TestInt32Slice(t *testing.T) {
   274  	s := []int32{1, 1, 2, 3, 5, 8, 13, 21}
   275  	ps := Int32Slice(s)
   276  	if len(ps) != 8 {
   277  		t.Errorf("expected %d, but received %d", 8, len(ps))
   278  	}
   279  	if *ps[0] != 1 {
   280  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   281  	}
   282  	if *ps[7] != 21 {
   283  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   284  	}
   285  }
   286  
   287  func TestInt32Map(t *testing.T) {
   288  	s := map[string]int32{
   289  		"F0": 1,
   290  		"F1": 1,
   291  		"F2": 2,
   292  		"F3": 3,
   293  		"F4": 5,
   294  		"F5": 8,
   295  		"F6": 13,
   296  		"F7": 21,
   297  	}
   298  	ps := Int32Map(s)
   299  	if len(ps) != 8 {
   300  		t.Errorf("expected %d, but received %d", 2, len(ps))
   301  	}
   302  	if *ps["F0"] != 1 {
   303  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   304  	}
   305  	if *ps["F7"] != 21 {
   306  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   307  	}
   308  }
   309  
   310  func TestInt64(t *testing.T) {
   311  	v := Int64(42)
   312  	if *v != 42 {
   313  		t.Errorf("expected %d, but received %d", 42, *v)
   314  	}
   315  }
   316  
   317  func TestInt64Slice(t *testing.T) {
   318  	s := []int64{1, 1, 2, 3, 5, 8, 13, 21}
   319  	ps := Int64Slice(s)
   320  	if len(ps) != 8 {
   321  		t.Errorf("expected %d, but received %d", 8, len(ps))
   322  	}
   323  	if *ps[0] != 1 {
   324  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   325  	}
   326  	if *ps[7] != 21 {
   327  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   328  	}
   329  }
   330  
   331  func TestInt64Map(t *testing.T) {
   332  	s := map[string]int64{
   333  		"F0": 1,
   334  		"F1": 1,
   335  		"F2": 2,
   336  		"F3": 3,
   337  		"F4": 5,
   338  		"F5": 8,
   339  		"F6": 13,
   340  		"F7": 21,
   341  	}
   342  	ps := Int64Map(s)
   343  	if len(ps) != 8 {
   344  		t.Errorf("expected %d, but received %d", 2, len(ps))
   345  	}
   346  	if *ps["F0"] != 1 {
   347  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   348  	}
   349  	if *ps["F7"] != 21 {
   350  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   351  	}
   352  }
   353  
   354  func TestUint(t *testing.T) {
   355  	v := Uint(42)
   356  	if *v != 42 {
   357  		t.Errorf("expected %d, but received %d", 42, *v)
   358  	}
   359  }
   360  
   361  func TestUintSlice(t *testing.T) {
   362  	s := []uint{1, 1, 2, 3, 5, 8, 13, 21}
   363  	ps := UintSlice(s)
   364  	if len(ps) != 8 {
   365  		t.Errorf("expected %d, but received %d", 8, len(ps))
   366  	}
   367  	if *ps[0] != 1 {
   368  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   369  	}
   370  	if *ps[7] != 21 {
   371  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   372  	}
   373  }
   374  
   375  func TestUintMap(t *testing.T) {
   376  	s := map[string]uint{
   377  		"F0": 1,
   378  		"F1": 1,
   379  		"F2": 2,
   380  		"F3": 3,
   381  		"F4": 5,
   382  		"F5": 8,
   383  		"F6": 13,
   384  		"F7": 21,
   385  	}
   386  	ps := UintMap(s)
   387  	if len(ps) != 8 {
   388  		t.Errorf("expected %d, but received %d", 2, len(ps))
   389  	}
   390  	if *ps["F0"] != 1 {
   391  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   392  	}
   393  	if *ps["F7"] != 21 {
   394  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   395  	}
   396  }
   397  
   398  func TestUint8(t *testing.T) {
   399  	v := Uint8(42)
   400  	if *v != 42 {
   401  		t.Errorf("expected %d, but received %d", 42, *v)
   402  	}
   403  }
   404  
   405  func TestUint8Slice(t *testing.T) {
   406  	s := []uint8{1, 1, 2, 3, 5, 8, 13, 21}
   407  	ps := Uint8Slice(s)
   408  	if len(ps) != 8 {
   409  		t.Errorf("expected %d, but received %d", 8, len(ps))
   410  	}
   411  	if *ps[0] != 1 {
   412  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   413  	}
   414  	if *ps[7] != 21 {
   415  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   416  	}
   417  }
   418  
   419  func TestUint8Map(t *testing.T) {
   420  	s := map[string]uint8{
   421  		"F0": 1,
   422  		"F1": 1,
   423  		"F2": 2,
   424  		"F3": 3,
   425  		"F4": 5,
   426  		"F5": 8,
   427  		"F6": 13,
   428  		"F7": 21,
   429  	}
   430  	ps := Uint8Map(s)
   431  	if len(ps) != 8 {
   432  		t.Errorf("expected %d, but received %d", 2, len(ps))
   433  	}
   434  	if *ps["F0"] != 1 {
   435  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   436  	}
   437  	if *ps["F7"] != 21 {
   438  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   439  	}
   440  }
   441  
   442  func TestUint16(t *testing.T) {
   443  	v := Uint16(42)
   444  	if *v != 42 {
   445  		t.Errorf("expected %d, but received %d", 42, *v)
   446  	}
   447  }
   448  
   449  func TestUintSlice16(t *testing.T) {
   450  	s := []uint16{1, 1, 2, 3, 5, 8, 13, 21}
   451  	ps := Uint16Slice(s)
   452  	if len(ps) != 8 {
   453  		t.Errorf("expected %d, but received %d", 8, len(ps))
   454  	}
   455  	if *ps[0] != 1 {
   456  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   457  	}
   458  	if *ps[7] != 21 {
   459  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   460  	}
   461  }
   462  
   463  func TestUint16Map(t *testing.T) {
   464  	s := map[string]uint{
   465  		"F0": 1,
   466  		"F1": 1,
   467  		"F2": 2,
   468  		"F3": 3,
   469  		"F4": 5,
   470  		"F5": 8,
   471  		"F6": 13,
   472  		"F7": 21,
   473  	}
   474  	ps := UintMap(s)
   475  	if len(ps) != 8 {
   476  		t.Errorf("expected %d, but received %d", 2, len(ps))
   477  	}
   478  	if *ps["F0"] != 1 {
   479  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   480  	}
   481  	if *ps["F7"] != 21 {
   482  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   483  	}
   484  }
   485  
   486  func TestUint32(t *testing.T) {
   487  	v := Uint32(42)
   488  	if *v != 42 {
   489  		t.Errorf("expected %d, but received %d", 42, *v)
   490  	}
   491  }
   492  
   493  func TestUint32Slice(t *testing.T) {
   494  	s := []uint32{1, 1, 2, 3, 5, 8, 13, 21}
   495  	ps := Uint32Slice(s)
   496  	if len(ps) != 8 {
   497  		t.Errorf("expected %d, but received %d", 8, len(ps))
   498  	}
   499  	if *ps[0] != 1 {
   500  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   501  	}
   502  	if *ps[7] != 21 {
   503  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   504  	}
   505  }
   506  
   507  func TestUint32Map(t *testing.T) {
   508  	s := map[string]uint32{
   509  		"F0": 1,
   510  		"F1": 1,
   511  		"F2": 2,
   512  		"F3": 3,
   513  		"F4": 5,
   514  		"F5": 8,
   515  		"F6": 13,
   516  		"F7": 21,
   517  	}
   518  	ps := Uint32Map(s)
   519  	if len(ps) != 8 {
   520  		t.Errorf("expected %d, but received %d", 2, len(ps))
   521  	}
   522  	if *ps["F0"] != 1 {
   523  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   524  	}
   525  	if *ps["F7"] != 21 {
   526  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   527  	}
   528  }
   529  
   530  func TestUint64(t *testing.T) {
   531  	v := Uint64(42)
   532  	if *v != 42 {
   533  		t.Errorf("expected %d, but received %d", 42, *v)
   534  	}
   535  }
   536  
   537  func TestUint64Slice(t *testing.T) {
   538  	s := []uint64{1, 1, 2, 3, 5, 8, 13, 21}
   539  	ps := Uint64Slice(s)
   540  	if len(ps) != 8 {
   541  		t.Errorf("expected %d, but received %d", 8, len(ps))
   542  	}
   543  	if *ps[0] != 1 {
   544  		t.Errorf("expected %d, but received %d", 1, *ps[0])
   545  	}
   546  	if *ps[7] != 21 {
   547  		t.Errorf("expected %d, but received %d", 21, *ps[7])
   548  	}
   549  }
   550  
   551  func TestUint64Map(t *testing.T) {
   552  	s := map[string]uint64{
   553  		"F0": 1,
   554  		"F1": 1,
   555  		"F2": 2,
   556  		"F3": 3,
   557  		"F4": 5,
   558  		"F5": 8,
   559  		"F6": 13,
   560  		"F7": 21,
   561  	}
   562  	ps := Uint64Map(s)
   563  	if len(ps) != 8 {
   564  		t.Errorf("expected %d, but received %d", 2, len(ps))
   565  	}
   566  	if *ps["F0"] != 1 {
   567  		t.Errorf("expected %d, but received %d", 1, *ps["F0"])
   568  	}
   569  	if *ps["F7"] != 21 {
   570  		t.Errorf("expected %d, but received %d", 21, *ps["F7"])
   571  	}
   572  }
   573  
   574  func TestFloat32(t *testing.T) {
   575  	v := Float32(0.5)
   576  	if *v != 0.5 {
   577  		t.Errorf("expected %f, but received %f", 0.5, *v)
   578  	}
   579  }
   580  
   581  func TestFloat32Slice(t *testing.T) {
   582  	s := []float32{0.5, 0.25, 0.125, 0.0625}
   583  	ps := Float32Slice(s)
   584  	if len(ps) != 4 {
   585  		t.Errorf("expected %d, but received %d", 4, len(ps))
   586  	}
   587  	if *ps[0] != 0.5 {
   588  		t.Errorf("expected %f, but received %f", 0.5, *ps[0])
   589  	}
   590  	if *ps[3] != 0.0625 {
   591  		t.Errorf("expected %f, but received %f", 0.0625, *ps[7])
   592  	}
   593  }
   594  
   595  func TestFloat32Map(t *testing.T) {
   596  	s := map[string]float32{
   597  		"F0": 0.5,
   598  		"F1": 0.25,
   599  		"F2": 0.125,
   600  		"F3": 0.0625,
   601  	}
   602  	ps := Float32Map(s)
   603  	if len(ps) != 4 {
   604  		t.Errorf("expected %d, but received %d", 4, len(ps))
   605  	}
   606  	if *ps["F0"] != 0.5 {
   607  		t.Errorf("expected %f, but received %f", 0.5, *ps["F0"])
   608  	}
   609  	if *ps["F3"] != 0.0625 {
   610  		t.Errorf("expected %f, but received %f", 0.0625, *ps["F3"])
   611  	}
   612  }
   613  
   614  func TestFloat64(t *testing.T) {
   615  	v := Float64(0.5)
   616  	if *v != 0.5 {
   617  		t.Errorf("expected %f, but received %f", 0.5, *v)
   618  	}
   619  }
   620  
   621  func TestFloat64Slice(t *testing.T) {
   622  	s := []float64{0.5, 0.25, 0.125, 0.0625}
   623  	ps := Float64Slice(s)
   624  	if len(ps) != 4 {
   625  		t.Errorf("expected %d, but received %d", 4, len(ps))
   626  	}
   627  	if *ps[0] != 0.5 {
   628  		t.Errorf("expected %f, but received %f", 0.5, *ps[0])
   629  	}
   630  	if *ps[3] != 0.0625 {
   631  		t.Errorf("expected %f, but received %f", 0.0625, *ps[7])
   632  	}
   633  }
   634  
   635  func TestFloat64Map(t *testing.T) {
   636  	s := map[string]float64{
   637  		"F0": 0.5,
   638  		"F1": 0.25,
   639  		"F2": 0.125,
   640  		"F3": 0.0625,
   641  	}
   642  	ps := Float64Map(s)
   643  	if len(ps) != 4 {
   644  		t.Errorf("expected %d, but received %d", 4, len(ps))
   645  	}
   646  	if *ps["F0"] != 0.5 {
   647  		t.Errorf("expected %f, but received %f", 0.5, *ps["F0"])
   648  	}
   649  	if *ps["F3"] != 0.0625 {
   650  		t.Errorf("expected %f, but received %f", 0.0625, *ps["F3"])
   651  	}
   652  }
   653  
   654  func TestTime(t *testing.T) {
   655  	v := Time(time.Unix(1234567890, 0))
   656  	if v.Unix() != 1234567890 {
   657  		t.Errorf("expected %d, but received %d", 1234567890, v.Unix())
   658  	}
   659  }
   660  
   661  func TestTimeSlice(t *testing.T) {
   662  	s := []time.Time{time.Unix(1234567890, 0), time.Unix(2147483647, 0)}
   663  	ps := TimeSlice(s)
   664  	if len(ps) != 2 {
   665  		t.Errorf("expected %d, but received %d", 2, len(ps))
   666  	}
   667  	if ps[0].Unix() != 1234567890 {
   668  		t.Errorf("expected %d, but received %d", 1234567890, ps[0].Unix())
   669  	}
   670  	if ps[1].Unix() != 2147483647 {
   671  		t.Errorf("expected %d, but received %d", 2147483647, ps[1].Unix())
   672  	}
   673  }
   674  
   675  func TestTimeMap(t *testing.T) {
   676  	s := map[string]time.Time{
   677  		"2009-02-13T23:31:30Z": time.Unix(1234567890, 0),
   678  		"2038-01-19T03:14:07Z": time.Unix(2147483647, 0),
   679  	}
   680  	ps := TimeMap(s)
   681  	if len(ps) != 2 {
   682  		t.Errorf("expected %d, but received %d", 2, len(ps))
   683  	}
   684  	if ps["2009-02-13T23:31:30Z"].Unix() != 1234567890 {
   685  		t.Errorf("expected %d, but received %d", 1234567890, ps["2009-02-13T23:31:30Z"].Unix())
   686  	}
   687  	if ps["2038-01-19T03:14:07Z"].Unix() != 2147483647 {
   688  		t.Errorf("expected %d, but received %d", 2147483647, ps["2038-01-19T03:14:07Z"].Unix())
   689  	}
   690  }
   691  

View as plain text