Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Indivizo/66-private-slice
Fix merging private slices (issue 66)
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mergo | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
type PrivateSliceTest66 struct { | ||
PublicStrings []string | ||
|
||
privateStrings []string | ||
} | ||
|
||
func TestPrivateSlice(t *testing.T) { | ||
p1 := PrivateSliceTest66{ | ||
PublicStrings: []string{"one", "two", "three"}, | ||
privateStrings: []string{"four", "five"}, | ||
} | ||
|
||
p2 := PrivateSliceTest66{ | ||
PublicStrings: []string{"six", "seven"}, | ||
} | ||
|
||
if err := Merge(&p1, p2); err != nil { | ||
t.Fatalf("Error during the merge: %v", err) | ||
} | ||
|
||
if len(p1.PublicStrings) != 5 { | ||
t.Error("5 elements should be in 'PublicStrings' field") | ||
} | ||
|
||
if len(p1.privateStrings) != 2 { | ||
t.Error("2 elements should be in 'privateStrings' field") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters