OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // CAUTION: If this file is not vector_test.go, it was generated | 5 // CAUTION: If this file is not vector_test.go, it was generated |
6 // automatically from vector_test.go - DO NOT EDIT in that case! | 6 // automatically from vector_test.go - DO NOT EDIT in that case! |
7 | 7 |
8 package vector | 8 package vector |
9 | 9 |
10 import "testing" | 10 import "testing" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 319 } |
320 count++ | 320 count++ |
321 }) | 321 }) |
322 if count != n { | 322 if count != n { |
323 t.Error(tname(c), "c) should visit", n, "values; did visit", cou
nt) | 323 t.Error(tname(c), "c) should visit", n, "values; did visit", cou
nt) |
324 } | 324 } |
325 | 325 |
326 } | 326 } |
327 | 327 |
328 | 328 |
329 func TestStrVectorData(t *testing.T) { | 329 func TestStrVectorCopy(t *testing.T) { |
330 » // verify Data() returns a slice of a copy, not a slice of the original
vector | 330 » // verify Copy() returns a copy, not simply a slice of the original vect
or |
331 const Len = 10 | 331 const Len = 10 |
332 var src StringVector | 332 var src StringVector |
333 for i := 0; i < Len; i++ { | 333 for i := 0; i < Len; i++ { |
334 src.Push(int2StrValue(i * i)) | 334 src.Push(int2StrValue(i * i)) |
335 } | 335 } |
336 » dest := src.Data() | 336 » dest := src.Copy() |
337 for i := 0; i < Len; i++ { | 337 for i := 0; i < Len; i++ { |
338 src[i] = int2StrValue(-1) | 338 src[i] = int2StrValue(-1) |
339 v := elem2StrValue(dest[i]) | 339 v := elem2StrValue(dest[i]) |
340 if v != int2StrValue(i*i) { | 340 if v != int2StrValue(i*i) { |
341 t.Error(tname(src), "expected", i*i, "got", v) | 341 t.Error(tname(src), "expected", i*i, "got", v) |
342 } | 342 } |
343 } | 343 } |
344 } | 344 } |
OLD | NEW |